Daily Archives

Articles indexed Saturday December 25 2010

Page 1/22 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to pass a Context when using acts_as_taggable_on for assigning tags

    - by kbjerring
    I am using acts_as_taggable_on for assigning 'fixed' categories as well as free' tags to a Company model. My question is how I can pass the correct tag Context for the two different kinds of tags in the form view. For instance, I would like the user to click all the "sector" categories that apply to a company, and then be freely allowed to add additional tags. At this point, the only way I have gotten this to work is through the company model (inspired by this question): # models/company.rb class Company ... acts_as_taggable_on :sectors, :tags has_many :sector_tags, :through => :taggings, :source => :tag, has_many :taggings, :as => :taggable, :include => :tag, :class_name => "ActsAsTaggableOn::Tagging", :conditions => { :taggable_type => "Company", :context => "sectors" } ... end in the form (using the simple_form gem) I have... # views/companies/_form.html.haml = simple_form_for @company do |f| = f.input :name = f.association :sector_tags, :as => :check_boxes, :hint => "Please click all that apply" = f.input :tag_list But this obviously causes the two tag types ("sectors" and "tags") to be of the same "sectors" context which is not what I want. Can anyone hint at how I can pass the relevant Context ("sectors") in the form where the user assigns the sector tags? Or maybe I can pass it in the "has_many :sector_tags ..." line in the Company model? A related question is if this is a good way to do it at all? Would I be better off just using a Category model for assigning sector tags through a joint model? Thanks!

    Read the article

  • What is the structure of a (Data Access) Service Class

    - by jiewmeng
    I learnt that I should be using service classes to persist entities into the database instead of putting such logic in models/controllers. I currently made my service class something like class Application_DAO_User { protected $user; public function __construct(User $user) { $this->user = $user } public function edit($name, ...) { $this->user->name = $name; ... $this->em->flush(); } } I wonder if this should be the structure of a service class? where a service object represents a entity/model? Or maybe I should pass a User object everytime I want to do a edit like public static function edit($user, $name) { $user->name = $name; $this->em->flush(); } I am using Doctrine 2 & Zend Framework, but it shouldn't matter

    Read the article

  • Is there a way for std::map to "edit" values like a predicate for the key?

    - by Marlon
    I am wondering if it is possible to create something like a predicate for a std::map for all of its values so I don't have to edit the values before I insert them into the map. What I would like is something like this: mymap["username"] = " Marlon "; // notice the space on both sides of my name assert(mymap["username"] == "Marlon"); // no more whitespace The context is I am creating a std::map for a .ini file and I would like it to automatically remove leading/trailing whitespace from the values when I want to retrieve them. I've already created a predicate to ignore casing and whitespace from the key so I want to know if it is possible to do the same for the value.

    Read the article

  • Getting started with SVG graphics objects in JSF 2.0 pages.

    - by AlanObject
    What I want to do is create web pages with interactive SVG content. I had this working as a Java desktop application using Batik to render my SVG and collect UI events like mouseclick. Now I want to use those SVG graphics files in my JSF (Primefaces) web application in the same way. Trying to get started, I found this didn't work: <h:graphicImage id="gloob" value="images/sprinkverks.svg" alt="Graphic Goes Here"/> I don't mind doing some reading to get up the learning curve. It was just a bit surprising that some google searches didn't turn up anything useful. What I did find suggested that I would have to do this with the f:verbatim tag as if I were hand-coding the HTML. I would then have to add some script to capture the SVG events and feed them back into the AJAX code. If I have to do all that I will, but I was hoping there would be an easier and automated way. So the questions are: How to get the image to render in the first place? How to get the DOM events from the SVG portion of the page back to the backing beans? Much thanks for any pointers.

    Read the article

  • Covariance and Contravariance on the same type argument

    - by William Edmondson
    The C# spec states that an argument type cannot be both covariant and contravariant at the same time. This is apparent when creating a covariant or contravariant interface you decorate your type parameters with "out" or "in" respectively. There is not option that allows both at the same time ("outin"). Is this limitation simply a language specific constraint or are there deeper, more fundamental reasons based in category theory that would make you not want your type to be both covariant and contravariant? Edit: My understanding was that arrays were actually both covariant and contravariant. public class Pet{} public class Cat : Pet{} public class Siamese : Cat{} Cat[] cats = new Cat[10]; Pet[] pets = new Pet[10]; Siamese[] siameseCats = new Siamese[10]; //Cat array is covariant pets = cats; //Cat array is also contravariant since it accepts conversions from wider types cats = siameseCats;

    Read the article

  • How can I make jQuery Autocomplete replaces only certain word - not full string?

    - by user553640
    I am using bassistance.de jQuery Autocomplete function. Have text like "hello to you @john" I made, Autocomplete run only when character @ is in word. But when I click on the needed item, it replaces me full text. How can I do so - to replace only "@john"? Or maybe there is another Autocomplete plugin for jQuery, which has such ability? $('#input_line').autocomplete('data.php', { extraParams: {input: function(){return GetTextareaWord("input_line");}} });

    Read the article

  • Convert alphabet letters to number in python

    - by altin
    Can someone help me finish this characters = ['a''b''c''d''e''f''g''h''i''j''k''l''m''n''o''p''q''r''t''u''v''w''x''y''z'] numbers = ['1''2''3''4''5''6''7''8''9''10''11''12''13''14''15''16''17''18''19''20''21''22''23''24'] text = raw_input(' Write text: ') Ive tryed to many ways but couldnt get to the pint, I want to make exc if i type hello the output to be in numbers lined like in alphabet... example a = 1 < in alphabet Can anyone give ideas ? or help sth ?

    Read the article

  • In Java Concurrency In Practice by Brian Goetz, why is the Memoizer class not annotated with @ThreadSafe?

    - by dig_dug
    Java Concurrency In Practice by Brian Goetz provides an example of a efficient scalable cache for concurrent use. The final version of the example showing the implementation for class Memoizer (pg 108) shows such a cache. I am wondering why the class is not annotated with @ThreadSafe? The client, class Factorizer, of the cache is properly annotated with @ThreadSafe. The appendix states that if a class is not annotated with either @ThreadSafe or @Immutable that it should be assumed that it isn't thread safe. Memoizer seems thread-safe though. Here is the code for Memoizer: public class Memoizer<A, V> implements Computable<A, V> { private final ConcurrentMap<A, Future<V>> cache = new ConcurrentHashMap<A, Future<V>>(); private final Computable<A, V> c; public Memoizer(Computable<A, V> c) { this.c = c; } public V compute(final A arg) throws InterruptedException { while (true) { Future<V> f = cache.get(arg); if (f == null) { Callable<V> eval = new Callable<V>() { public V call() throws InterruptedException { return c.compute(arg); } }; FutureTask<V> ft = new FutureTask<V>(eval); f = cache.putIfAbsent(arg, ft); if (f == null) { f = ft; ft.run(); } } try { return f.get(); } catch (CancellationException e) { cache.remove(arg, f); } catch (ExecutionException e) { throw launderThrowable(e.getCause()); } } } }

    Read the article

  • How to select one object from a NSArray?

    - by 0SX
    First of all Merry Christmas to everyone!!! Currently I have a NSArray that has parsed content in it. When I do a NSLog of the array it prints out 20 objects with the parsed content that I needed. Like so: 2010-12-24 20:27:32.170 TestProject[48914:298] SomeContent 2010-12-24 20:27:32.172 TestProject[48914:298] SomeContent1 2010-12-24 20:27:32.172 TestProject[48914:298] SomeContent2 2010-12-24 20:27:32.173 TestProject[48914:298] SomeContent3 2010-12-24 20:27:32.173 TestProject[48914:298] SomeContent4 2010-12-24 20:27:32.173 TestProject[48914:298] SomeContent5 2010-12-24 20:27:32.174 TestProject[48914:298] SomeContent6 2010-12-24 20:27:32.175 TestProject[48914:298] SomeContent7 2010-12-24 20:27:32.176 TestProject[48914:298] SomeContent8 2010-12-24 20:27:32.176 TestProject[48914:298] SomeContent9 2010-12-24 20:27:32.177 TestProject[48914:298] SomeContent10 2010-12-24 20:27:32.177 TestProject[48914:298] SomeContent11 2010-12-24 20:27:32.177 TestProject[48914:298] SomeContent12 2010-12-24 20:27:32.179 TestProject[48914:298] SomeContent13 2010-12-24 20:27:32.179 TestProject[48914:298] SomeContent14 2010-12-24 20:27:32.180 TestProject[48914:298] SomeContent15 2010-12-24 20:27:32.180 TestProject[48914:298] SomeContent16 2010-12-24 20:27:32.181 TestProject[48914:298] SomeContent17 2010-12-24 20:27:32.181 TestProject[48914:298] SomeContent18 2010-12-24 20:27:32.190 TestProject[48914:298] SomeContent19 However, I don't need every object at once. I need to be able to pick out one object at a time so I can put each object into a string of it's own. If anyone knows a easier way to do this then what I'm trying to please let me know. Anyways, I need to be able to choose just one object depending on what object I need. For example, let's say I only need object #5 and not all the array, how can this be done so I can put it into a string? I'm thinking I might have to use the index feature but I'm not sure how to set it up properly. Here is my NSArray that I'm working with: NSArray* myArray = [document selectElements: @"div.someContent"]; NSMutableArray* results = [NSMutableArray array]; for (Element* element in myArray){ NSString* snipet = [element contentsSource]; [results addObject: snipet]; NSLog(@"%@", snipet); } NSLog(@"%i",myArray.count); I've already spent several hours trying to achieve this but my knowledge with array's is limited even with me reading the documentation. :-( Any help is much appreciated. Thanks

    Read the article

  • dell server display on laptop screen

    - by hari
    Please redirect if this is not (and probably thats true) the correct forum/site. I have a dell server and I am trying to configure it for the first time. It is running windows server 2003. I do not have a monitor screen. Can I use laptop screen to display dell server and set it up? I mean to say is, if I can display dell server on laptop screen, it would be great. I am trying that with a dell laptop but not getting the display. Any help/pointer would be appreciated. Thanks in advance.

    Read the article

  • problem with my texture coordinates on a square.

    - by Evan Kimia
    Im very new to OpenGL ES, and have been doing a tutorial to build a square. The square is made, and now im trying to map a 256 by 256 image onto it. The problem is, im only seeing a very zoomed in portion of this bitmap; Im fairly certain my texture coords are whats wrong here. Thanks! package se.jayway.opengl.tutorial; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; import javax.microedition.khronos.opengles.GL10; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.opengl.GLUtils; public class Square { // Our vertices. private float vertices[] = { -1.0f, 1.0f, 0.0f, // 0, Top Left -1.0f, -1.0f, 0.0f, // 1, Bottom Left 1.0f, -1.0f, 0.0f, // 2, Bottom Right 1.0f, 1.0f, 0.0f, // 3, Top Right }; //Our texture. private float texture[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, }; // The order we like to connect them. private short[] indices = { 0, 1, 2, 0, 2, 3 }; // Our vertex buffer. private FloatBuffer vertexBuffer; // Our index buffer. private ShortBuffer indexBuffer; //texture buffer. private FloatBuffer textureBuffer; //Our texture pointer. private int[] textures = new int[1]; public Square() { // a float is 4 bytes, therefore we multiply the number if // vertices with 4. ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4); vbb.order(ByteOrder.nativeOrder()); vertexBuffer = vbb.asFloatBuffer(); vertexBuffer.put(vertices); vertexBuffer.position(0); // a float is 4 bytes, therefore we multiply the number of // vertices with 4. ByteBuffer tbb = ByteBuffer.allocateDirect(texture.length * 4); vbb.order(ByteOrder.nativeOrder()); textureBuffer = tbb.asFloatBuffer(); textureBuffer.put(texture); textureBuffer.position(0); // short is 2 bytes, therefore we multiply the number if // vertices with 2. ByteBuffer ibb = ByteBuffer.allocateDirect(indices.length * 2); ibb.order(ByteOrder.nativeOrder()); indexBuffer = ibb.asShortBuffer(); indexBuffer.put(indices); indexBuffer.position(0); } /** * This function draws our square on screen. * @param gl */ public void draw(GL10 gl) { // Counter-clockwise winding. gl.glFrontFace(GL10.GL_CCW); // Enable face culling. gl.glEnable(GL10.GL_CULL_FACE); // What faces to remove with the face culling. gl.glCullFace(GL10.GL_BACK); //Bind our only previously generated texture in this case gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); // Enabled the vertices buffer for writing and to be used during // rendering. gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); //Enable texture buffer array gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Specifies the location and data format of an array of vertex // coordinates to use when rendering. gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer); // Disable the vertices buffer. gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); //Disable the texture buffer. gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); // Disable face culling. gl.glDisable(GL10.GL_CULL_FACE); } /** * Load the textures * * @param gl - The GL Context * @param context - The Activity context */ public void loadGLTexture(GL10 gl, Context context) { //Get the texture from the Android resource directory InputStream is = context.getResources().openRawResource(R.drawable.test); Bitmap bitmap = null; try { //BitmapFactory is an Android graphics utility for images bitmap = BitmapFactory.decodeStream(is); } finally { //Always clear and close try { is.close(); is = null; } catch (IOException e) { } } //Generate one texture pointer... gl.glGenTextures(1, textures, 0); //...and bind it to our array gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]); //Create Nearest Filtered Texture gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); //Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT); //Use the Android GLUtils to specify a two-dimensional texture image from our bitmap GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0); //Clean up bitmap.recycle(); } }

    Read the article

  • Help with SDL_mixer (no sound)

    - by Kaizoku
    Hello, I have this strange problem with SDL_mixer, it doesn't want to play music. It doesn't throw any error, it just skips it. Any advice? I am compiling on linux with libvorbis. audio.h #ifndef AUDIO_H #define AUDIO_H #include <string> #include <SDL/SDL_mixer.h> class Audio { private: Mix_Music *music; public: Audio(); virtual ~Audio(); public: void setMusic(std::string path); void playMusic(); }; #endif /* AUDIO_H */ audio.cpp #include "Audio.h" #include <stdexcept> Audio::Audio() { if (0 == Mix_Init(MIX_INIT_OGG)) throw std::runtime_error(Mix_GetError()); if (-1 == Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096)) throw std::runtime_error(Mix_GetError()); } Audio::~Audio() { Mix_FreeMusic(music); Mix_Quit(); } void Audio::setMusic(std::string path) { music = Mix_LoadMUS(path.c_str()); if (NULL == music) throw std::runtime_error(Mix_GetError()); } void Audio::playMusic() { if (NULL != music) { if (-1 == Mix_PlayMusic(music, -1)) throw std::runtime_error(Mix_GetError()); } }

    Read the article

  • MySQL 5.5 on Windows server is horribly slow

    - by Brad
    I have had no luck getting MySQL 5.5 to be as fast as 5.1 or MariaDB on the exact same hardware/database/environment under Windows server 2003R2 or 2008R2. My benchmarks from our application: MySQL 5.5 + CentOS 5.2 (XenServer Virtual) = 28 seconds (box is "busy" not buried) MariaDB (5.1) + Windows 2003 (Physical box) = 130 seconds (box is 2% busy) MySQL 5.1 + Windows 2003 (Physical box) = 170 seconds (box is 2% busy) MySQL 5.5 + Windows 2003 (Physical box) = 305 seconds (As high as 600 seconds...) (box is 2% busy) The only difference between these runs is the removal of skip-locking and the running of mysql_upgrade.exe to update some tables for stored procs on 5.5. Yes, I know it's a release candidate, I'm feeding that back to MySQL as well. No slow queries are logged, it doesn't think it's being slow, it just is. I'm going to start tearing into the queries themselves to see if the INSERT/SELECT plans have gone buggo on 5.5. Any help would be appreciated! Thanks

    Read the article

  • Change sysout logging level for Weblogic

    - by Justin Voss
    When I run a local copy of Weblogic, I like to see the output in the console so that I can observe my app's logging messages. But, Weblogic spits out a lot of log messages I don't care about, like these: [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' 08-29-2010 01:02:21 INFO Getting a JNDI connection [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' 08-29-2010 01:02:21 INFO Connection Returned. Elapsed time to acquire=0ms. [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' 08-29-2010 01:02:21 INFO Getting a JNDI connection [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' 08-29-2010 01:02:21 INFO Connection Returned. Elapsed time to acquire=0ms. Can I configure Weblogic to not output those? I assume that I can change the logging level to something higher than INFO and that should fix it?

    Read the article

  • James - mail server configuration help needed

    - by Chaitanya
    Hi, I am trying to setup James mail server on a linux machine. The linux machine has public static ip address assigned. I installed James and added in the config.xml added the servername as mydomain.com. In the DNS for mydomain.com, I have created a A-record, say mx.mydomain.com, which corresponds to the ipaddress of the above mail server machine. Then added mx.mydomain.com as MX record for mydomain.com. In James, I have created a new user test. Then from gmail, I sent a mail to [email protected]. The mail is not received back and it didn't even bounce back. The linux machine is behind a firewall with only 22, 80, 8080 ports open for external network. My question here is, Do I require do open any other ports on the firewall so that the mail I send from gmail arrives to James? If it's not the port problem, any views on solving this issue? I don't want to send mails from this server. It's only for receiving the mails.

    Read the article

  • how to protect telnet access to smtp port 25?

    - by Michael Mao
    Hi all: Please consider the following: 192-168-1-106:~ michael$ telnet <remote_server_ip> 25 Trying <remote_server_ip>... Connected to li*****.linode.com. Escape character is '^]'. 220 mindinscription.net ESMTP Postfix (Ubuntu) quit 221 2.0.0 Bye Connection closed by foreign host. Is this very bad? how to protect port 25 from malicious attackers? I've already set up a firewall, but not very sure what to do in this case. Basically I'd like to use this server to only send emails as alert messages, not receiving any external emails. Many thanks to the help in advance.

    Read the article

  • Customize rsyslogd messages to show the sender of the message; not the receiver

    - by Nimmy Lebby
    I'm forwarding the WiFi router's log messages to our sysadmin box (sb3). This is the stanza in /etc/rsyslog.conf: # WiFi router log :fromhost-ip, isequal,'10.3.291.2' /var/log/wifi-router.log & ~ However, the log looks like this: Dec 23 10:41:58 sb3 dnsmasq-dhcp[253]: DHCPACK(br0) 10.3.292.133 xx:xx:xx:xx:xx:xx dg-ipad I want to customize so that anything logged to wifi-router.log does not mention sb3 but indicates the sender of the log message. How would I do this?

    Read the article

  • Is there a standard Mac OS X Snow Leopard home folder naming convention?

    - by JGFMK
    I recently re-installed a fresh copy of Snow Leopard on my Mac. I was a bit surprised when the process completed it had changed the name of my home folder to use my name rather than my initials. This messed up all the paths in my Eclipse IDE workspace. I vaguely remember being asked if I use it for home or business use and wondered if something I did there has a bearing on the way the default name is assigned. Does anyone have more information on this? Links too official Apple install etc. Cheers.

    Read the article

  • Anyone know how to get dual screens working on a Dell E6410 laptop with Ubuntu 10.04 64 bit?

    - by Curtis
    I've installed the drivers from nVidia. When I go into the NVIDIA X Server Settings application, in the X Server Display Configuration setcion, and click the "Configure" button, "TwinView" is disabled. Also, clicking "Detect Displays" doesn't pick up my monitor (which is connected through a port replicator - keyboard and mouse in that port replicator work fine). Has anyone else seen this? Is this just a limitation of the current nvidia linux drivers?

    Read the article

  • Batch convert HTML file(s) saved using IE to MHT

    - by ultrasawblade
    I have numerous web sites that I've saved over the years. I used Internet Explorer's "Save As..." option to do this. It saves the original page as an .html document, and page requirements in a linked folder with the same name as a document. I want to convert a bunch of these (over 1000) to the single-file .mht format. This can be done through Internet Explorer or Firefox (using UnMHT extension) by loading the original .html document, then re-saving as an .mht document. It is tedious to do that for the number of files I'm talking about, obviously. I'm wondering if anyone knows of a utility, command line or otherwise, that can accomplish this.

    Read the article

  • SQLAuthority News – 18 Seconds of Fame – My PASS Experience

    - by pinaldave
    Happy Holidays to All of YOU! Life is full of little and happy surprises. I think Christmas and Santa are based on it. I just received very interesting email earlier today, I had no idea about it. Earlier this year, I had visited Seattle to attend SQLPASS – read the complete summary over here: SQLAuthority News – SQLPASS Nov 8-11, 2010-Seattle – An Alternative Look at Experience. While I was walking down, someone has stopped me and asked if they can talk to me for 15 seconds, I said yes and they had shot quick movie with mobile. The conversation was very quick and I had forgotten about it. Today I received email from one of the blog reader about it being on YouTube. Honestly, I did not know if this was ever going to be on YouTube. I am surprised and thrilled. Watch my 18 seconds fame movie. Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: About Me, Pinal Dave, SQL, SQL Authority, SQL Optimization, SQL Performance, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority Author Visit, T SQL, Technology

    Read the article

  • Including one Xcode project in another -- linker errors

    - by William Jockusch
    I am trying to do this, and running into problems. The parent project needs to access the class SettingsViewController from the child project. I have put the child project path into my header search paths. Everything compiles OK, but I get linker errors, as follows: Undefined symbols: "_OBJC_METACLASS_$_SettingsViewController", referenced from: _OBJC_METACLASS_$_StatisticsViewController in StatisticsViewController.o "_OBJC_CLASS_$_SettingsViewController", referenced from: objc-class-ref-to-SettingsViewController in SelectionViewController.o _OBJC_CLASS_$_StatisticsViewController in StatisticsViewController.o ld: symbol(s) not found collect2: ld returned 1 exit status How can I fix this?

    Read the article

  • Help converting some classic asp code to c# (.net 3.5)

    - by xoail
    I have this block of code in a .asp file that I am struggling to convert to c#... can anyone help me? Function EncodeCPT(ByVal sPinCode, ByVal iOfferCode, ByVal sShortKey, ByVal sLongKey) Dim vob(2), encodeModulo(256), decodeX, ocode decodeX = " abcdefghijklmnopqrstuvwxyz0123456789!$%()*+,-.@;<=>?[]^_{|}~" if len(iOfferCode) = 5 then ocode = iOfferCode Mod 10000 else ocode = iOfferCode end if vob(1) = ocode Mod 100 vob(0) = Int((ocode-vob(1)) / 100) For i = 1 To 256 encodeModulo(i) = 0 Next For i = 0 To 60 encodeModulo(asc(mid(decodeX, i + 1, 1))) = i Next 'append offer code to key sPinCode = lcase(sPinCode) & iOfferCode If Len(sPinCode) < 20 Then sPinCode = Left(sPinCode & " couponsincproduction", 20) End If 'encode Dim i, q, j, k, sCPT, s1, s2, s3 i = 0 q = 0 j = Len(sPinCode) k = Len(sShortKey) sCPT = "" For i = 1 To j s1 = encodeModulo(asc( mid(sPinCode, i, 1)) ) s2 = 2 * encodeModulo( asc( mid(sShortKey, 1 + ((i - 1) Mod k), 1) ) ) s3 = vob(i Mod 2) q = (q + s1 + s2 + s3) Mod 61 sCPT = sCPT & mid(sLongKey, q + 1, 1) Next EncodeCPT = sCPT End Function

    Read the article

  • How do I position an element so that it acts like both 'absolutely' & 'relatively' positioned at the same time? - CSS

    - by marcamillion
    You can see the implementation here: http://jsfiddle.net/BMWZd/25/ When you click on one of the names in Box#1, you will see the circle in the top left corner of the box move up and down. How do I stop that? While also, making sure that it shows in the top left corner of each of the boxes on all browser sizes? So position:absolute will keep it in one place regardless of what happens around it. But it won't put it in the exact same position (relatively) on diff browser sizes. But position:relative will. How do I get the best of both worlds?

    Read the article

  • Using NSNumberFormatter to get a decimal value from an international currency string

    - by Duncan A
    It seems that the NSNumberFormatter can't parse Euro (and probably other) currency strings into a numerical type. Can someone please prove me wrong. I'm attempting to use the following to get a numeric amount from a currency string: NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; NSNumber *currencyNumber = [currencyFormatter numberFromString:currencyString]; This works fine for UK and US currency amounts. It even deals with $ and £ and thousands separators with no problems. However, when I use it with euro currency amounts (with the Region Format set to France or Germany in the settings app) it returns an empty string. All of the following strings fail: 12,34 € 12,34 12.345,67 € 12.345,67 It's worth noting that these strings match exactly what comes out of the NSNumberFormatter's stringFromNumber method when using the corresponding locale. Setting the Region Format to France in the settings app, then setting currencyNumber to 12.34 in the following code, results in currencyString being set to '12,34 €' : NSNumberFormatter *currencyFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; NSString *currencyString = [currencyFormatter stringFromNumber:currencyNumber]; It would obviously be fairly easy to hack around this problem specifically for the Euro but I'm hoping to sell this app in as many countries as possible and I'm thinking that a similar situation is bound to occur with other locales. Does anyone have an answer? TIA, Duncan

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >