Search Results

Search found 2400 results on 96 pages for 'ceiling cat'.

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

  • Automatically unsubscribe an event

    - by Cat
    Is it possible to do something like this in C#? Probably with Expressions. private void RegisterEvent(EventHandler handler, Action<EventArgs> action) { handler += action; m_toUnsubscribe.Add(handler, action); } ... in Dispose() { foreach(var pair in m_toUnsubscribe) { pair.handler -= pair.action; } }

    Read the article

  • gluNewQuadric() before opengl's initialization

    - by Schrödinger's cat
    Hello, I'm working on a c++ code that uses SDL/opengl. Is this possible to create a pointer to a quadric with 'gluNewQuadric()' before having initialized opengl with 'SDL_SetVideoMode'? The idea is to create a class with a (pointer to a) quadric class member that has to be instantiate before the 'SDL_SetVideoMode' call. This pointer is initialized in the class' constructor with a 'gluNewQuadric()' call.

    Read the article

  • User input being limited to the alphabet in python

    - by Danger Cat
    I am SUPER new to programming and have my first assignment coming up in python. I am writing a hangman type game, where users are required to guess the word inputted from the other user. I have written most of the code, but the only problem I am having is when users have to input the word, making sure it is only limited to the alphabet. The code I have so far is : word = str.lower(raw_input("Type in your secret word! Shhhh... ")) answer = True while answer == True: for i in range(len(word)): if word[i] not in ("abcdefghijklmnopqrstuvwxyz"): word = raw_input("Sorry, words only contain letters. Please enter a word ") break else: answer = False This works while I input a few tries, but eventually will either exit the loop or displays an error. Is there any easier way to use this? We've really only covered topics up to loops in class, and break and continue are also very new to me. Thank you! (Pardon if the code is sloppy, but as I said I am very new to this....)

    Read the article

  • Do not want Form to display over other application windows

    - by Cat
    I am displaying a Form from one process by passing the Show method a window handle from another process. I only want this new Form to display above the passed Form, like a MessageBox. However, this newly launched Form appears above other application windows, despite: Setting Process.WindowStyle.Hidden to the Form-displaying process Overriding the ShowWithoutActivation and CreateParams properties of the Form. Making sure Form.TopMost is not true I have checked that the window handle is valid from the second process. Focus is not stolen, however. Process A: Pass (Form) window handle to a new Process B via the command line Process B: Display a new Form using Form.Show(anotherProcessWindowHandle)

    Read the article

  • Collision Detection problems in Voxel Engine (XNA)

    - by Darestium
    I am creating a minecraft like terrain engine in XNA and have had some collision problems for quite some time. I have checked and changed my code based on other peoples collision code and I still have the same problem. It always seems to be off by about a block. for instance, if I walk across a bridge which is one block high I fall through it. Also, if you walk towards a "row" of blocks like this: You are able to stand "inside" the left most one, and you collide with nothing in the right most side (where there is no block and is not visible on this image). Here is all my collision code: private void Move(GameTime gameTime, Vector3 direction) { float speed = playermovespeed * (float)gameTime.ElapsedGameTime.TotalSeconds; Matrix rotationMatrix = Matrix.CreateRotationY(player.Camera.LeftRightRotation); Vector3 rotatedVector = Vector3.Transform(direction, rotationMatrix); rotatedVector.Normalize(); Vector3 testVector = rotatedVector; testVector.Normalize(); Vector3 movePosition = player.position + testVector * speed; Vector3 midBodyPoint = movePosition + new Vector3(0, -0.7f, 0); Vector3 headPosition = movePosition + new Vector3(0, 0.1f, 0); if (!world.GetBlock(movePosition).IsSolid && !world.GetBlock(midBodyPoint).IsSolid && !world.GetBlock(headPosition).IsSolid) { player.position += rotatedVector * speed; } //player.position += rotatedVector * speed; } ... public void UpdatePosition(GameTime gameTime) { player.velocity.Y += playergravity * (float)gameTime.ElapsedGameTime.TotalSeconds; Vector3 footPosition = player.Position + new Vector3(0f, -1.5f, 0f); Vector3 headPosition = player.Position + new Vector3(0f, 0.1f, 0f); // If the block below the player is solid the Y velocity should be zero if (world.GetBlock(footPosition).IsSolid || world.GetBlock(headPosition).IsSolid) { player.velocity.Y = 0; } UpdateJump(gameTime); UpdateCounter(gameTime); ProcessInput(gameTime); player.Position = player.Position + player.velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; velocity = Vector3.Zero; } and the one and only function in the camera class: protected void CalculateView() { Matrix rotationMatrix = Matrix.CreateRotationX(upDownRotation) * Matrix.CreateRotationY(leftRightRotation); lookVector = Vector3.Transform(Vector3.Forward, rotationMatrix); cameraFinalTarget = Position + lookVector; Vector3 cameraRotatedUpVector = Vector3.Transform(Vector3.Up, rotationMatrix); viewMatrix = Matrix.CreateLookAt(Position, cameraFinalTarget, cameraRotatedUpVector); } which is called when the rotation variables are changed: public float LeftRightRotation { get { return leftRightRotation; } set { leftRightRotation = value; CalculateView(); } } public float UpDownRotation { get { return upDownRotation; } set { upDownRotation = value; CalculateView(); } } World class: public Block GetBlock(int x, int y, int z) { if (InBounds(x, y, z)) { Vector3i regionalPosition = GetRegionalPosition(x, y, z); Vector3i region = GetRegionPosition(x, y, z); return regions[region.X, region.Y, region.Z].Blocks[regionalPosition.X, regionalPosition.Y, regionalPosition.Z]; } return new Block(BlockType.none); } public Vector3i GetRegionPosition(int x, int y, int z) { int regionx = x == 0 ? 0 : x / Variables.REGION_SIZE_X; int regiony = y == 0 ? 0 : y / Variables.REGION_SIZE_Y; int regionz = z == 0 ? 0 : z / Variables.REGION_SIZE_Z; return new Vector3i(regionx, regiony, regionz); } public Vector3i GetRegionalPosition(int x, int y, int z) { int regionx = x == 0 ? 0 : x / Variables.REGION_SIZE_X; int X = x % Variables.REGION_SIZE_X; int regiony = y == 0 ? 0 : y / Variables.REGION_SIZE_Y; int Y = y % Variables.REGION_SIZE_Y; int regionz = z == 0 ? 0 : z / Variables.REGION_SIZE_Z; int Z = z % Variables.REGION_SIZE_Z; return new Vector3i(X, Y, Z); } Any ideas how to fix this problem? EDIT 1: Graphic of the problem: EDIT 2 GetBlock, Vector3 version: public Block GetBlock(Vector3 position) { int x = (int)Math.Floor(position.X); int y = (int)Math.Floor(position.Y); int z = (int)Math.Ceiling(position.Z); Block block = GetBlock(x, y, z); return block; } Now, the thing is I tested the theroy that the Z is always "off by one" and by ceiling the value it actually works as intended. Altough it still could be greatly more accurate (when you go down holes you can see through the sides, and I doubt it will work with negitive positions). I also does not feel clean Flooring the X and Y values and just Ceiling the Z. I am surely not doing something correctly still.

    Read the article

  • How can I check detailed memory information on linux?

    - by user35153
    I know that I can check cpu info via cat /proc/cpuinfo and memory info via cat /proc/meminfo. but cat /proc/meminfo yiels result like : MemTotal: 66098352 kB MemFree: 329152 kB Buffers: 632432 kB Cached: 62619692 kB SwapCached: 0 kB Active: 6425444 kB Inactive: 58717276 kB SwapTotal: 1951888 kB SwapFree: 1951796 kB Dirty: 38416 kB Writeback: 0 kB AnonPages: 1890268 kB Mapped: 12624 kB Slab: 464580 kB SReclaimable: 275812 kB SUnreclaim: 188768 kB PageTables: 7524 kB NFS_Unstable: 0 kB Bounce: 0 kB CommitLimit: 35001064 kB Committed_AS: 3860248 kB VmallocTotal: 34359738367 kB VmallocUsed: 125636 kB VmallocChunk: 34359612527 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB But I want to learn info on the clock speed of the memories (in Mhz?) HOW can I get That Info ? Thnks

    Read the article

  • Checking detailed memory information on Linux

    - by user35153
    I know that I can check CPU info via cat /proc/cpuinfo and memory info via cat /proc/meminfo. But cat /proc/meminfo yields results like the following: MemTotal: 66098352 kB MemFree: 329152 kB Buffers: 632432 kB Cached: 62619692 kB SwapCached: 0 kB Active: 6425444 kB Inactive: 58717276 kB SwapTotal: 1951888 kB SwapFree: 1951796 kB Dirty: 38416 kB Writeback: 0 kB AnonPages: 1890268 kB Mapped: 12624 kB Slab: 464580 kB SReclaimable: 275812 kB SUnreclaim: 188768 kB PageTables: 7524 kB NFS_Unstable: 0 kB Bounce: 0 kB CommitLimit: 35001064 kB Committed_AS: 3860248 kB VmallocTotal: 34359738367 kB VmallocUsed: 125636 kB VmallocChunk: 34359612527 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB I want to learn more about the clock speed of the memory (in Mhz?). How do I get that information?

    Read the article

  • Need script to redirect STDIN & STDOUT to named pipes

    - by user54903
    I have an app that launches an authentication helper (my script) and uses STDIN/STDOUT to communicate. I want to re-direct STDIN and STDOUT from this script to two named pipes for interaction with another program. E.g.: SCRIPT_STDIN pipe1 SCRIPT_STDOUT < pipe2 Here is the flow I'm trying to accomplish: [Application] - Launches helper script, writes to helpers STDIN, reads from helpers STDOUT (example: STDIN:username,password; STDOUT:LOGIN_OK) [Helper Script] - Reads STDIN (data from app), forwards to PIPE1; reads from PIPE2, writes that back to the app on STDOUT [Other Process] - Reads from PIPE1 input, processes and returns results to PIPE2 The cat command can almost do what I want. If there were an option to copy STDIN to STDERR I could make cat do this with a command (assuming the fictitious option -e echos to STDERR rather than STDOUT): cat -e PIPE2 2PIPE1 (read from PIPE2 and write it to STDOUT, copy input, normally going to STDERR to PIPE1)

    Read the article

  • .php files see Apache environment variables, .html files don't

    - by dotancohen
    Consider this environment: $ cat .htaccess AddType application/x-httpd-php .php .html SetEnv Foo Bar $ cat test.php <?php echo "Hello: "; echo $_SERVER['Foo']; echo $_ENV['Foo']; echo getenv('Foo'); ?> $ cat test.html <?php echo "Hello: "; echo $_SERVER['Foo']; echo $_ENV['Foo']; echo getenv('Foo'); ?> This is the output of test.php: Hello BarBarBar This is the output of test.html: Hello Why might that be? How might I fix it? Here is phpinfo.php: http://pastebin.com/rgq7up61 Here is phpinfo.html: http://pastebin.com/VUKFNZ36 If anyone knows where I can host a real webpage instead of just the HTML for one, please let me know and I'll move the content to there. Thanks.

    Read the article

  • Syntax error in apc.ini: unexpected '='

    - by Ashley
    I installed APC on Ubuntu 10.04 and it seems to be working fine but I'm seeing this error in my Apache error.log: PHP: syntax error, unexpected '=' in /etc/php5/apache2/conf.d/apc.ini on line 2 The contents of the file are: cat /etc/php5/apache2/conf.d/apc.ini extension=apc.so apc.enabled="1" apc.shm_segments="1" apc.shm_size="192" apc.num_files_hint="1024" And I have also tried it without the quotes (") around the values and get the same error. I've looked at loads of the tutorials on installing APC that mention apc.ini and they all seem to use one of the two syntax formats I have tried. I'd appreciate any ideas. Update: This still causes it: cat /etc/php5/apache2/conf.d/apc.ini extension='apc.so' apc.enabled='1' apc.shm_segments='1' apc.shm_size='192' apc.num_files_hint='1024' I changed to: cat /etc/php5/apache2/conf.d/apc.ini extension=apc.so and it still happens (there's no line 2 in the file now!) I'm assuming a /etc/init.d/apache2 reload will be sufficient to read the new config, is that my mistake?

    Read the article

  • passing URL vars to a wordpress page and pretty-fying it with .htaccess

    - by Jonah
    I have wordpress installed in a directory called welcome, and /welcome/samples is a "page" (created via Wordpress). It's has a php template waiting for a $_REQUEST['category'] When a user goes to /welcome/samples/fun, I want to have "fun" passed to the samples php template in the form welcome/samples/?category=fun But I want the URL to remain in its original form - it's currently replacing the it with the ugly "?cat...etc" # Outside the wordpress block so it won't be overwritten Options +FollowSymlinks RewriteEngine On RewriteRule ^samples/([^/]+)$ /welcome/samples?cat=$1 [R,L] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /welcome/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /welcome/index.php [L] </IfModule> # END WordPress I tried Rewriting with simply samples?cat=$1 but I was getting a 404. I tried putting in the RewriteBase /welcome/ in the first block. without the [R] flag it doesn't work at all. I keep trying different permutations... and failing:( Perhaps I'm missing some basic concepts... thanks if you take the time to even read through this:) ciao

    Read the article

  • Files listed by bash but unaccessible

    - by Cerin
    What would cause the following behavior on an Ubuntu 12.04 system? I've SSHed into a machine as the "ubuntu" user. Running ls -lah /data/* shows dozens of non-empty files (e.g. file1.txt, file2.txt, etc), all owned by the "ubuntu" user/group, and with full read/write access. If I try to cat /data/file1.txt, bash gives me the error "cat: /data/file1.txt: No such file or directory" In short, ls is listing files, but in every other way, the files essentially don't exist. I can't cat them or read them in any way. Even giving all the files 777 permission doesn't change anything. This is really bizarre. What's going on here?

    Read the article

  • Grepping grep output fails

    - by viraptor
    I'm trying to grep the output of ngrep. Unfortunately when I add another grep to the pipeline, I get no output at all. It can be some other command too - cat / grep / tee - everything breaks the chain. Example: # this works: $ ngrep -l -q -T -Wbyline -d any udp and port 5060 | egrep -B1 '^SIP/2.0 180' -- U +1.469535 xxx:5060 -> xxx:5060 SIP/2.0 180 Ringing. -- U +0.001384 xxx:5060 -> xxx:2048 SIP/2.0 180 Ringing. but #these don't: $ ngrep -l -q -T -Wbyline -d any udp and port 5060 | egrep -B1 '^SIP/2.0 180' | egrep '^U' $ ngrep -l -q -T -Wbyline -d any udp and port 5060 | egrep -B1 '^SIP/2.0 180' | cat $ ngrep -l -q -T -Wbyline -d any udp and port 5060 | egrep -B1 '^SIP/2.0 180' | tee test If I use cat somefile instead of ngrep at the start, everything works as expected. Any ideas what could go wrong here?

    Read the article

  • ssl_error_log apache issue

    - by lakshmipathi
    https://localhost works but https://ipaddress didn't cat logs/ssl_error_log [Mon Aug 02 19:04:11 2010] [error] [client 192.168.1.158] (13)Permission denied: access to /ajaxterm denied [root@space httpd]# cat logs/ssl_access_log 192.168.1.158 - - [02/Aug/2010:19:04:11 +0530] "GET /ajaxterm HTTP/1.1" 403 290 [root@space httpd]# cat logs/ssl_request_log [02/Aug/2010:19:04:11 +0530] 192.168.1.158 SSLv3 DHE-RSA-CAMELLIA256-SHA "GET /ajaxterm HTTP/1.1" 290 httpd.conf file NameVirtualHost *:443 <VirtualHost *:443> ServerName localhost SSLEngine on SSLCertificateFile /etc/pki/tls/certs/ca.crt SSLCertificateKeyFile /etc/pki/tls/private/ca.key <Directory /usr/share/ajaxterm > Options FollowSymLinks AllowOverride None Order deny,allow Allow from All </Directory> DocumentRoot /usr/share/ajaxterm DirectoryIndex ajaxterm.html ProxyRequests Off <Proxy *> # Order deny,allow Allow from all </Proxy> ProxyPass /ajaxterm/ http://localhost:8022/ ProxyPassReverse /ajaxterm/ http://localhost:8022/ ErrorLog error_log.log TransferLog access_log.log </VirtualHost> How to fix this ?

    Read the article

  • NFSv4 with idmap

    - by HTF
    The following errors appear on the NFS server, could you please advise how I can fix this? Details: System: CentOS release 6.4, NFS: nfs-utils-1.2.3-36 # cat /etc/idmapd.conf [General] Domain = domain.com [Mapping] Nobody-User = nobody Nobody-Group = nobody [Translation] Method = nsswitch Sep 3 08:25:28 snode1 rpc.idmapd[1382]: nss_getpwnam: name '0' does not map into domain 'domain.com' Sep 3 08:25:29 snode1 rpc.idmapd[1382]: nss_getpwnam: name '500' does not map into domain 'domain.com' EDIT: 03 Sep 2013 10:41 Please note that I'm using NFSv4 and these errors appear on NFS server only (not NFS clients). Server: # cat /etc/sysconfig/nfs MOUNTD_NFS_V2="no" MOUNTD_NFS_V3="no" ... RPCNFSDARGS="-N 2 -N 3" Clients: # cat /etc/fstab server:/ /data nfs4 defaults,hard,intr,timeo=15,_netdev,noatime,nodiratime,nosuid 0 0

    Read the article

  • jquery dynamic select doesn't submit values

    - by n00b0101
    I have a form that includes three select boxes. The first one is categories, and selecting a category from it will populate the variables multi-select box with values specific to the selected category. Selecting variables and then clicking "add selected" will populate the target select box will those variables. The problem is, print_r shows that the values in the target select box aren't passed upon submit, and I don't understand why... Below is the code, and help is really appreciated Here's the html markup: <select multiple="" id="categories" name="categories[]"> <option class="category" value="Income">Income</option> <option class="category" value="Gender">Gender</option> <option class="category" value="Age">Age</option> </select> //note that i'm only showing variables for a presumably select category <select multiple="multiple" id="variables" name="variables[]"> <option value="2">Less Than $15,000</option> <option value="3">$15,000 - $19,999</option> <option value="4">$20,000 - $29,999</option> <option value="5">$30,000 - $39,999</option> <option value="6">$40,000 - $49,999</option> <option value="11">$90,000 - $99,999</option> <option value="12">$100,000 - $124,999</option> <option value="13">$125,000 - $149,999</option> <option value="14">Greater than $149,999</option> </select> <select name="target[]" id="target" multiple="multiple" height="60"> </select> And here's the jquery code: $(function(){ var opts = {}, $cats = $("#categories"), $target = $("#target"), $vars = $("#variables"); $vars.find("option").each(function(){ var $opt = $(this), cat = this.className, value = this.value, label = $opt.text(); if(!opts[cat]) { opts[cat] = []; } opts[cat].push({label: label, value: value}); $opt.remove(); }); function update_variables(){ var cat = $cats.val(), new_opts = []; $vars.empty(); $.each(opts[cat], function(){ if( $target.find('[value=' + this.value + ']').length === 0 ){ new_opts.push(option(this.value, this.label)); } }); $vars.html(new_opts.join('')); } function option(value, label){ return "<option value='" + value + "'>" + label + "</option>"; } $("#add").click(function(e){ e.preventDefault(); $vars.find(':selected').appendTo($target).attr('selected',false); update_variables(); }); $("#remove").click(function(e){ e.preventDefault(); $target.find(':selected').remove(); update_variables(); }); $cats.change(function(){ update_variables(); }).change(); })

    Read the article

  • How to join video files from terminal?

    - by Leon Vitanos
    I have tried avidemux2_cli, mencoder, ffmpeg, cat.. But this doesn't always work (With the most of the times the error is that the audio codec is not the same) Maybe i put wrong options in the commands. So the commands: cat Sample.avi rrr.avi > complete.avi ffmpeg -i Sample.avi -i output.avi -vcodec copy -acodec copy complete.avi mencoder -ovc lavc -oac copy Sample.avi rrr.avi -o complete.avi avidemux2_cli --audio-codec copy --video-codec copy --output-format avi --load Sample.avi -append output.avi --save video.avi The cat problem is that it doesn't show error but it doesn't work always..Like the complete.avi will be exactly the same with Sample.avi Fmmpeg does nothing. The complete.avi is always the same with Sample.avi Mencoder error: All files must have identical audio codec and format for -oac copy. So the complete.avi is the same with Sample.avi avidemux2_cli there is no error but the complete.avi is again the same with Sample.avi.. So to sum up, all complete.avi are the same with Sample.avi.. And the problem is that they don't have the same audio codec ( i quess ).. Any ideas?

    Read the article

  • Wake laptop when lid is opened?

    - by crackout12
    I have a SAMSUNG laptop, which by the experience in the last months, has been a great one. I am actually implementing some functionality to it, and since I noticed, I am able to wake up my laptop from sleep by just opening the lid on Windows 7, however, I need to press to power button to wake up in Ubuntu. Using a program called i-nex, I noted that the kernel DOES dettect a "lid switch", and I am looking forward to use it to wake up function. Any ideas? UPDATE: Thanks @yossile for bringing up some clues! However, output of command cat /proc/acpi/wakeup does not show the LID device. I still tried the second set of commands you gave me with no effect. Then I tried experimenting, guessing that LID should be named by other value, so I tried enabling the others. No victory so far. But I noticed that devices that did not have any pci listings were disabled at all time no matter what I tried. Here is the output of command cat /proc/acpi/wakeup: root@samsung:~# cat /proc/acpi/wakeup Device S-state Status Sysfs node PCE4 S4 *disabled pci:0000:00:04.0 SBAZ S4 *disabled pci:0000:00:14.2 P0PC S4 *disabled pci:0000:00:14.4 GEC S4 *disabled PE20 S4 *disabled pci:0000:00:15.0 PE21 S4 *disabled PE22 S4 *disabled pci:0000:00:15.2 PE23 S4 *disabled PWRB S5 *enabled So maybe it could be that LID is either GEC,PE21, or PE23? Still, there is /proc/acpi/button/lid/LID/state file which shows that LID is opened. Any more ideas?

    Read the article

  • Jocuri friv pentru toti

    - by haioase
    Jocurile online sunt o modalitate foarte simpla de a te relaxa in timpul liber si spun acest lucru deoarece nu ai altceva de facut decat sa te asezi in fata calculatorului, sa cauti pe internet ceea ce iti place si sa te joci cat vrei - sau cat de mult timp ai la dispozitie.Poate si din cauza ca sunt atat de cautate, industria jocurilor de pe internet a devenit tot mai infloritoare in ultima decada.Un site unde poti sa gasesti o multitudine de jocuri flash este si friv.me.uk games - Play your favorite online game, site dedicat in exclusivitate jocurilor friv de tot felul. Dupa cum se vede din titlu este in limba engleza, dar acest lucru nu cred ca reprezinta un impediment pentru vizitatorii din lumea intreaga care viziteaza www.friv.me.uk , deoarece astazi pana si copiii de gradinita stiu semnificatia cuvintelor play this game sau click here to play.Daca va intrebati ce sa alegeti din multele jocuri de acolo, v-as sugera sa incercati noile jocuri friv de strategie, deoarece sunt atat haioase, cat si interesante si educative pentru cei mici. Nu iti trebuie dexteritate in apasarea tastelor, ci o minte organizata, deoarece trebuie sa iti faci un plan de aparare foarte bun pentru a putea castiga un joc de genul lui Bloons tower defense, de exemplu.Fetelor care vor sa se joace pe friv.me.uk as vrea sa le sugerez cateva jocuri speciale pentru ele, cum ar fi cele de gatit impreuna cu Dora. Se vor distra copios, preparand cea mai gustoasa pizza in bucataria virtuala a Dorei si, in acelasi timp, vor invata fractiile, deoarece trebuie sa imparta pizza in felii egale pentru toti cei aflati la masa.Acestea au fost doar cateva idei despre ce jocuri friv puteti sa va jucati in fiecare zi pe friv.me.uk. Voi alegeti orice va place si stati oricat vreti acolo, pentru ca este un site unde va puteti amuza foarte tare impreuna cu prietenii sau familia. Distractie placuta tuturor!

    Read the article

  • Better solution then simple factory method when concrete implementations have different attributes

    - by danip
    abstract class Animal { function eat() {..} function sleep() {..} function isSmart() } class Dog extends Animal { public $blnCanBark; function isSmart() { return $this->blnCanBark; } } class Cat extends Animal { public $blnCanJumpHigh; function isSmart() { return $this->blnCanJumpHigh; } } .. and so on up to 10-20 animals. Now I created a factory using simple factory method and try to create instances like this: class AnimalFactory { public static function create($strName) { switch($strName) { case 'Dog': return new Dog(); case 'Cat': return new Cat(); default: break; } } } The problem is I can't set the specific attributes like blnCanBark, blnCanJumpHigh in an efficient way. I can send all of them as extra params to create but this will not scale to more then a few classes. Also I can't break the inheritance because a lot of the basic functionality is the same. Is there a better pattern to solve this?

    Read the article

  • GDM locale problems

    - by Simón
    I have two problems with GDM on Ubuntu 10.04. The first is with locales. In my system I have defined: $ cat /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" LANG="es_ES.UTF-8" LANGUAGE="es_ES:es:en_US:en" $ cat /etc/default/locale LANG="es_ES.UTF-8" LANGUAGE="es_ES:es:en_US:en" $ cat /var/lib/locales/supported.d/local es_ES UTF-8 es_ES.UTF-8 UTF-8 en_US UTF-8 en_US.UTF-8 UTF-8 But when I enter in gnome desktop: $ locale LANG=es_ES LANGUAGE=es_ES:es:en_US:en LC_CTYPE="es_ES" LC_NUMERIC="es_ES" LC_TIME="es_ES" LC_COLLATE="es_ES" LC_MONETARY="es_ES" LC_MESSAGES="es_ES" LC_PAPER="es_ES" LC_NAME="es_ES" LC_ADDRESS="es_ES" LC_TELEPHONE="es_ES" LC_MEASUREMENT="es_ES" LC_IDENTIFICATION="es_ES" LC_ALL= I have deleted ~/.dmrc and I have restarted the system but nothing. GDM login screen also doesn't permit change this setting. However, in the text terminals (tty1,...): $ locale LANG=es_ES.UTF-8 LANGUAGE=es_ES:es:en_US:en LC_CTYPE="es_ES.UTF-8" LC_NUMERIC="es_ES.UTF-8" LC_TIME="es_ES.UTF-8" LC_COLLATE="es_ES.UTF-8" LC_MONETARY="es_ES.UTF-8" LC_MESSAGES="es_ES.UTF-8" LC_PAPER="es_ES.UTF-8" LC_NAME="es_ES.UTF-8" LC_ADDRESS="es_ES.UTF-8" LC_TELEPHONE="es_ES.UTF-8" LC_MEASUREMENT="es_ES.UTF-8" LC_IDENTIFICATION="es_ES.UTF-8" LC_ALL= The solution to problem is to edit .drmc file, but I think this isn't the right way. Why doesn't GDM read/apply the system locales? Why don't I see, in GDM login screen, the box to change the locale?

    Read the article

  • SQL*Plus??? - ?????????1??????(????? ???Tips-1)

    - by Yuichi.Hayashi
    ??????????SQL*Plus????3?????????????? ????????????????????????????????????????2??????????????????????????????????????????????? ??????????????????1????????????????????? ??1:SQL*Plus?-l?????????? ?????????????????SQL*Plus?-l???????????????? <-l ??????????????> $ sqlplus scott/cat SQL*Plus: Release 11.2.0.1.0 Production on ? 12? 22 15:15:11 2010 Copyright (c) 1982, 2009, Oracle. All rights reserved. ERROR: ORA-01017: invalid username/password; logon denied ??????????????: <-l ???????????????> $ sqlplus -l scott/cat SQL*Plus: Release 11.2.0.1.0 Production on ? 12? 22 15:18:55 2010 Copyright (c) 1982, 2009, Oracle. All rights reserved. ERROR: ORA-01017: invalid username/password; logon denied SP2-0751: Oracle????????????SQL*Plus??????? $ ????????-l??????????????????????????????????SQL*Plus?????????????????? ??2:/nolog??????????? ?????/nolog??????????????SQL???????connect???????????????????? connect????????????????????????exit??????????????????SQL??????SP2-0640: ??????????????????????? $ sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on ? 12? 22 15:46:53 2010 Copyright (c) 1982, 2009, Oracle. All rights reserved. SQL conn scott/cat ERROR: ORA-01017: invalid username/password; logon denied SQL select sysdate from dual; SP2-0640: ?????????? SQL SQL exit $ (Written by Hiroyuki Nakaie)

    Read the article

  • Need to optimize this PHP script for "recent posts". Fatal error when post count is high...

    - by Scott B
    The code below is resulting in an error on a site in which there are ~ 1500 posts. It performs fine when post count is nominal, however, this heavy load is exposing the weakness of the code and I'd like to optimize it. Interestingly, when I disable this menu and instead use the "Recent Posts" widget, the posts are drawn fine. So I'd probably do good to borrow from that code if I knew where to find it, or better yet, If I could call the widget directly in my theme, passing it a post count variable. Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 16384 bytes) in /home1/est/public_html/mysite/wp-includes/post.php on line 3462 The code is below. Its purpose is to list "recent posts". global $post; $cat=get_cat_ID('myMenu'); $cathidePost=get_cat_ID('hidePost'); $myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$cathidePost",'showposts' => $count-of-posts)); $myrecentposts2 = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$cathidePost",'showposts' => -1)); $myrecentpostscount = count($myrecentposts2); if ($myrecentpostscount > 0) { ?> <div class="recentPosts"><h4><?php if ($myHeading !=="") { echo $myHeading; } else { echo "Recent Posts";} ?></h4><ul> <?php $current_page_recent = get_post( $current_page ); foreach($myrecentposts as $idxrecent=>$post) { if($post->ID == $current_page_recent->ID) { $home_menu_recent = ' class="current_page_item'; } else { $home_menu_recent = ' class="page_item'; } $myclassrecent = ($idxrecent == count($myrecentposts) - 1 ? $home_menu_recent.' last"' : $home_menu_recent.'"'); ?> <li<?php echo $myclassrecent ?>><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php } ; if (($myrecentpostscount > $count-of-posts) && $count-of-posts > -1){ ?><li><a href="<?php bloginfo('url'); ?>/recent">View All Posts</a></li><?php } ?></ul></div>

    Read the article

  • Losing reference to $_post variable?

    - by Scott B
    In the code below, the echo at the top returns true, but the echo at the bottom returns nothing. Apparently the code in between is causing me to lose a reference to the $_post variable? <?php echo "in category: ".in_category('is-sidebar', $_post); //RETURNS TRUE if (!get_option('my_hide_recent')) { $cat=get_cat_ID('top-menu'); $catHidden=get_cat_ID('hidden'); $myquery = new WP_Query(); $myquery->query(array( 'cat' => "-$cat,-$catHidden", 'post_not_in' => get_option('sticky_posts') )); $myrecentpostscount = $myquery->found_posts; if ($myrecentpostscount > 0) { ?> <div class="menu"><h4><?php if ($my_sidebar_heading_recent !=="") { echo $my_sidebar_heading_recent; } else { echo "Recent Posts";} ?></h4><ul> <?php global $post; $current_page_recent = get_post( $current_page ); $myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$catHidden",'showposts' => $my_recent_count)); foreach($myrecentposts as $idxrecent=>$post) { if($post->ID == $current_page_recent->ID) { $home_menu_recent = ' class="current_page_item'; } else { $home_menu_recent = ' class="page_item'; } $myclassrecent = ($idxrecent == count($myrecentposts) - 1 ? $home_menu_recent.' last"' : $home_menu_recent.'"'); ?> <li<?php echo $myclassrecent ?>><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php } ; if (($myrecentpostscount > $my_recent_count) && $my_recent_count > -1){ ?><li><a href="<?php bloginfo('url'); ?>/site-map">View all</a></li><?php } ?></ul></div> <?php } } global $sitemap; echo "in category: ".in_category('is-sidebar', $_post); //RETURNS NOTHING

    Read the article

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