Posts

Showing posts from July, 2010

java - Example images for code and mark-up Q&As -

Image
when preparing mcve / sscce involves images, useful have direct access images. the types of images cover questions - small images in multiple colors or shapes, animated gifs with/without transparency, jpegs 'pairs' of pictures & can used in image transitions, tile sets, sprite sheets.. are there small (under 30kb), on-site, license & royalty free images can hot-link these types of examples? here example images common use, existing answers on so. icons simple geometric shapes generated using java seen in this answer . includes java based interface defines urls , makes them easy access. details: 32x32 pixel png (4 colors x 5 shapes) partial transparency (along edges). categories: png icons       sprite sheets chess pieces seen on this answer includes 2 other sprite sets (same image in different colors). details: 384x128 px (each sprite 64x64 px) png partial transparency.

java - How to add MouseEvent inside the Anonymous Class Listener? -

so im making puzzle game in jframe, dont know how use mouseevent , put inside anonymous class listener. , problem. need move images center of frame , guess images. //p5 components(continue frame) imageicon pic1st = new imageicon("c:\\java pics\\w.png"); jlabel pic1st0 = new jlabel(pic1st); jlabel level = new jlabel("level:" + l); jlabel score = new jlabel("score:" + s); jlabel time = new jlabel("time:" + t); and anonymous class listener //this part of code want put mouseevent. continue1.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent arg0) { // todo auto-generated method stub f.add(p5); f.remove(p20); f.setvisible(true); f.revalidate(); f.repaint(); } }); //where put mouseevent here? any appreciated. why need mouseevent here? need

ruby on rails - Test if error validation text match a string using if statement doesn't works -

i have validation in user model check input text if have value or not : validate :picture_name ... ... ... def picture_name errors[:picture].push "no_name" if namepicture.blank? end html text field: <input type="text" name="namepicture" /> in view want check if @user.errors[:picture] contains 1 error , error text "no_name" (no_name error added picture_name validation) : <% if @user.errors.count.eql? 1 && @user.errors['picture'] == "no_name" %> <h1> test works </h1> <% else %> <h1> test doesn't works </h1> <% end %> but don't know why shows me "test doesn't works" when errors['picture'] contains (one) "no_name" error ! there error in if statement ? or ? thank you i found solution if interest someone, in above statement : if @user.errors.count.eql? 1 && @user.errors['picture']

php - How to solve this mysqli error -

