Daily Archives

Articles indexed Tuesday July 3 2012

Page 12/17 | < Previous Page | 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • How to customize the initrd embedded in or coming with the kernel image

    - by STATUS_ACCESS_DENIED
    I would like to add some tools and not just kernel modules into the initrd (initramfs-based). Now I'm aware of how to unpack and how to pack the initrd with cpio and have even written a hook for /etc/initramfs-tools/hooks in the past to integrate a third-party kernel module. However, while the available script libraries seem to be geared towards the integration of modules, none of them seems to be for integration of other entities (in particular programs and their dependencies). What options do I have to automate the integration of some useful tools for recovery into the initrd? I'm talking about the "rescue" system that the system drops into if it is unable to mount the root drive given to it by the boot loader. Please note that I don't want the SquashFS approach as is used for Live-CDs because for the issue at hand it will be by far sufficient to include some relatively small tools that aid in recovery of the system (when it gets stuck in initrd and can't boot further). Also, the machines when they run into the issue that we have had in the past tend to boot into the rescue system, but there a few tools are missing to kick the system back on trail ...

    Read the article

  • Can not resolve hostnames on Xubuntu computers

    - by P Curtis
    I have a network of computers which has been running for many years. I have changed two of those to Xubuntu 11.10 and found I can no longer connect by ssh using the host-name from any other machine. I can connect and ping by IP although ping is very slow in one case (~200ms). All other machines are fine including another with Ubuntu 11.10. Host-name resolution works from Xubuntu machines to other networked machines. I am using wins resolution and have checked settings in /etc/nsswitch.conf are the same as my working Ubuntu systems. What is different in Xubuntu networking that I might have missed?

    Read the article

  • How to create repeatable table with unique ID's using jQuery

    - by milbert
    I need to create a table structure that can be "copied" and populated with a new set of data. However, each table must have unique IDs for functions that must access them later. For example: <table class="main"> <thead><tr><th class="header"></th></tr></thead> <tbody> <tr class="row"><td class="col0"></td><td class="col1"></td></tr> </tbody> </table> My current thought is to use jQuery to load the table from a seperate html file into a variable. Using this saved table I could then create a function that copies it, traverses the table to add an ID to each section where information will need to be appended from a seperate data source, and return this new table. I am new to jQuery and feel like I may be missing an easier/better way to accomplish this. Any help on this subject would be appreciated.

    Read the article

  • How to automatically generate html table from image in Linux?

    - by alfish
    In Photoshop, you can easily devide the image into zones using point and click and it automatically generates the corresponding html with image slices addressed in tables. Gimp also has a Slice (Filter Web Slice) but it is so rudimentary and, as far as I can see, does not allow point and click selection of slices. I am wondering if the functionality can be added into Gimp, or there are other Linux software to do this. I hate to return to Windows jut to do this simple task which I happen to use frequently. Thanks in advance for your suggestions.

    Read the article

  • Usual Suspects: Typical 3rd Party Entities in E-Commerce [closed]

    - by zharvey
    I am doing some requirements/analysis for a web app that I'd like to build (Ruby/Java developer here). This web app would have a store front, shopping cart and would need to be totally compliant with all e-com best practices. It's amazing how much non-technical info comes up when you search for phrases like "how does e-commerce work", but very little comes up in the way of technical details. As such, I'm having extreme frustration finding answers to what I consider pretty straight-forward questions. I came here because I believe this question is not off-topic; if it is, please leave a comment as to why this question does not belong here and I will happily remove it myself (upvotes if your comment can point me to the correct place for this question!). So then: What 3rd parties will I need to work with to have a modern, web-compliant e-com site? So far I can account for a payment gateway provider like Authorize.net and an SSL certificate provider like Trustwave. Any others? What other standards besides PCI compliance will I be held to (besides governing laws, of course!)? Vulnerability scans: PCI compliance requires quarterly scans: if I'm a "Level 4" (low volume) Merchant does that still apply to me? Irregardless, my backend architecture is quite huge, with web servers, app servers, database, message brokers and more. Do each of these servers need to be scanned?!? If not what servers do need to get these quarterly scans? I usually hate to ask micro-questions inside of one large one, but these are so closely-related I just felt like asking them all separately would be spamming the site with too many petty questions. Thanks in advance!

    Read the article

  • Feasible to send marketing emails as an image?

    - by Anonymous -
    Is it feasible to send marketing emails entirely as images - apart from a link at the top, giving the option for the recipient to view the email online (in their browser) and one at the footer to unsubscribe from our mailing list? Anyone who's coded a html email template before knows how much of a pain it is to end up with the final design that displays 'properly' (rarely does it display the same in all clients) and doesn't break. I understand there's the possibility of people simply ignoring the email altogether should their email clients be set not to automatically download images, but many of our email primarily feature images anyway. Thoughts?

    Read the article

  • Updating sprite location with controls

    - by iQue
    So ive got a character in a 2D game using surfaceView that I want to be able to move using a button(eventually a joystick), but my game crashes as soon as I try to move my sprite. This is my onTouch-method for my steering button: public void handleActionDown(int eventX, int eventY) { if (eventX >= (x - bitmap.getWidth() / 2) && (eventX <= (x + bitmap.getWidth()/2))) { if (eventY >= (y - bitmap.getHeight() / 2) && (y <= (y + bitmap.getHeight() / 2))) { setTouched(true); } else { setTouched(false); } } else { setTouched(false); } and if I try to put this in my update-method: public void update() { x += (speed.getXv() * speed.getxDirection()); y += (speed.getYv() * speed.getyDirection()); } the sprite moves on its own just fine, but as soon as I add: public void update() { if(steering.isTouched()){ x += (speed.getXv() * speed.getxDirection()); y += (speed.getYv() * speed.getyDirection()); } the game crashes. Does any1 know why this is or how to fix it? I cannot figure it out. Im using MotionEvent.ACTION_DOWN to check if the user if pressing the screen. }

    Read the article

  • Multiplayer tile based movement synchronization

    - by Mars
    I have to synchronize the movement of multiple players over the Internet, and I'm trying to figure out the safest way to do that. The game is tile based, you can only move in 4 directions, and every move moves the sprite 32px (over time of course). Now, if I would simply send this move action to the server, which would broadcast it to all players, while the walk key is kept being pressed down, to keep walking, I have to take this next command, send it to the server, and to all clients, in time, or the movement won't be smooth anymore. I saw this in other games, and it can get ugly pretty quick, even without lag. So I'm wondering if this is even a viable option. This seems like a very good method for single player though, since it's easy, straight forward (, just take the next movement action in time and add it to a list), and you can easily add mouse movement (clicking on some tile), to add a path to a queue, that's walked along. The other thing that came to my mind was sending the information that someone started moving in some direction, and again once he stopped or changed the direction, together with the position, so that the sprite will appear at the correct position, or rather so that the position can be fixed if it's wrong. This should (hopefully) only make problems if someone really is lagging, in which case it's to be expected. For this to work out I'd need some kind of queue though, where incoming direction changes and stuff are saved, so the sprite knows where to go, after the current movement to the next tile is finished. This could actually work, but kinda sounds overcomplicated. Although it might be the only way to do this, without risk of stuttering. If a stop or direction change is received on the client side it's saved in a queue and the char keeps moving to the specified coordinates, before stopping or changing direction. If the new command comes in too late there'll be stuttering as well of course... I'm having a hard time deciding for a method, and I couldn't really find any examples for this yet. My main problem is keeping the tile movement smooth, which is why other topics regarding synchronization of pixel based movement aren't helping too much. What is the "standard" way to do this?

    Read the article

  • How to get warnings when compiling fx files

    - by jdv-Jan de Vaan
    When I compile DirectX shaders (.fx files), I dont see any compiler warnings unless there was an error in the effect. This happens both when using the offline FXC compiler, as well as calling SlimDx's CompileEffect (which is what we normally do). I could force warnings as errors (/WX), but if you enable that, you get an error that compilation failed, without the warning that caused the problem. So how can I output warnings for shaders that compile properly?

    Read the article

  • Self learning automated movement

    - by Super1
    I am trying to make a small demo in Javascript, I have a black border and a car the car travels randomly and a line is drawn of its trail. When the user click inside the area it creates an object (we'll call this the wall). If the car hits the wall then it goes back 3 paces and tries a different route. When its hit the wall it needs to log down its location so it does NOT make that mistake again. Here is my example: http://jsfiddle.net/Jtq3E/ How can I get the car to move by itself and create a trail?

    Read the article

  • Why aren't tangent space normal maps completely blue?

    - by seahorse
    Why aren't normal maps just blue? I would think that normal maps should be predominantly blue in color because the Z component of the normal is represented by blue. Normals point out of the surface in the Z direction so we should see blue as the predominant colour since the Z component is dominant. By definition tangent space is perpendicular to the surface. At any point we should have the normal always pointing in the Z (blue direction) with no X (red direction) or Y (green direction). Thus the normal map (since it is a "normal map") should have the colour of the normals which is just blue (R = x = 0, G = y = 0, B = z = 1) with no shades in between. But normal maps are not so, and they have gradients of shades in them. Why is this so?

    Read the article

  • Reuseable Platform For Custom Board Game

    - by George Bailey
    Is there a generic platform to allow me to customize the rules to a board game. The board game uses a square grid, similar to Checkers or Chess. I was hoping to take some of the work out of creating this computer opponent, by reusing what is already written. I would think that there would be a pre-written routine for deciding which moves would lead to the best outcome, and all that I would need to program is the pieces, legal moves, what layout constitutes a win/lose or draw, and perhaps some kind of scoring for value of pieces. I have seen chess programs that appear to use a recursive routine, so they think anywhere from 2 to 20 moves ahead to create varying degrees of difficulty. I have noticed this on chess.com. The game I am programming will not be as complex. Is there a platform designed to be re-used for different grid/piece based games. JavaScript would be preferable, but Java or Perl would be acceptable.

    Read the article

  • Implmenting RLE into a tilemap or how to create a large 3D array?

    - by Smallbro
    Currently I've been using a 3D array for my tiles in a 2D world but the 3D side comes in when moving down into caves and whatnot. Now this is not memory efficient and I switched over to a 2D array and can now have much larger maps. The only issue I'm having now is that it seems that my tiles cannot occupy the same space as a tile on the same z level. My current structure means that each block has its own z variable. This is what it used to look like: map.blockData[x][y][z] = new Block(); however now it works like this map.blockData[x][y] = new Block(z); I'm not sure why but if I decide to use the same space on say the floor below it wont allow me to. Does anyone have any ideas on how I can add a z-axis to my 2D array? I'm using java but I reckon the concept carries across different languages. Edit: As Will posted, RLE sounds like the best method for achieving a fast 3D array. However I'm struggling to understand how I would even start to implement it? Would I create a 4D array the 4th being something which controls how many to skip? Or would the x-axis simply change altogether and have large gaps in between - for example [5][y][z] would skip 5 tiles? Is there something really obvious here which I am missing? The number of z levels I'm trying to have is around 66, it would be preferably that I can have up to or more than 1000 in x and y.

    Read the article

  • Java program grading

    - by pasito15
    I've been working on this program for hours and I can't figure out how to get the program to actually print the grades from the scores Text file public class Assign7{ private double finalScore; private double private_quiz1; private double private_quiz2; private double private_midTerm; private double private_final; private final char grade; public Assign7(double finalScore){ private_quiz1 = 1.25; private_quiz2 = 1.25; private_midTerm = 0.25; private_final = 0.50; if (finalScore >= 90) { grade = 'A'; } else if (finalScore >= 80) { grade = 'B'; } else if (finalScore >= 70) { grade = 'C'; } else if (finalScore>= 60) { grade = 'D'; } else { grade = 'F'; } } public String toString(){ return finalScore+":"+private_quiz1+":"+private_quiz2+":"+private_midTerm+":"+private_final; } } this code compiles as well as this one import java.util.*; import java.io.*; public class Assign7Test{ public static void main(String[] args)throws Exception{ int q1,q2; int m = 0; int f = 0; int Record ; String name; Scanner myIn = new Scanner( new File("scores.txt") ); System.out.println( myIn.nextLine() +" avg "+"letter"); while( myIn.hasNext() ){ name = myIn.next(); q1 = myIn.nextInt(); q2 = myIn.nextInt(); m = myIn.nextInt(); f = myIn.nextInt(); Record myR = new Record( name, q1,q2,m,f); System.out.println(myR); } } public static class Record { public Record() { } public Record(String name, int q1, int q2, int m, int f) { } } } once a compile the code i get this which dosent exactly compute the numbers I have in the scores.txt Name quiz1 quiz2 midterm final avg letter Assign7Test$Record@4bcc946b Assign7Test$Record@642423 Exception in thread "main" java.until.InputMismatchException at java.until.Scanner.throwFor(Unknown Source) at java.until.Scanner.next(Unknown Source) at java.until.Scanner.nextInt(Unknown Source) at java.until.Scanner.nextInt(Unknown Source) at Assign7Test.main(Assign7Test.java:25)

    Read the article

  • jqgrid Posting name:value pair when deleting row?

    - by user837168
    I want to send some name:value pair from the row selected along with del command. from below script I want to send the "polpono" value to my php script when del command is issued. any help will be highly appreciated. $(document).ready(function(){ $("#datagrid").jqGrid({ url:'actionpo.php?vid=polpogridjq', datatype: 'xml', mtype: 'GET', colNames:['List#','PO#', 'Item Code','Item Detail','Qty','Price','Tax'], colModel :[ {name:'polistno', width:100,editable:true,editable:true,key:true}, {name:'polpono',index:'polpono', width:100,editable:true}, {name:'politemcode',index:'politemcode', width:100, align:'right',sortable:true,editable:true}, {name:'politemname', width:300, align:'left',sortable:false,editable:true}, {name:'politemqty',width:50, align:'right',sortable:false,editable:true}, {name:'politemvalue', width:80,align:'left',sortable:false,editable:true}, {name:'politemtax', width:50, align:'right',editable:true} ], pager: $('#pager'), rowNum:10, rowList:[10,20,30], sortname: 'polpono', sortorder: 'desc', shrinkToFit: false, rownumbers: false, multiselect: false, viewRecords: false, clearAfterAdd:true, caption: 'Itemised Quantity', editurl: "actionpo.php?vid=gridformcall", }).navGrid('#pager', { edit: true, add: true, del: true ,search:false, refresh:true},{ } }); });

    Read the article

  • Hide/Show problems on a questionerre application

    - by T. Todd
    I am doing an assignment involving the creation of a simple Quiz type form application. However, whenever I run the program, only the first answer shows for a multiple question and I cannot for the life of me figure out why. This is the contstructor: MultipleChoice dlg = new MultipleChoice( new Question("What is the capital of Zimbabwe?", new Answer("Paris", false), new Answer("Washington D.C.", false), new Answer("Harare", true), new Answer("Cairo", false), new Answer("N'Djamena", false))); if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Correct) MessageBox.Show("You got something right!"); else MessageBox.Show("You couldn't be more wrong"); } And this is the Question Form Code: private Question Q; public MultipleChoice (Question q) { Q = q; InitializeComponent(); textPrompt.Text = Q.Prompt; if (Q.A != null) { radioA.Text = Q.A.Prompt; } else radioA.Hide(); if (Q.B != null) { radioB.Text = Q.B.Prompt; } radioB.Hide(); if (Q.C != null) { radioC.Text = Q.C.Prompt; } radioC.Hide(); if (Q.D != null) { radioD.Text = Q.D.Prompt; } radioD.Hide(); if (Q.E != null) { radioE.Text = Q.E.Prompt; } radioE.Hide(); } public bool Correct { get { if (Q == null) return false; if (Q.A != null && Q.A.Correct && radioA.Checked) return true; if (Q.B != null && Q.B.Correct && radioB.Checked) return true; if (Q.C != null && Q.C.Correct && radioC.Checked) return true; if (Q.D != null && Q.D.Correct && radioD.Checked) return true; if (Q.E != null && Q.E.Correct && radioE.Checked) return true; return false; } Where have I gone wrong? Thank you, Travis

    Read the article

  • Bad interpreter: No such file or directory

    - by user1497462
    I'm working through Michael Hartl's tutorial trying to learn Rails for the first time, and I've run into some issues. I recently reinstalled the whole Rails Installer because I had apparently inadvertently deleted some important files. Now, when I try running a test I get the following error: sh.exe": /c/Program Files (x86)/ruby-1.9.3/bin/bundle: "c:/Program: bad interpre ter: No such file or directory I checked my PATH and attempted to use the solution outlined here: Bundle command not found. Bad Interpreter ..but putting quotation marks around "C:\Program Files (x86)\ruby-1.9.3\bin" didn't do anything for me. I ran $ rails -v and got the following output: $ rails -v ?[31mCould not find multi_json-1.3.6 in any of the sources?[0m ?[33mRun `bundle install` to install missing gems.?[0m So then I tried running $bundle install and got the following issue again: Tom@TOM-PC /c/sample_app (updating-users) $ bundle install sh.exe": /c/Program Files (x86)/ruby-1.9.3/bin/bundle: "c:/Program: bad interpre ter: No such file or directory I'd really appreciate any help -- I've spent 5+ hours today trying to get back on track and am still at a loss. Thanks!

    Read the article

  • My form submit button is not showing correctly

    - by JackR
    I have created an form that submits the contents to email. I have used the exact same coding in many other websites, but for my new website http://www.peterevansfuneraldirectors.co.uk/contact-us.html the submit button is just a grey square with text, rather than the usual button. Also the hand doesn't come up on hover. My form code is... <form action="php/FormToEmail.php" method="post" name="ContactForm" id="ContactForm" onsubmit="MM_validateForm('name','','R','email','','RisEmail','message subject','','R','message','','R');return document.MM_returnValue" > <div class="form-text"> <b>Name<span class="purple">*</span></b><br /> <input name="name" type="text" id="name" size="35" style="height:23px; background-color:#FFF; color:#000; border: 1px solid #CCC;" /> </div><br /> <div class="form-text"> <b>Email<span class="purple">*</span></b><br /> <input name="email" type="text" id="email" size="35" style="height:23px; background-color:#FFF; color:#000; border: 1px solid #CCC;" /> </div><br /> <div class="form-text"> <b>Message Subject<span class="purple">*</span></b><br /> <input name="message subject" type="text" id="message subject" size="35" style="height:23px; background-color:#FFF; color:#000; border: 1px solid #CCC;" /> </div><br /> <div class="form-text"> <b>Message<span class="purple">*</span></b><br /> <textarea name="message" type="text" id="message" rows="8" cols="55" style="background-color:#FFF; color:#000; border: 1px solid #CCC;" ></textarea> </div><br /> <div class="submit-button"> <input type="submit" name="submit" value="Submit" /> </div> </form> Thanks in advance! Jack.

    Read the article

  • Changing PHP variable from an <a href=""> link

    - by aener
    I'm making a site using divs. I have one across the top with a row of links which I want to change what's in the main window. I would prefer to keep strictly to PHP and HTML and use a full page refresh as I am comfortable with them at current, rather than using an Ajax refresh as I don't have any knowledge of Ajax. I don't want to use iframes. I thought the best way to do this would be as follows: <div id="top"> <a href="news.html">News</a> </div> <div id="main"> <?php include($page); ?> </div> What I need is a way of changing the $page variable upon clicking the link. If this means changing the variable and then reloading the page then so be it. A command following the logic of: <a href="news.html" action="<?php $page="news.html"; ?>">News</a> would be ideal! I thought about using a form, but it seems there should be an easier way.

    Read the article

  • C As Principal Class For Mac App

    - by CodaFi
    So, I've got a c file raring to go and be the main class behind an all-C mac-app, however, a combination of limiting factors are preventing the application from being launched. As it currently stands, the project is just a main.m and a class called AppDelegate.c, so I entered "AppDelegate" as the name of the principal class in the info.plist, and to my complete surprise, the log printed: Unable to find class: AppDelegate, exiting This would work perfectly well in iOS, because the main function accepts the name of a delegate class, and handles it automatically, but NSApplicationMain() takes no such argument. Now, I know this stems from the fact that there are no @interface/@implementation directives in C, and that's really what the OS seems to be looking for, so I wrote a simple NSApplication subclass and provided it as the Principal Class to the plist, and it launched perfectly well. My question is, how could one go about setting a c file as the principal class in a mac application and have it launch correctly? PS, don't ask what or why I'm doing this for, the foundation must be dug. For @millimoose's amusement, here be the AppDelegate.c file: #include <objc/runtime.h> #include <objc/message.h> struct AppDel { Class isa; id window; }; // This is a strong reference to the class of the AppDelegate // (same as [AppDelegate class]) Class AppDelClass; BOOL AppDel_didFinishLaunching(struct AppDel *self, SEL _cmd, void *application, void *options) { self->window = objc_msgSend(objc_getClass("NSWindow"), sel_getUid("alloc")); self->window = objc_msgSend(self->window, sel_getUid("init")); objc_msgSend(self->window, sel_getUid("makeKeyAndOrderFront:"), self); return YES; }

    Read the article

  • Getting instance of a class in ArrayList

    - by user1499974
    I have a small problem with ArrayList. You see, I wish to get an instance of RenderNewHUD in my renderer class, which has a list of registered renderers. I did not want to create a variable for this due to limitations and awkwardness. Here is my code. RenderNewHUD hud = renderer.renderList.get(RenderNewHUD()); How exactly can I go along getting the instance of RenderNewHUD without creating a new instance? If you need any more of my code, just ask. Sorry if this is a very dumb question - I have looked EVERYWHERE for an answer.

    Read the article

  • What is a fast way to set debugging code at a given line in a function?

    - by Josh O'Brien
    Preamble: R's trace() is a powerful debugging tool, allowing users to "insert debugging code at chosen places in any function". Unfortunately, using it from the command-line can be fairly laborious. As an artificial example, let's say I want to insert debugging code that will report the between-tick interval calculated by pretty.default(). I'd like to insert the code immediately after the value of delta is calculated, about four lines up from the bottom of the function definition. (Type pretty.default to see where I mean.) To indicate that line, I need to find which step in the code it corresponds to. The answer turns out to be step list(c(12, 3, 3)), which I zero in on by running through the following steps: as.list(body(pretty.default)) as.list(as.list(body(pretty.default))[[12]]) as.list(as.list(as.list(body(pretty.default))[[12]])[[3]]) as.list(as.list(as.list(body(pretty.default))[[12]])[[3]])[[3]] I can then insert debugging code like this: trace(what = 'pretty.default', tracer = quote(cat("\nThe value of delta is: ", delta, "\n\n")), at = list(c(12,3,3))) ## Try it a <- pretty(c(1, 7843)) b <- pretty(c(2, 23)) ## Clean up untrace('pretty.default') Questions: So here are my questions: Is there a way to print out a function (or a parsed version of it) with the lines nicely labeled by the steps to which they belong? Alternatively, is there another easier way, from the command line, to quickly set debugging code for a specific line within a function? Addendum: I used the pretty.default() example because it is reasonably tame, but with real/interesting functions, repeatedly using as.list() quickly gets tiresome and distracting. Here's an example: as.list(as.list(as.list(as.list(as.list(as.list(as.list(as.list(as.list(body(# model.frame.default))[[26]])[[3]])[[2]])[[4]])[[3]])[[4]])[[4]])[[4]])[[3]]

    Read the article

  • Grab two parts of a single, short string

    - by TankorSmash
    I'm looking to fill a python dict with TAG:definition pairs, and I'm using RegExr http://gskinner.com/RegExr/ to write the regex My first step is to parse a line, from http://www.id3.org/id3v2.3.0, or http://pastebin.com/VJEBGauL and pull out the ID3 tag and the associated definition. For example the first line: 4.20 AENC [#sec4.20 Audio encryption] would look like this myDict = {'AENC' : 'Audio encryption'} To grab the tag name, I've got it looking for at least 3 spaces, then 4 characters, then 4 spaces: {3}[a-zA-Z0-9]{4} {4} That part is easy enough. The second part, the definition, is not working out for me. So far, I've got (?<=(\[#.+?)) A Which should find, but not include the [# as well as an indeterminded set of characters until it finds: _A, but it's failing. If I remove .+? and replace _A with s it works out alright. What is going wrong? *The underscores represent spaces, which don't show up on SO. How do I grab the definition, ie,(Audio encryption) of the ID3v2 tag from the line, using RegEx?

    Read the article

  • Objective C - creating concrete class instances from base class depending upon type

    - by indiantroy
    Just to give a real world example, say the base class is Vehicle and concrete classes are TwoWheeler and FourWheeler. Now the type of the vehicle - TwoWheeler or FourWheeler, is decided by the base class Vehicle. When I create an instance of TwoWheeler/FourWheeler using alloc-init method, it calls the super implementation like below to set the value of common properties defined in the Vehicle class and out of these properties one of them is type that actually decides if the type is TwoWheeler or FourWheeler. if (self = [super initWithDictionary:dict]){ [self setOtherAttributes:dict]; return self; } Now when I get a collection of vehicles some of them could be TwoWheeler and others will be FourWheeler. Hence I cannot directly create an instance of TwoWheeler or FourWheeler like this Vehicle *v = [[TwoWheeler alloc] initWithDictionary:dict]; Is there any way I can create an instance of base class and once I know the type, create an instance of child class depending upon type and return it. With the current implementation, it would result in infinite loop because I call super implementation from concrete class. What would be the perfect design to handle this scenario when I don't know which concrete class should be instantiated beforehand?

    Read the article

  • PHP regex for password validation

    - by Fabio Anselmo
    I not getting the desired effect from a script. I want the password to contain A-Z, a-z, 0-9, and special chars. A-Z a-z 0-9 2 special chars 2 string length = 8 So I want to force the user to use at least 2 digits and at least 2 special chars. Ok my script works but forces me to use the digits or chars back to back. I don't want that. e.g. password testABC55$$ is valid - but i don't want that. Instead I want test$ABC5#8 to be valid. So basically the digits/special char can be the same or diff - but must be split up in the string. PHP CODE: $uppercase = preg_match('#[A-Z]#', $password); $lowercase = preg_match('#[a-z]#', $password); $number = preg_match('#[0-9]#', $password); $special = preg_match('#[\W]{2,}#', $password); $length = strlen($password) >= 8; if(!$uppercase || !$lowercase || !$number || !$special || !$length) { $errorpw = 'Bad Password';

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17  | Next Page >