Daily Archives

Articles indexed Friday October 25 2013

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

  • Nginx routing script for NodeJS and Wordpress

    - by Nilay Parikh
    We are moving blogs and site from wordpress to nodejs and ready to move into production. However I'm not able to figure it out how to implement routing from front server (Nginx) to NodeJS (prefered web instance) and if data not synced yet into NodeJS website than (404 will throw by NodeJS) fall back to (using reverse proxy) to Wordpress and serve page, during the transformation period. Q1. Is the approach good for the scenario, or anyone can suggest better approach? Q2. Should NodeJS treat itself as Reverse proxy (using bouncy : https://github.com/substack/bouncy or similar package) in event of fall back or shoud stick with Nginx to do so using fastcgi approch. Both NodeJS and Wordpress are on single server only, In first scenario, /if resource available than serve directly User -> Nginx -> NodeJS (8080) \if resource not available then reverse query wordpress and serve content second scenario, /if resource available than serve directly User -> Nginx -> NodeJS (8080) \if resource not available then 404 to Nginx and Nginx script fallback to Wordpress (FastCGI PHP) Later we have plan to phase out Wordpress and PHP from the server environment completely. I'd like to see any examples of Nginx or Varnish scripts and/or NodeJS scripts if you have for me to refer. Thanks.

    Read the article

  • AdBlock users statistics

    - by DataSmarter
    Are there statistics of internet users that use AdBlock or other ad blocking plug-ins? Are there some statistical breakdown, for example, per country (I assume it must vary a lot)? I was unable to google the information I am looking for. The reason I am asking is because I have just signed up for the "Amazon Partners" program and see that this affiliate program is listed on the AdBlock blacklist.

    Read the article

  • Google Authorship Image of my blogspot has been disappeared in Google SERP. Why?

    - by Sathiya Kumar
    I have a blogspot and i used my image to appear on the Google SERP for my keywords using Google Authorship Markup. My image was showed for last 2 months but while checking SERP for my blog, i found that my authorship markup is not working. My image, name and G+ followers count is not appearing near my blogspot URL in SERP. I didn't made any changes in my google+ profile or in my blogspot header tag where i had put the authorship code. I tried to find the reason but i didn't find any value answer. May anyone answer this question. Please let me know if you had already experienced like this.

    Read the article

  • Grid-Based 2D Lighting Problems

    - by Lemoncreme
    I am aware this question has been asked before, but unfortunately I am new to the language, so the complicated explanations I've found do not help me in the least. I need a lighting engine for my game, and I've tried some procedural lighting systems. This method works the best: if (light[xx - 1, yy] > light[xx, yy]) light[xx, yy] = light[xx - 1, yy] - lightPass; if (light[xx, yy - 1] > light[xx, yy]) light[xx, yy] = light[xx, yy - 1] - lightPass; if (light[xx + 1, yy] > light[xx, yy]) light[xx, yy] = light[xx + 1, yy] - lightPass; if (light[xx, yy + 1] > light[xx, yy]) light[xx, yy] = light[xx, yy + 1] - lightPass; (Subtracts adjacent values by 'lightPass' variable if they are more bright) (It's in a for() loop) This is all fine and dandy except for a an obvious reason: The system favors whatever comes first in the for() loop This is what the above code looks like applied to my game: If I could get some help on creating a new procedural or otherwise lighting system I would really appreciate it!

    Read the article

  • Brief pause after keypress

    - by user36324
    After i press and hold the key it goes forward once then pauses for a second or less then goes forward on forever. My problem is the brief pause I cant locate the issue. Thanks for your help. while(game){ while (SDL_PollEvent(&e)){ mainChar.manageEvents(e); } background.renderChar(); mainChar.renderChar(); SDL_RenderPresent(ren); } void Character::manageEvents(SDL_Event event) { switch(event.type){ case SDL_KEYDOWN: KEYS[event.key.keysym.sym] = true; printf("true"); handleInput(); break; case SDL_KEYUP: KEYS[event.key.keysym.sym] = false; printf("false"); break; default: break; } } void Character::handleInput() { if(KEYS[SDLK_a]) { dst.x--; } if(KEYS[SDLK_d]) { dst.x++; } if(KEYS[SDLK_w]) { dst.y++; } if(KEYS[SDLK_s]) { dst.y--; } }

    Read the article

  • Pygame: Save a list of objects/classes/surfaces

    - by Sam Tubb
    I am working on a game, in which you can create mazes. You place blocks on a 16x16 grid, while choosing from a variety of block to make the level with. Whenever you create a block, it adds this class: class Block(object): def __init__(self,x,y,spr): self.x=x self.y=y self.sprite=spr self.rect=self.sprite.get_rect(x=self.x,y=self.y) to a list called instances. I tried shelving it to a .bin file, but it returns some error dealing with surfaces. How can I go about saving and loading levels? Any help is appreciated! :) Here is the whole code for reference: import pygame from pygame.locals import * #initstuff pygame.init() screen=pygame.display.set_mode((640,480)) pygame.display.set_caption('PiMaze') instances=[] #loadsprites menuspr=pygame.image.load('images/menu.png').convert() b1spr=pygame.image.load('images/b1.png').convert() b2spr=pygame.image.load('images/b2.png').convert() currentbspr=b1spr curspr=pygame.image.load('images/curs.png').convert() curspr.set_colorkey((0,255,0)) #menu menuspr.set_alpha(185) menurect=menuspr.get_rect(x=-260,y=4) class MenuItem(object): def __init__(self,pos,spr): self.x=pos[0] self.y=pos[1] self.sprite=spr self.pos=(self.x,self.y) self.rect=self.sprite.get_rect(x=self.x,y=self.y) class Block(object): def __init__(self,x,y,spr): self.x=x self.y=y self.sprite=spr self.rect=self.sprite.get_rect(x=self.x,y=self.y) while True: #menu items b1menu=b1spr.get_rect(x=menurect.left+32,y=48) b2menu=b2spr.get_rect(x=menurect.left+64,y=48) menuitems=[MenuItem(b1menu,b1spr),MenuItem(b2menu,b2spr)] screen.fill((20,30,85)) mse=pygame.mouse.get_pos() key=pygame.key.get_pressed() placepos=((mse[0]/16)*16,(mse[1]/16)*16) if key[K_q]: if mse[0]<260: if menurect.right<255: menurect.right+=1 else: if menurect.left>-260: menurect.left-=1 else: if menurect.left>-260: menurect.left-=1 for e in pygame.event.get(): if e.type==QUIT: exit() if menurect.right<100: if e.type==MOUSEBUTTONUP: if e.button==1: to_remove = [i for i in instances if i.rect.collidepoint(placepos)] for i in to_remove: instances.remove(i) if not to_remove: instances.append(Block(placepos[0],placepos[1],currentbspr)) for i in instances: screen.blit(i.sprite,i.rect) if not key[K_q]: screen.blit(curspr,placepos) screen.blit(menuspr,menurect) for item in menuitems: screen.blit(item.sprite,item.pos) if item.rect.collidepoint(mse): if pygame.mouse.get_pressed()==(1,0,0): currentbspr=item.sprite pygame.draw.rect(screen, ((255,0,0)), item, 1) pygame.display.flip()

    Read the article

  • ContentManager in XNA cant find any XML

    - by user36385
    Im making a game in XNA 4 and this is the first time I'm using the Content loader to initialize a simple class with a XML file, but no matter how many guide I follow, or how simple or complicated is my XML File the ContentManager cant find the file; the Debug keep telling me: "A first chance exception of type 'Microsoft.Xna.Framework.Content.ContentLoadException' occurred in Microsoft.Xna.Framework.dll". I'm really confuse because I can load SpriteFonts and Texture2D without a problem ... I create the following XML (the most basic Xna XML): <?xml version="1.0" encoding="utf-8" ?> <XnaContent> <Asset Type="System.String">Hello</Asset> </XnaContent> and I try to load it in the LoadContent method in my main class like this: System.String hello = Content.Load<System.String>("NewXmlFile"); There is something I'm doing wrong? I really appreciate your help

    Read the article

  • C# Convert negative int to 11 bits

    - by Klemenko
    I need to convert numbers in interval [–1024, 1016]. I'm converting to 11 bits like that: string s = Convert.ToString(value, 2); //Convert to binary in a string int[] bits = s.PadLeft(11, '0') // Add 0's from left .Select(c => int.Parse(c.ToString())) // convert each char to int .ToArray(); // Convert IEnumerable from select to Array This works perfectly for signed integers [0, 1016]. But for negative integers I get 32 bits result. Do you have any idea how to convert negative integers to 11 bits array?

    Read the article

  • Android Samsung S2 spannablestringbuilder error

    - by Bilal Akmal
    I'm working on an app which fetches data from server using JSON. It is working fine in emulator but in my phone, it is giving error and not getting data. The error comes at this point in JSON Parser.... HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost);//Error Point httpEntity = httpResponse.getEntity(); On the third line logcat shows.... SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length I have searched a lot but it doesn't help me.

    Read the article

  • Java Passing variables around classes

    - by nazerb
    I am new to java and am trying to pass variables like in the following example from one class to another, im wondering is this possible and how i would go about it if it is. As this code does not work as it is not static. Main Class public class testAll { public static void main(String[] args) { One one = new One(); Two two = new Two(); } } The first class: public class One { public int test = 4; public int getTest() { return this.test; } } The second class: public class Two { public void value() { System.out.print("Var is: " + One.getTest()); } } Thanks, Naz

    Read the article

  • cuda 5.0 namespaces for contant memory variable usage

    - by Psypher
    In my program I want to use a structure containing constant variables and keep it on device all long as the program executes to completion. I have several header files containing the declaration of 'global' functions and their respective '.cu' files for their definitions. I kept this scheme because it helps me contain similar code in one place. e.g. all the 'device' functions required to complete 'KERNEL_1' are separated from those 'device' functions required to complete 'KERNEL_2' along with kernels definitions. I had no problems with this scheme during compilation and linking. Until I encountered constant variables. I want to use the same constant variable through all kernels and device functions but it doesn't seem to work. ########################################################################## CODE EXAMPLE ########################################################################### filename: 'common.h' -------------------------------------------------------------------------- typedef struct { double height; double weight; int age; } __CONSTANTS; __constant__ __CONSTANTS d_const; --------------------------------------------------------------------------- filename: main.cu --------------------------------------------------------------------------- #include "common.h" #include "gpukernels.h" int main(int argc, char **argv) { __CONSTANTS T; T.height = 1.79; T.weight = 73.2; T.age = 26; cudaMemcpyToSymbol(d_consts, &T, sizeof(__CONSTANTS)); test_kernel <<< 1, 16 >>>(); cudaDeviceSynchronize(); } --------------------------------------------------------------------------- filename: gpukernels.h --------------------------------------------------------------------------- __global__ void test_kernel(); --------------------------------------------------------------------------- filename: gpukernels.cu --------------------------------------------------------------------------- #include <stdio.h> #include "gpukernels.h" #include "common.h" __global__ void test_kernel() { printf("Id: %d, height: %f, weight: %f\n", threadIdx.x, d_const.height, d_const.weight); } When I execute this code, the kernel executes, displays the thread ids, but the constant values are displayed as zeros. How can I fix this?

    Read the article

  • can not find out if the div element is already set in body in chrome extension

    - by alpham8
    in my chrome extension I got an div, which I will add to the body of the current tab. I am listening to chrome.tabs.onUpdated. If this event is called, I execute a script inside content_scripts. In this function there I´ll wait till the document is ready with jQuery $(document).ready(...). I try to access $("#div").length and sometimes it returns 1 and sometimes 0. It should added to the body, if it´s not already there. For some strange reasons, the onUpdated event is called twice on each page reload. Actually I found no way to check safely if the div was already added.

    Read the article

  • Migrating just article contect of Joomla 1.0 to 2.5.x / 3.x?

    - by user2919408
    I have a simple website using Joomla 1.0.15, just having articles in some categories. As i want to install or remove components from admin area, i got : "You are not authorised to view this resource" or something like that. This is uncommon, this site is about 5 years old, and never got error message like that. I think my website is hacked ?? I have set safe_mode = off in php.ini, turn of sh404sef, removing .htaccess file etc ... and it still does not work. Then i try to upgrade to Joomla 2.5.x / 3.x . I found that i must migrate to Joomla 1.5.x first, then from there to 2.5.x. I got problem installing "migration.zip" component in my Joomla 1.0.x (always alert/err message pop up is shown). Is there another way to migrate the website ? May be just get the article section, category, article id and the content of Joomla 1.0.x , then import it to Joomla 2.5.x / 3.x ? I don't need components, modules, mambots (if any) of the old site. How to do it ? Thanks

    Read the article

  • WAMP server suddenly stopped running scripts

    - by user2358008
    I have been working on a website for some months now. Every day, I open up the PHP scripts in the same manner, and every day they work just fine. Today, I go to open one up the same as I always do, except the page just comes up as the text file. All pages are the same, I have not changed most of them for many weeks now. WAMP is giving me no errors. I just installed the latest version, and it still won't work. There is no problem with file extensions, The only problem I can find is in the Apache Error Log: [Fri Oct 25 10:42:40.029691 2013] [mime:warn] [pid 4860:tid 1508] AH01599: Cannot get media type from 'x-httpd-php53' What does this mean?

    Read the article

  • Solr alphabetical sorting trouble. Sorting uppercase then lowercase for string type field

    - by Alauddin Ansari
    I've crated a title field with list below: Asking is good But answering is best join the group like this You are the best hey dudes. whass up When I'm sorting this ASC (&sort=title ASC) Asking is good But answering is best You are the best hey dudes. whass up join the group like this and (&sort=title DESC) join the group like this hey dudes. whass up You are the best But answering is best Asking is good But I'm expecting result like: (&sort=title ASC) Asking is good But answering is best hey dudes. whass up join the group like this You are the best schema.xml <field name="title" type="text_general" indexed="true" stored="true"/> <field name="title_sort" type="string" indexed="true" stored="false"/> <copyField source="title" dest="title_sort" /> I'm using title_sort field to sort (also tried title field) Please tell me where I'm going wrong

    Read the article

  • How to correctly use = wp_enqueue_style with a CDN in wordpress?

    - by Amod
    My current code: wp_enqueue_style( 'script-css', plugins_url( 'script/myscript.js', FILE )); My goal: Instead of loading the file from the plugins directory, I want to load above script file from http://mycloudfronturl.net/myscript.js But somehow I am messing with either the quotes or while replacing the plugins_url. I am not a hard code php coder, so can someone tell me what to do please? Thanks and Regards, Amod

    Read the article

  • java instanceof not finding method

    - by Razvan N
    I have a problem with java instanceof. I have a class called Employee and several others that extend this one, for example - Manager. I also created another class,EmployeeStockPlan, where I wanted to test if instanceof is finding which object I am using. But when I am calling a method from the new class, I have this error: The method grantStock(Manager) is undefined for the type Loader. Sorry, I am somehow new to some thing in java, I hope I am not asking dumb questions. The Employee class: package com.example.domain; public class Employee { private int empId; private String name; private String ssn; private double salary; public Employee(int empId, String name, String ssn, double salary) { // constructor // method; this.empId = empId; this.name = name; this.ssn = ssn; this.salary = salary; } public void setName(String newName) { if (newName != null) { this.name = newName; } } public void raiseSalary(double increase) { this.salary += increase; } public String getName() { return name; } public double getSalary() { return salary; } public String getDetails() { return "Employee id: " + empId + "\n" + "Employee name: " + name; } } The Manager class: package com.example.domain; public class Manager extends Employee { private String deptName; public Manager(int empId, String name, String ssn, double salary, String dept) { super(empId, name, ssn, salary); this.deptName = dept; } public String getDeptName() { return deptName; } public String getDetails() { return super.getDetails() + "\n" + "Department: " + deptName; } } The EmployeeStockPlan class: package com.example.domain; public class EmployeeStockPlan { public void grantStock(Employee e) { // nothing calculated, just simulating; System.out.println("This is an employee!"); if (e instanceof Manager) { // process Manager stock grant System.out.println("This is a manager!"); } else { // error - instance of Engineer? System.out.println("Not an engineer!"); } return; } } The main class: EmployeeStockPlan esp = new EmployeeStockPlan(); Manager m = new Manager (12421, "Manager1", "111-4254-521", 2430, "Marketing1"); grantStock(m);

    Read the article

  • Best way to set a default button (or trigger its event in javascript) for an input field, not part of a form

    - by Sheldon Pinkman
    I've got a stand-alone input field, not part of any form. I also got a button, that has some onclick event. When I type something in the input field, and press the Enter key, I want it do effectively press the button, or trigger its onclick event. So that the button is "the input field's default button" so to speak. <input id='myText' type='text' /> <button id='myButton' onclick='DoSomething()'>Do it!</button> I guess I can mess around with the input field's onkeypress or onkeydown events and check for the Enter key, etc. But is there a more 'clean' way, I mean something that associated the button with that input field, so that the button is the 'default action' or something for that field? Note that I'm not inside a form, I am not sending, posting, or submitting something. The DoSomething() function just changes some of the HTML content locally, depending on the text input.

    Read the article

  • How to catch mousewheel up/down event using RaphaelJs

    - by alex.dominte
    I need to implement a horizontal scrollable timeline. I've drawn the timeline/grids/rulers etc. I just need to catch mousewheel up/down to scroll the timeline (backward - past/forward - future). First I need to catch the event: but nothing I've found seems to work. Need browser support only for chrome/firefox (latest versions). These 2 won't listeners won't work: var paper = new Raphael('raphael-paper'); // ... paper.canvas.on('mousewheel', function(event) { console.log(event); }); // ... paper.canvas.addEventListener('mousewheel', function(event) { console.log(event); });

    Read the article

  • PHP Form - Empty input enter this text - Validation

    - by James Skelton
    No doubt very simple question for someone with php knowledge. I have a form with a datepicker, all is fine when a user has selected a date the email is send with: Date: 2012 04 10 But i would like if the user has skipped this and left blank (as i have not made this required) to send as: Date: Not Entered (<-- Or something) Instead at the minute of course it reads: Date: Form input <input type="text" class="form-control" id="datepicker" name="datepicker" size="50" value="Date Of Wedding" /> This is the validator $(document).ready(function(){ //validation contact form $('#submit').click(function(event){ event.preventDefault(); var fname = $('#name').val(); var validInput = new RegExp(/^[a-zA-Z0-9\s]+$/); var email = $('#email').val(); var validEmail = new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/); var message = $('#message').val(); if(fname==''){ showError('<div class="alert alert-danger">Please enter your name.</div>', $('#name')); $('#name').addClass('required'); return;} if(!validInput.test(fname)){ showError('<div class="alert alert-danger">Please enter a valid name.</div>', $('#name')); $('#name').addClass('required'); return;} if(email==''){ showError('<div class="alert alert-danger">Please enter an email address.</div>', $('#email')); $('#email').addClass('required'); return;} if(!validEmail.test(email)){ showError('<div class="alert alert-danger">Please enter a valid email.</div>', $('#email')); $('#email').addClass('required'); return;} if(message==''){ showError('<div class="alert alert-danger">Please enter a message.</div>', $('#message')); $('#message').addClass('required'); return;} // setup some local variables var request; var form = $(this).closest('form'); // serialize the data in the form var serializedData = form.serialize(); // fire off the request to /contact.php request = $.ajax({ url: "contact.php", type: "post", data: serializedData }); // callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ $('.contactWrap').show( 'slow' ).fadeIn("slow").html(' <div class="alert alert-success centered"><h3>Thank you! Your message has been sent.</h3></div> '); }); // callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // log the error to the console console.error( "The following error occured: "+ textStatus, errorThrown ); }); }); //remove 'required' class and hide error $('input, textarea').keyup( function(event){ if($(this).hasClass('required')){ $(this).removeClass('required'); $('.error').hide("slow").fadeOut("slow"); } }); // show error showError = function (error, target){ $('.error').removeClass('hidden').show("slow").fadeIn("slow").html(error); $('.error').data('target', target); $(target).focus(); console.log(target); console.log(error); return; } });

    Read the article

  • File not readable exception - pear/Config_Lite

    - by CasperNine
    I have two config files located in: /etc/svnauth and var/www/svnauth I have given read, write access to for both files like shown below chown -R apache:apache /etc/svnauth chmod -R 770 /etc/svnauth chown -R apache:apache /var/www/svnauth chmod -R 770 /var/www/svnauth When I try to read these two files using pear/Config_Lite, /etc/svnauth always fails. I can successfully read the /var/www/svnauth file Any reasons for this? What am I missing here Following is the error message i get: Fatal error: Uncaught exception 'Config_Lite_Exception_Runtime' with message 'file not readable: /etc/svnauth' in /var/www/html/svnmanager/Config/Lite.php:112 Stack trace: #0 /var/www/html/svnmanager/index.php(60): Config_Lite->read('/etc/svnauth') #1 {main} thrown in /var/www/html/svnmanager/Config/Lite.php on line 112

    Read the article

  • Need a VB Script to check if service exist

    - by Shorabh Upadhyay
    I want to write a VBS script which will check if specific service is installed/exist or not locally. If it is not installed/exist, script will display message (any text) and disabled the network interface i.e. NIC. If service exist and running, NO Action. Just exit. If service exist but not running, same action, script will display message (any text) and disabled the network interface i.e. NIC. i have below given code which is displaying a message in case one service is stop but it is not - Checking if service exist or not Disabling the NIC strComputer = "." Set objWMIService = Getobject("winmgmts:"_ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colRunningServices = onjWMIService.ExecQuery _ ("select State from Win32_Service where Name = 'dhcp'") For Each objService in colRunningServices If objService.State <> "Running" Then errReturn = msgbox ("Stopped") End If Next Please help. Thanks in advance.

    Read the article

  • Order a sentence alphabetically and count the number of times each words appears and print in a table

    - by JaAnTr
    I am struggling with the print in a table part of the question. So far I have managed to order the user inputted sentence alphabetically and count the number of times each word occurs. Here is the code: thestring = (raw_input()) sentence = thestring.split(" ") sentence.sort() count = {} for word in thestring.split(): try: count[word] += 1 except KeyError: count[word] = 1 print sentence print count And when I run the code I get this: ['apple', 'apple', 'banana', 'mango', 'orange', 'pear', 'pear', 'strawberry'] {'apple': 2, 'pear': 2, 'strawberry': 1, 'mango': 1, 'orange': 1, 'banana': 1} However, ideally I want it printed in a table that looks something like: apple.....|.....2 banana....|.....1 mango.....|.....1 orange....|.....1 pear......|.....2 strawberry|.....1 Thanks for any help!

    Read the article

  • how to align multiple div's next to each other?

    - by Ashok Kumar
    I am new to Html,I'm trying to align multiple div's next to each other horizontally. i tried float property and display inline property also, but nothing works correctly.can anyone suggest any methods for it? my code: #display2letter { width:150px; height:50px; background-color:grey; box: 10px 10px 5px #888888; } #display3letter { width:150px; height:50px; background-color:blue; box: 10px 10px 5px #888888; } #display4letter { width:150px; height:50px; background-color:grey; box: 10px 10px 5px #888888; } #one { position:fixed; left:23%; } #two { position:fixed; left:23%; } #three { position:fixed; left:23%; } here is the fiddle http://jsfiddle.net/pGHS9/1/

    Read the article

  • code setOnClickListener for multiple TextViews

    - by user2870583
    I have 40+ TextViews and I want to add click events on them, but I try to do it "shortly" : final GridLayout myGL; myGL = (GridLayout) v0725.findViewById( R.id.tab1 ); for( int i = 0; i < myGL.getChildCount(); i++ ) if ( getResources().getResourceEntryName(((TextView) myGL.getChildAt(i)).getId()).indexOf("v")==0 ) { ((TextView) myGL.getChildAt(i)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.v("edf", getResources().getResourceEntryName(((TextView) myGL.getChildAt(i)).getId())); } }); }; But Eclipse stops me on the Log.v line, because i should be final (but I can't) any tips?

    Read the article

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