code 1 works fine , updates attendance table: <?php $date = $_post['date']; $subject = $_post['subject']; $con=mysqli_connect("localhost","root","","notifier"); if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $result = mysqli_query($con,"select * student"); echo "enter attendance. please untick 'absent' students , submit"; echo "<br>"; echo "<form action=\"d.php\" method=\"post\">"; while($row = mysqli_fetch_array($result)) { echo "<br>" .$row['classrollno'] . "&nbsp&nbsp;&nbsp<input type=\"checkbox\" name=\"p[]\" value=\"" . $row['studentid'] . "\" checked>"; $sql="insert attendance (rollno, subjectid, date) values ('{$row['classrollno']}','$_post

objective c - iOS: Object equality when enumerating -

say have nsarray , , each item nsdictionary 3 keys keya, keyb, , keyc - each referring objects of unknown type (id) . if wanted write method found given element 3 keys i.e. -(nsdictionary *) itemthatcontainskeys:(id)objecta and:(id)objectb and:(id)objectc would run trouble enumerating through , testing object equality via if([i objectforkey:(keya) isequalto:objecta] ) etc? passing in actual objects set in dictionary initialization - ie not strings same value different locations. is bad practise? there better way without creating database? you can override isequal stipulate notion of equality type. same rules apply in other languages: if provide implementation of equals should provide implementation of 'hash' objects 'equal' should have same 'hash' equals should transitive -> if equals b, , b equals c, c must equal a. equals should bi-directional -> if equals b, b must equal a. this ensure predictable behavior in classes nss

php - How to use implode? -

i have php code <?php if(!empty($_post['invite'])) { foreach($_post['invite'] $check) { echo implode($_post['invite'], ','); } } result is: sky,earth,universesky,earth,universe here result showing 2 times see after universe sky agian repeat, want show result one. have idea? just echo implode($_post['invite'], ','); no need use loop

Make bash script run on both Linux and Solaris -

i writing script , script required work both on solaris , linux (opensuse) the script goes in different directories , compares files , outputs difference between files in specific manner. right now, developing on opensuse(linux). there tips on how can write/edit script works on both os? thank in advance writing portable script easy or @ least should be, use commands specified posix standard , stick documented options , behavior.

javascript - Treehouse or CodeSchool? -

i want expand js/jquery + php skills + frameworks, question: worth buying kind premium account learn, if yes threehouse or codeschool? update: have inspected course each website has, , had decided buy premium account @ codeschool, because there angularjs , other advanced web tutorials. because on treehouse there courses people starting beginning. thanks help. is worth it? in simple words, nobody knows. boils down want. php great language , can find want know googling, though nice know basics of language. learnt php sort of self learning (i watched online videos of harvard university's courses on edx(cs50). google taught me rest) to simplify, if want go straight learning ease, go it. if want take time, around , see related stuff, learn yourself. getting project challanges useful.

Which sorting algorithm is this? -

i need know sorting algorithm sorts this: [4 1 7 6 3 11] [4 1 7 3 6 11] [4 1 3 7 6 11] [1 4 3 7 6 11] [1 4 3 6 7 11] [1 3 4 6 7 11] tomorrow exam, , i'm confused. shall simple algorithm, can't insertion sort / selection sort, looked @ heapsort (absolutely) , merge sort - last option. i it's mergesort, addition should easy, i'm unsure. or heavily misunderstood how algorithms work. :( thanks reading, @ least! :) as can see, algorithm works comparing 2 adjacent values, makes bubble sort , interesting thing note here instead of sorting being done in left right passes, seems doing them in passes right left; in turn makes reversed bubble sort .

javascript - Enabling HTML 5 Mode in AngularJS 1.2 -

i'm working on app needs use html 5 mode. due fact migrating existing site use angularjs 1.2, cannot have '#' tags in url. currently, have following: angular.module('myapp', ['ngroute']). config(['$routeprovider', '$locationprovider', function($routeprovider, $locationprovider) { $locationprovider.html5mode(true); $routeprovider .when("/home", {templateurl:'home.html', controller:'homecontroller'}) // other routes defined here.. .otherwise({redirectto: '/home'}); }]); unfortunately, when visit ' http://myserver/home ', app not work when html 5 mode enabled. 404. however, when visit http://myserver/ works. deep-linking doesn't work when have html5 mode enabled. if comment out line says "$locationprovider.html5mode(true);", site functions. however, once again, cannot have hash tags in url due fact i'm migrating existing site. am misunderstanding how html

python - Format These Dates And Get Time Passed -

i have python list of dates , i'm using min , max find recent , oldest (first, best method?), need format dates can figure out current time , subtract oldest date in list can "in last 27 minutes..." can state how many days, hours, or minutes have past since oldest. here list (the dates change depending on i'm pulling) can see current format. how info need? [u'sun oct 06 18:00:55 +0000 2013', u'sun oct 06 17:57:41 +0000 2013', u'sun oct 06 17:55:44 +0000 2013', u'sun oct 06 17:54:10 +0000 2013', u'sun oct 06 17:35:58 +0000 2013', u'sun oct 06 17:35:58 +0000 2013', u'sun oct 06 17:35:25 +0000 2013', u'sun oct 06 17:34:39 +0000 2013', u'sun oct 06 17:34:39 +0000 2013', u'sun oct 06 17:34:39 +0000 2013', u'sun oct 06 17:30:35 +0000 2013', u'sun oct 06 17:25:28 +0000 2013', u'sun oct 06 17:24:04 +0000 2013', u'sun oct 06 17:24:04 +0000 2013', u'sun oct

android - Trivial programming mistakes found in source codes, when APK file decoded -

i followed steps here decode apk file, , tried compile decoded project in eclipse. found errors, of them trivial programming mistakes. here examples: int i; (int j = 0;; j++) { if (j >= i) return; } this error says local variable may not have been initialized. apk file, means project has been compiled successfully, what's wrong? there problem dex2jar file, has missed parts of code? help. here correction: int = 0; (int j = 0;; j++) { if (j >= i) return; } you should decompile own project, 1 still have original source for. that's best way see how unreliable compiler , how unreadable becomes. decompiling project not trivial. may still need make manual adjustments afterwards.

c++ - How to call a template Method -

this question has answer here: why can templates implemented in header file? 13 answers i read possible create template method. have in code file : student.h class student { public: template<class typeb> void printgrades(); }; file: student.cpp #include "student.h" #include <iostream> template<class typeb> void student::printgrades() { typeb s= "this string"; std::cout << s; } now in main.cpp student st; st.printgrades<std::string>(); now linker error: error 1 error lnk2019: unresolved external symbol "public: void __thiscall student::printgrades<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??$printgrades@v?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@@student@@qaexxz) referenced

wordpress - Get top-level category and make it a link -

wordpress - trying top-level parent category name , make link categories structured europe > eastern europe > poland in instance wan cat name europe , make link cat page europe. no matter try not seem able top category. being executed in custom qp query here go get top level categories <?php $args = array( 'orderby' => 'name', 'parent' => 0 ); $categories = get_categories( $args ); foreach ( $categories $category ) { echo '<a href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a><br/>'; } ?> get top level categories / taxonomy <?php $args = array( 'type' => 'post', 'orderby' => 'term_group', 'hide_empty' => 0, 'hierarchical' => 0, 'parent' => 0, 'taxonomy' => '..if using taxonomy

smalltalk - Send a file over websocket with pharo, ZnWebsocket, and Fuel in Pharo 2.0? -

i trying send large video files on websocket using pharo 2.0, , zinc websocket. pharo pharo transfer. i have tried in vain work. i'm sure there's simple solution i'm missing. help. edit: update: did work, through following code: mystream := (filestream oldfilenamed: 'big_buck_bunny_480p_surround-fix.avi') . bytes := mystream next: mystream size. mystream close. mystream := nil. server distributemessage: bytes. testconnect | websocket1 receivedfile| websocket1 := znwebsocket to: 'ws://192.168.1.102:1701/ws-chatroom'. testprocess := [ [ | mes | mes := [ websocket1 readmessage ] on: connectiontimedout do: [ nil ]. mes ifnotnil: [ transcript show: 'message received in client';cr . receivedfile := filestream newfilenamed: 'receivedfile3.avi'. receivedfile nextputall: mes. receivedfile close. ] ] repeat ] fork however, doesn't work files bigger ~500 megabytes, be

python - API Query results error "The request signature we calculated does not match the signature you provided" -

i doing ec2 api query , facing error "the request signature calculated not match signature provided." the fact have taken care of in ec2 documentation (signatureversion 2) still facing error , cant figure out problem. here details: 1) signin string: s="""get\n ec2.amazonaws.com\n /\n awsaccesskeyid=access_id&action=describesecuritygroups&signaturemethod=hmacsha256 &signatureversion=2&timestamp=2013-10-06t14%3a15%3a30&version=2013-08-15""" 2) python code generate signature: #!/bin/env python2.7 import hmac import hashlib import base64 s="""get\n ec2.amazonaws.com\n /\n awsaccesskeyid=acces_id&action=describesecuritygroups& signaturemethod=hmacsha256&signatureversion=2&timestamp=2013-10- 06t14%3a15%3a30&version=2013-08-15""" signature=base64.b64encode(hmac.new("secret_key_id", msg=s, digestmod=hashlib.sha256).digest()) print(signature) 3

openmpi - "mpirun was unable to launch the specified application as it could not find an executable" error -

i came across strage problem, worked doesn't. i run openmpi program tau profiling among 2 computers. seems mpirun can't run tau_exec program on remote host, maybe it's permission issue? cluster@master:~/software/mpi_in_30_source/test2$ mpirun -np 2 --hostfile hostfile -d tau_exec -v -t mpi,trace,profile ./hello.exe [master:19319] procdir: /tmp/openmpi-sessions-cluster@master_0/4568/0/0 [master:19319] jobdir: /tmp/openmpi-sessions-cluster@master_0/4568/0 [master:19319] top: openmpi-sessions-cluster@master_0 [master:19319] tmp: /tmp [slave2:06777] procdir: /tmp/openmpi-sessions-cluster@slave2_0/4568/0/1 [slave2:06777] jobdir: /tmp/openmpi-sessions-cluster@slave2_0/4568/0 [slave2:06777] top: openmpi-sessions-cluster@slave2_0 [slave2:06777] tmp: /tmp [master:19319] [[4568,0],0] node[0].name master daemon 0 arch ff000200 [master:19319] [[4568,0],0] node[1].name slave2 daemon 1 arch ff000200 [slave2:06777] [[4568,0],1] node[0].name master daemon 0 ar

tsql - Select IN on more than 2100 values -

how can select in on more 2100 values? <cfquery name="result.qrydata"> select sub_acct_no, ... dbo.closed_order ord_no in <cfqueryparam cfsqltype="cf_sql_varchar" value="#valuelist(qryord.ord_no)#" list="yes"> </cfquery> because of ways tables setup, linked servers , joins not option. when ran error thrown because there new many fields being passed in. first load values xml <cfset var strresult = '<ul class="xoxo">'> <cfloop query="qryord"> <cfset strresult &= '<li>#xmlformat(ord_no)#</li>'> </cfloop> <cfset strresult &= '</ul>'> then use xml in sql query <cfquery name="result.qrydata"> declare @xmlord_no xml = <cfqueryparam cfsqltype="cf_sql_varchar" value="#strresult#"> declare @tblord_no table (id varchar(20)) insert @tblo

express - npm install appname -g bash: command not found -

upon trying install express via npm, bash returning command not found statement upon running node module in shell directly. went through countless resources , forums locate issue , not succesfull. this seemed solution me. ran below statement , proceeded reinstall express sudo: chmod 777 /usr/local/lib sudo install express -g run both commands respectively.

c# - Set position and size of a ClickOnce application -

i know if there way set position , size of clickonce deployed application, started via process.start. normal (.exe) applications there no problem, can that: var externalappprocess = process.start("calc"); var externalappptr = externalappprocess.mainwindowhandle; and use invoked movewindow set stuff position, size etc. however, when i'm starting appref-ms file, runs without issues, can't access mainwindowhandle, says "process has exited, requested information not available". ideas? when launch *.appref-ms, rundll32 or dfshim process run. clickonce checking , starts executable of clickonce deployed application. so may try finding main window handle this: var processes = process.getprocessesbyname("clickoncedeployedapp"); foreach (process p in processes) { intptr windowhandle = p.mainwindowhandle; // }

C# Application that installs a c++ dll -

i made small 32 bit c# application installs c++ dll file resources folder on hd following c# code. file.writeallbytes(folder + @"\test.dll", properties.resources.testdll); it works expected when i'm using dll works partly , crashes, if replace dll installed 32 bit c# application dll hd i've added beginning c# project resources, works. why? because c# installation program 32 bit , installed dll through resources 64 bit dll?? someone knows how resources 32/64 bit works? regards, morgan

scala - Polymorphic Deserialization function using shapeless -

i'm trying write polymorphic deserialization function hlists/csv's using shapeless here definition value typeclass provides serialization/deserialization (i'm aware results should return , option/either/validation show failed parsing, come later) class value[t](val read: string => t, val write: t => string) object value { implicit object intvalue extends value[int](_.toint, _.tostring) implicit object stringvalue extends value[string](s => s, s => s) def apply[v: value] = implicitly[value[v]] } import value._ the following serialization function works great object serialize extends poly1 { implicit def casevalue[t: value] = at[t](value[t].write) } and im able map on hlist of types have supporting value[_] typeclass: def write[l <: hlist, la1 <: hlist](t: l)( implicit mapper: mapper.aux[writepoly.type, l, la1], lister: tolist[la1, string]): list[string] = t.map(writepoly).tolist here 2 different versions of deserializ

httprequest - Python 3.X Extract Source Code ONLY when page is done loading -

i submit query on web page. query takes several seconds before done. when done display html table information from. let's query takes maximum of 4 seconds load. while prefer data loaded, acceptable wait 4 seconds data table. the issue have when make urlread request, page hasn't finished loading yet. tried loading page, issuing sleep command, loading again, not work either. my code import urllib.request import time uf = urllib.request.urlopen(urlname) time.sleep(3) uf.decode('utf-8') text = uf.read() print (text) the webpage looking @ http://bookscouter.com/prices.php?isbn=9781111835811 (feel free ignore interesting textbook haha) and using python 3.x on raspberry pi the prices want not in page you're retrieving, no amount of waiting make them appear. instead, prices retrieved javascript in page after has loaded. urllib module not browser, won't run script you. you'll want figure out url ajax request (a quick @ source code gives pr

javascript - Finding how many times a capital letters precede a period -

i need count how many letters capital precede period. find each period , check character before see if capital. here code threw thought job. var s = 'washington d.c. nice place.'; var counter = 0; var totals = 0; var n = s.indexof(".",counter); var times = s.split('.').length; var l = n; while(counter != times){ n = s.indexof(".",l); if(s.substring(n-1,1) == s.substring(n-1,1).touppercase()) totals++; counter++; l = n; } //totals should 2 this worked me: var s = 'washington d.c. nice place.'; var foo = s.match(/[a-z]\./g,s); console.log(foo.length); jsfiddle example

php - visual basic regex mode/pattern modifier -

i ran trouble. i'm testing regex in php (not in asp.net app, long takes me while) $pattern = '~<table.*>(.*?)</table>~s'; i need convert line vb format. including 's' modifier (at end of regex) i doubt code covers need dim tableexpression = "<table.*>(.*?)</table>" many flavors give option of putting modifiers in regex itself, so: dim tableexpression = "(?s)<table.*>(.*?)</table>" (?s) called inline modifier , , can read here . works in of major languages, including .net , php. notable holdout javascript, incredibly frustrating because means can't case-insensitive matches in asp.net validator unless disable client-side validation.

html - Content not touching the sides of the screen -

i want have header in div, div isn't directly touching of page, there little bit of room on sides. why? , how can remove that? div just <div class="header"> <img src="images/header.png" width="600" height="252" alt="header" /> </div> and style.css file contains .header { background: url(../images/header_extend.png) repeat-x center; overflow: hidden; } .header img { display:block; margin:0px auto; max-width: 100%; height: auto; overflow: hidden; } the header_extend.png fill rest of screen width. you should remove default margin body tag. body { margin:0 } additionally, if want use percentage .header div's width, should specify parent's width well. in case parent body tag, can do: body { margin: 0; width: 100%; } here's fiddle

python - Django Social WrongBackend Error -

i pretty new django , noob django-social-auth. settings.py code (from installed app social_auth_config) : django_apps = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', ) thied_party_apps = ( #'south', 'captcha', 'social_auth', ) my_apps = ( 'account', 'dashboard', ) installed_apps = django_apps + thied_party_apps + my_apps #------------------------------------------------- social auth ------------------- login_url = 'account/login/' login_redirect_url = 'dashboard/' login_error_url = '/login/' authentication_backends = ( 'social_auth.backends.contrib.github.githubbackend', 'django.contrib.auth.backends.modelbackend

objective c - having trouble drawing a rectangle to the screen ios -

i following video tutorial pluralsight draws red rectangle screen. have subclass of uiview called psviewdemo has following code in .m file: // override drawrect: if perform custom drawing. // empty implementation adversely affects performance during animation. - (void)drawrect:(cgrect)rect { cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetfillcolor(context, [uicolor redcolor].cgcolor); cgcontextfillrect(context, cgrectmake(40, 400,100,200)); // drawing code } i call in viewdidload of viewcontroller view in application (until code adds subview). - (void)viewdidload { [super viewdidload]; psviewdemo *dv = [[psviewdemo alloc] initwithframe:cgrectmake( 0, 0, 320, 480)]; [self.view addsubview:dv]; // additional setup after loading view, typically nib. } the whole thing compiles , runs without error there no red rectangle on screen. what missing? pretty sure following tutorial maybe has changed in cocoa since tutorial made? i&#

jquery - I'm Having Problems Merging HTML and JavaScript -

i trying make mock webpage designed use html , javascript return cost of rental car given number of days. html portion of page works great, when press button calculate total, not anything. i've looked around internet in hopes of finding answer issue, no matter try doesn't seem want work. here html portion of code, working fine <form> name: <input type="text" name="name"><br> street address: <input type="text" name="street"> city: <input type="text" name="city"><br> state: <input type="text" name="state"> zip code: <input type="text" name="zip"><br> beginning odometer reading: <input type="text" name="odometerbegin"> ending odometer reading: <input type="text" name="odometerend"><br> days of use: <input type="number" name="days"> </fo

multithreading - Can the synchronized statements be re-ordered by Java compiler for optimization? -

Image
can synchronization statements reordered. i.e : can : synchronized(a) { synchronized(b) { ...... } } become : synchronized(b) { synchronized(a) { ...... } } can synchronization statements reordered? i assume asking if compiler can reorder synchronized blocks lock order happens in different order code. the answer no. synchronized block (and volatile field access) impose ordering restrictions on compiler. in case, cannot move monitor-enter before monitor-enter nor monitor-exit after monitor-exit. see grid below. to quote jsr 133 (java memory model) faq : it not possible, example, compiler move code before acquire or after release. when acquires , releases act on caches, using shorthand number of possible effects. doug lea's jsr-133 cookbook has grid shows reordering possibilities. blank entry in grid means reordering allowed. in case, entering synchronized block "monitorenter" (same reordering limi

xcode - Can I Create iOS Application for Clients Using Personal Apple Developer Account? -

sorry if stupid question, have been searching online , not finding exact answers question. i building newsstand applications myself , other people started own newsstand applications. have personal developer account , people help. my question is: possible me setup app in xcode, itunes connect & apple developer account , transfer app people want help? i not sure apple allows personal developer accounts? if it's allowed , possible, best practices this? there way "share" provisioning profiles, or people have setup themselves? ideally love setting up: apple id (developer account) profiles (developer account) newsstand app (itunes connect) in app purchases (itunes connect) if @ possible, love able publish client, think not possible personal developer accounts? sorry if newbie stuff, links documentation great! fine doing these things myself, lately people have been asking me out , it's getting little tricky me. thanks reading! yes. added under

jquery - KnockoutJs - data-bind not working on new element -

im done on binding , works great. im trying create element create via jquery. problem when created new element using jquery data-bind doesnt interact knockout. please me :( think should rebind ..... when click add button created jquery doesnt work :( this code: html user list:<br> <table> <thead><tr> <th>name</th><th>action</th> </tr></thead> <tbody class="user-list"> <tr> <td>anthony</td> <td><input type="button" data-bind="click: adduser" value="add"/></td> </tr> </tbody> </table> <input type="button" class="btnadd" value="add user"/> user block:<br> <table> <thead><tr> <th>username</th> </tr></thead> <tbody data-bind="foreach: users"> <tr>

EASy68K Assembly - first program errors -

i'm new assembly language, i'm having little trouble first program. supposed recreate following code, except in assembly language obviously. can me fix errors , me program work properly? think close. original non-assembly code: q = 7; p = 15; // test on p = 14 , p = 6 if (p > 12) p = 8 * p + 4; // requirement: use asl multiplied 8 else p = p - q; print p; here have far, i'm getting errors. i'll post errors @ bottom. start org $1000 //program starts @ loc $1000 if cmp #12,p //is p > 12? ble endif //if p < 12, go endif asl #3,p //shift left 3 times (multiply p * 8) add #4,p //p + 4 endif sub q,p //p - q * data section org $2000 //data starts @ loc 2000 p dc.w 15 //int p = 15; q dc.w 7 //int q = 7; end start line 4: error: invalid addressing mode line 7: error: invalid addressing mode i recommend keep m68000 programmer's reference m

php - DELETE mutiples table doesn't work -

$sql = "delete t1, t2, t3, t4, t5, t6, t7 bla1 t1, bla2 t2, bla3 t3, bla4 t4, bla5 t5, bla6 t6, bla7 t7 t1.id = t2.id , t2.id = t3.id , t3.id = t4.id , t4.id = t5.id , t5.id = t6.id , t6.id = t7.id , t1.id = {$_get["id"]}"; ok, i'll bite. you've got sql injection hole in code here: t1.id = {$_get["id"]}"; <<-- never inject php `get` sql! see answers question: how can prevent sql injection in php? if want webmaster, knowing sql-injection , xss 2 important things. learn 2 things , you'll have happy customers. back business: mysql delete have syntax error in delete statement. delete not follow same syntax select . select selects columns, delete works on rows, it's mix of metaphors mention columns in delete statement. see here correct syntax: http://dev.mysql.com/doc/refman/5.5/en/delete.html because did not explain in question intended do, i'll have guess. looks ty

In Makefile how do I build seperate executable for each C file -

i using check c unit tests. each c library file create there should 1 test file should generate single executable linked test , source code. executable should run make sure tests pass. when there 1 test file , 1 source file works great. add second source file corresponding test file, tries link them 1 executable. how second rule pull 1 test_src , matching src , header file test_obj compile 2 object files executable? below current makefile out_dir=bin build_dir=build test_build_dir=test_build src_dir=src test_src_dir=tests src= $(wildcard $(src_dir)/*.c) test_src= $(patsubst $(src_dir)/%.c, $(test_src_dir)/%_tests.c, $(src)) test_obj= $(patsubst $(test_src_dir)/%.c, $(test_build_dir)/%.o, $(test_src)) obj= $(patsubst $(src_dir)/%.c, $(build_dir)/%.o, $(src)) $(out_dir)/string_calculator_tests: $(test_obj) gcc -o $@ $^ `pkg-config --cflags --libs check` $(test_obj): $(test_src) $(src) gcc -c -o $@ $^ `pkg-config --cflags --libs check` any appreciated. it

nhibernate - SignalR and Hibernate -

i using signalr 2.0 live chat , notifications , using nhibernate (with fluentnhibernate) persistence. i building single page app , calls done using xhr , websocket signalr . problem is: written database through signalr not recognized nhibernate session. when full page refresh changes there suppose signalr 2.0 contains no httpcontext using when building nhibernate sessionfactory.

java - how to view pdf file in jsp -

i want view pdf file view dynamically in pop window using java.while clicking file link open pdf file pop window don't allow down load option please me give example in java.i need need java code using action jsp file f= new file(file); if(f.exists()){ servletoutputstream op= response.getoutputstream(); response.reset(); if(check==1){ response.setcontenttype("application/pdf"); }else{ response.setcontenttype(content); } // response.setheader("content-disposition","attachment; filename=" +filename); byte[] buf = new byte[4096]; int length; datainputstream in = new datainputstream(new fileinputstream(f)); while ((in != null) && ((length = in.read(buf)) != -1)){ op.write(buf,0,length); } in.close(); op.flush(); op.close(); } to open local file need use file scheme in url as path windows path e:/files/it/cat1/cat1notification.pdf, link's href needs file:/// added before jsp's <%=path%> variabl

algorithm - How can you simulate an array with two unbounded stacks and a small amount of memory? -

i going through past slides of 1 of courses being offered in university. here slide mentions question: http://www.cse.psu.edu/~asmith/courses/cse565/f10/www/lec-notes/cse565-f10-lec-03.pptx.pdf however, not sure if correctly understand question , clueless on solution. any pointers on problem , how think it? to simulate array need allow indexed lookup. insert: given 2 unbounded stacks, call them foo , bar, can keep inserting foo. lookup: when user tries lookup element, pop stack.size - index times bar. next pop give element user looking for. @ point can peek instead of pop because array not delete elements on lookup. now can either push elements onto foo bar or push rest of elements bar onto foo. in latter case, need reverse indexing. delete: to implement delete can mark element deleted. if user ever tries inserting element @ index can pop , push new element. whereas on lookup should return whatever represents empty index.

javascript - sorting object by keys (strings as numbers) -

i have data set in object, keys strings { '17': '17-17:30', '20': '20:00-21', '21': '21-22', '22': '22-23', '23': '23-24', '01': '1-2', '02': '2-3', '03': '3-4', '04': '4-5', '05': '5-6', '06': '6-7', '07': '7-7:30', '08': '08:50-9' } i want arrange them numerically 01 comes first , 23 comes last. here's code i'm using: var sort_object = function(map) { var keys = _.sortby(_.keys(map), function(a) { return number(a); }); var newmap = {}; _.each(keys, function(k) { newmap[k] = map[k]; }); return newmap; } it still returns 17 in beginning. did go wrong? as blender pointed out, objects not ordered. need use array. there several ways set array, , once have data in array it's easy

ios - cannot add parentContext to NSManagedObjectContext, context already has a coordinator -

i have view retrieve saved entity (route *) main nsmanagedobjectcontext . want import tempcontext . following marcus zarra's examples, this: nsmanagedobjectcontext *moc = _route.managedobjectcontext; nsmanagedobjectid *routeid = [_route objectid]; nspersistentstorecoordinator *psc = moc.persistentstorecoordinator; self.tempcontext = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsprivatequeueconcurrencytype]; [self.tempcontext setpersistentstorecoordinator:psc]; nsmanagedobject *localroute = [self.tempcontext objectwithid:routeid]; [localroute motodictionary:localroute]; self.tempcontext.parentcontext = moc; // crashes here everything until try set parentcontext of tempcontext main moc. error: terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'context has coordinator; cannot replace.' i understand it's telling me cannot change persistentstorecoordinator . i'm nto su

html - CSS first-child pseudo class with unordered list (Bootstrap) -

i trying render background color on list item first child of unordered list. html structure follows <div class="nav-collapse"> <ul class="nav"> <li><a href="#">test 1</a></li> <li><a href="#">test 2</a></li> <li><a href="#">test 3</a></li> </ul> </div> and apply background color on first child element did .nav-collapse > .nav:first-child { background-color: orange; } it renders orange background list items. i've played slight variations doesn't make difference. .nav-collapse > ul.nav:first-child .nav-collapse > ul:first-child here demo use following: .nav > li:first-child { background-color: orange; } working jsfiddle here you trying style first .nav item - there 1 of. change style first li direct child of .nav . if want more specific use: .nav-colla

networking - Is ICMP a transport layer protocol? -

i going through video lecture on networking , there lecturer mentions icmp transport layer protocol. however, googling shows various forums describing network layer protocol. has confused me lot. can clarify? transport layer protocols concerned send data end-to-end , ensuring (or explicitly not ensuring) reliability. tcp used send data 1 computer , includes logic necessary ensure data transported correctly, while udp used send data 1 computer while getting reliability. icmp doesn't this. job routers figure out shape of internet , direction send packets different protocols. consequently, it's considered network-layer protocol, since job ensure data routed right place doesn't route data. hope helps!

android - Couch DB replication - Sequence number in 'since' param is invalid -

we have android application uses couchbase mobile. application replicates couchdb on cloudant. we observed (when replication started taking more 6 minutes 'complete') 'since' parameter sent in 'changes' request no near source's sequence number. source's seq = 66000+ since param on 2nd , subsequent replication requests = 25000+ (it varies) we use filter, takes lot of time, , ok first replication. see future replications takes 6 minutes (even when there no updates @ source db). we suspect filtered replication target makes checkpoint last replicated doc , not source's commit sequence. is default behaviour? there way overcome feature/problem? [we in process of migrating couchdb lite, need fix before that]. regards, vijay

Search "Our" Use Full Text Search with Contains in SQL Server -

we use full text search , contains search between records in sql server 2008 r2, here samples: news(title): "we", "new", "our", "long-term", "seem", "non.active" so see in news table title field have values. can search of values except "long-term" , "non.active" , can not search words includes dash("-") or dot("."). check these tips: select * news contains(title, 'non.active'); select * news contains(title, 'non active'); select * news contains(title, 'nonactive'); select * news contains(title, 'non*'); select * news contains(title, 'active'); select * news contains(title, 'non'); select * news contains(title, '*active'); select * news contains(title, ' "non.active" '); select * news contains(title, ' "non active" '); select * news contains(title, ' "nonactive"

php - CakePHP Cache::clear does not work -

i have cache configuration in bootstrap.php file as cache::config('long', array( 'engine' => 'file', 'duration' => '+1 week', 'probability'=> 100, 'mask' => 0666, 'path' => cache . 'long' . ds, )); and trying clear cache when setting edited. below admin_edit function public function admin_edit($id = null) { if (!$this->setting->exists($id)) { throw new notfoundexception(__('invalid setting')); } if ($this->request->is('post') || $this->request->is('put')) { if ($this->setting->save($this->request->data)) { $this->session->setflash(__('the setting has been saved')); $this->redirect(array('action'=> 'index')); cache::clear(false,'long');

java - How to handle concurrent Maven builds on Jenkins? -

i use jenkins lot , lots of different jobs run on cluster. every , job fails obscure error , i've been able debug fact job using artifact x , job b has downloaded or built fresh version of (with maven). the job fails java.lang.noclassdeffounderror or else zip file being corrupt or segfault zip implementation java using. so obvious solution use private local maven repository jobs quite disk , internet expensive solution. mean each job's maven download whole internet. for cases eager loading of class files jar file corrupts helps limit damage don't want everything. any other solutions? sort of improved locking repository? yes, looks maven doesn't concurrent access single local repository (there issue opened recently, 7 years ago). creating repo each job quite massive. however, there variable $executor_number , maybe use create maven local repo per each jenkins executor.

c++ - managed dll in native code (via com) .is it in process or out process com server? -

i needed use managed dynamic linked library(c#) in native code(c++).i found solution here was. ( http://support.microsoft.com/kb/828736 ). but thing bothering me is.. 1) managed dynamic linked libraries used in native code through com act in process com servers ? . if yes how can be? 2)if no, how can dynamic linked library act out process com server without being carried executable . this in-proc configuration. it's not more "impossible" using p/invoke mechanism directly. when run regasm makes necessary changes registry when client calls cocreateinstance() com knows needs p/invoke functions corresponding .net assembly.

ubuntu - Linux: /var/log/syslog segfault message format? What does each parameter means? -

this question has answer here: how read segfault kernel log message 3 answers as per question title, each paramter stands for, in /var/log/syslog segfault messagae ? for example, got error message in /var/log/syslog file : sep 17 03:57:23 localhost kernel: [ 99.032748] iaccessremotesc[1413]: segfault @ 11 ip 0804ca94 sp bfaf6d90 error 4 in iaccessremotescreen[8048000+a000] where : sep 17 03:57:23 ==> timestamp localhost kernel ==> log host ip ==> instruction pointer sp ==> stack pointer what other parameter stands ? [ 99.032748] ==> ? iaccessremotesc ==> ? [1413] ==> ? segfault ==> 11 ==> 0804ca94 ==> bfaf6d90 ==> error 4 ==> iaccessremotescreen[8048000+a000] ==> ? [8048000+a000] ==> ? is there standard protocol syslog ? i need detail description each paramter. can suggest me link or manual

c++ - DirectX using multiple Render Targets as input to each other -

i have simple directx 11 framework setup want use various 2d simulations. trying implement 2d wave equation on gpu. requires keep grid state of simulation @ 2 previous timesteps in order compute new one. how went - have class called framebuffer, has following public methods: bool initialize(d3dgraphicsobject* graphicsobject, int width, int height); void beginrender(float clearred, float cleargreen, float clearblue, float clearalpha) const; void endrender() const; // return pointer underlying texture resource const id3d11shaderresourceview* gettextureresource() const; in main draw loop have array of 3 of these buffers. every loop use textures previous 2 buffers inputs next frame buffer , draw user input change simulation state. draw result. int nextstep = simstep+1; if (nextstep > 2) nextstep = 0; mframearray[nextstep]->beginrender(0.0f,0.0f,0.0f,1.0f); { mgraphicsobj->setzbufferstate(false); mquad->getrenderer()->ren

c# - Searching Country by Country code -

i working on search method, called ajax, , updates webgrid in mvc4. search go through list of project objects, contains fields. one of fields country. , right code checks if input string contains search string: private bool stringstartwith(string input, string searchstring) { bool startwith = false; var inputlist = new list<string>(input.tolower().split(' ').distinct()); var searchlist = new list<string>(searchstring.tolower().split(' ')); var count = (from inp in inputlist sear in searchlist inp.startswith(sear) select inp).count(); if (count == searchlist.count) startwith = true; return startwith; } but want able search country code. if write "dk", should tell equal denmark. i hope can it. thanks. //update!! iturtev answer helped me make method work should. had update method shown here: private bool inputstartwithsearch(string input, string searchstring) { if(searchstring[sea

testing mobile apps at home (IIS hosted) -

i not sure current problem , appreciate suggestions. basically, want locally host web application on iis , access mobile browser. my web application hosted on local iis , works fine on main machine. can use computer name, internal ip or external ip instead of localhost connect app main computer. when go computer (which can see , exchange files with) connected same network cannot access web application on main machine. tried ip , machine name. at work, connected domain , tried same thing work computer. when write computer name or it's ip, can access hosted app computer. so question is, have have domain capability , if so, possible create local domain @ home network? need search working? wamp must? apparently opening outbound/inbound port 80 windows firewall enough