Posts

Using 'OR' and 'AND' in SQL Server -

is using ( condition or condition b , condition c ) the same as ( condition , condition c) or (condition b , condition c) no. first condition is: (condition a) or (condition b , condition c) and second is: (condition , condition c) or (condition b , condition c) you can see difference between them.

Update existing design of a website, use of CSS -

i'd opinions if plan worthwhile or not. have existing site, , elements have css class defined. thought append each element has class new class: <div class="existingclass"> would turn into: <div class="existingclass newclass"> then, if want override attributes in "existingclass", in "newclass" (because last class attributes taken?). figure way, nothing break, not risk because not removing "existingclass". any problems plan? first know in existingclass . write newclass in such manner won't break layout. knowing in existingclass use tools firebug save time.

node.js - Sanitizing data before saving to Mongoose -

i trying create pre handler sanitizes data before written mongodb see: http://mongoosejs.com/docs/middleware.html i've tried following each property able sanitize it: blogschema.pre('save', function (next) { var obj = this; console.log(obj)//-> https://gist.github.com/daslicht/70e0501acd6c345df8c2 // i've tried following single items : object.keys(obj).foreach(function (key) { console.log('keys: ',obj[key]); }); //and: for(var key in obj) { console.log(obj[key]) } //and: _.each( self , function(value, key, list){ console.log('value:',key); }) next(); }) any of above approaches results following: thats output of: for(var key in obj) { console.log(obj[key]) } https://gist.github.com/daslicht/cb855f53d86062570a96 any know how each single property can sanitize it, please? ~marc [ed...

select - MySql variable sequential calculation with group by do not work properly -

a table following , query give desired result. select col1, col2, col3, @a:=@a+(col2+col3) col4 test join (select @a:=0)t col1 | col2 | col3 | col4 ------------------------- | 1 | 1 | 2 b | 2 | 0 | 4 c | 3 | 0 | 7 | 0 | 2 | 9 but when use group not work properly. have solution? select col1, sum(col2)col2, sum(col3)col3, @a:=@a+sum(col2+col3) col4 test join (select @a:= 0)t group col1 col1 | col2 | col3 | col4 ------------------------- | 1 | 3 | 4 b | 2 | 0 | 2 << 6 c | 3 | 0 | 3 << 9 first row fetched correctly. row2 , row3 did not calculate previous row col4 value previous example. can not understand problem! try code, worked me :) select col1, col2,col3, @a:=@a+(col2+col3) col4 (select col1,sum(col2)col2,sum(col3)col3 test group col1) tes join (select @a:= 0)t i made fiddle : http://sqlfiddle.com/#!2/9b3ac/44 hope helps ;)

php - Not having any luck with preg_match -

im trying parse url last 2 / sections. need address (can that) , number(second section {ie:08078612,08248595} unless @ last , no address present {last url list example} {ie: 8274180}) optionally need last 3 digits of second numbers section.{ie 612,595,180} im not having luck heres code far. $url_list[] = $url; if(preg_match("/[0-9]/",substr(strrchr($url, '/'), 1))) { $url_list_mls[]= substr(strrchr($url, '/'), 2); $url_list_mls_last3[] = substr(strrchr($url, '/'), -3); } else { $url_list_mls[]= substr(strrchr($url, '/'), 1); $url_list_mls_last3[] = substr(strrchr($url, '/'), -3); } $url_list_addy[]= substr(strrchr($url, '/'), 1); example urls (part of full url endings examples) /a019/08078612/214-n-crest-avenue /a019/08248595/111-n-elroy-avenue /a019/8274180 im trying make 3 lists, address (last section) number (second section) , last 3 numbers of second section number. the original code...

visual studio - TFS will not accept changes I've made to a Java project -

i using tfs's team explorer manage visual studio projects. recently, i've created new java project (not in visual studio) manually added tfs using source control control explorer in visual studio. after added java project tfs, made changes , bug fixes. then, went visual studio , opened source control explorer check in changes, tfs thinks no changes made. it seems needed check out project before making changes. guess erroneously expected tfs track automatically, okay. so, using source control explorer in tfs, checked out project, , tried check in pending changes. when tried check in, got following message: all of changes either unmodified files or locks. changes have been undone server. is there way convince server indeed project has changed? how can check in changes have made? thank help.

java - How to Configure JAXRS and Spring With Annotations -

i working on little spring web service project. here example route: package com.example.api; import javax.ws.rs.get; import javax.ws.rs.path; import javax.ws.rs.produces; import javax.ws.rs.pathparam; import javax.ws.rs.ext.provider; import javax.ws.rs.core.mediatype; @provider public class webserviceroutes { @get @path("/hello") public string health() { return "hello"; } } then in spring configuration class: package com.example.api; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration; @configuration public class springcontextconfiguration { @bean( destroymethod = "shutdown" ) public springbus cxf() { return new springbus(); } @bean public webserviceroutes webserviceroutes() { return new webserviceroutes(); } } and in web.xml: <?xml version="1.0" encoding="utf-8"?> <web-app version=...

php - How can I print all values in group option? -

i couldn't find. i've read , done of these: http://docs.mongodb.org/manual/reference/aggregation/ , these: http://php.net/manual/en/mongocollection.aggregate.php but couldn't make happen. i'm trying learn, complicated. mongodb complicated. this code: $hg = $collection_iddaa->aggregate(array( array('$project'=> array( 'lig_adi'=>1, 'ulke_adi'=>1, 'ulke_kisa'=>1, 'hometeam'=>1, 'awayteam'=>1, 'homegol'=>1, 'awaygol'=>1, 'baslangic'=>1, 'status'=>1, 'ptime'=>1 ) ), array( '$group' => array( '_id' => array('lig_adi'=>'$lig_adi', 'ulke_adi'=>'$ulke_adi'), "ulke_kisa" => array('$addtoset' => ...

c - Strange behavior after fseek() has worked -

Image
i've came across strange behavior. while debugging, when while -loop loops @ first time: after going though /* "data-url" */ , /* "data-author" */ parts of code have next result in debugging windows -> watches : (i'm using code::blocks ide, ubuntu 13.04) the length of dataurl_tempstring 8 bytes, length of dataauthor_tempstring 11 bytes, length of dataname_tempstring 9 bytes... but after going through /* data-name */ part of code have the result confuses me: now not of size 8, 11 , 9 bytes! what matter? could me finding reason of such behavior? here code of function: int substring_search(char *fnamenew, char *strurl, char *strauthor, char *strname) { file *fp; file *ofp_erase; file *ofp; char ch_buf; int count = 0; char dataurl[8] = ""; char dataauthor[11] = ""; char dataname[9] = ""; char *dataurl_tempstring = &dataurl[0]; char *dataauthor_temp...

Google Chrome Extension not working in canary 31.0.1605.1 canary aura -

i looked on getting started: building chrome extension page, , couldn't one-click kittens extension work on version of canary (31.0.1605.1 canary aura). if right click on , click on "inspect popup", extension shows developer window, won't work if click on it. it works in chrome dev version 30.0.1568.2, though. i downloaded files website. is problem code, google chrome canary, or else? thanks.

graph - Bell chart with PHP -

i looking way create bell curve in php. have tried jpgraph, , lined scatter graph, have no idea how align bell curve. honestly i've never used bell curve , i've got make 1 takes 3 inputs charity organization, have no idea how work, appreciated. i have quite understanding of php , if possibly paste code, find way understand it. simple bell curve for ($x = -m_pi; $x <= m_pi; $x += (m_pi / 20)) { echo sprintf('%+01.2f => %01.8f' . php_eol, $x, (cos($x) + 1) / 2); } but please explain 3 inputs: expected gaussian curve, mean, standard deviation , x value. bell curve special case of gaussian mean of 0 , standard deviation of 1, x value variable.

.htaccess - htaccess non www to www and remove subdomain www -

so i've got following rewrite code in htaccess rewriteengine on rewritecond %{http_host} ^[^.]+\.[^.]+$ rewriterule ^(.*)$ http://www.%{http_host}/$1 [l,r=301] // rewriteengine on rewritecond %{http_host} ^www\.([^\.]*)\.domain\.com$ [nc] rewriterule (.*) http://%1.domain.com$1 [r=301,l] works perfect redirecting non-www www domains. i've got subdomain, lets call ' sub.domain.com ' works find. if goto www.sub.domain.com , redirecting ' sub.domain.com/sub/ ' having idea why? none of rules have in question routes requests subdomain's folder. /sub/ should never there if wasn't in request. that said, of redirect rules need come before routing rules. routing rules being stuff internally routes requests other uri's, example: rewritecond %{http_host} ([^\.]*)\.domain\.com$ [nc] rewriterule (.*) /%1/$1 [l] that rule internall routes folder named same thing subdomain. if rule before redirect, both rules applied , redirected uri be...

Move cursor to specific point on screen using ncurses c++ (Linux) -

i'd move cursor specific point on screen, can move logical point, cursor stay static on position. how work in c++ using ncurses ? obs.: i've tried use move(y, x); doesn't works from move(y,x) man page : this routine not move physical cursor of terminal until refresh called. did call refresh() after calling move(y,x)

python - Searching string for different substrings -

i have string. need know if of following substrings appear in string. so, if have: thing_name = "visa assessments" i've been doing searches with: any((_ in thing_name _ in ['assessments','kilobyte','international'])) i'm going through long list of thing_name items, , don't need filter, exactly, check number of substrings. is best way this? feels wrong, can't think of more efficient way pull off. you can try re.search see if faster. along lines of import re pattern = re.compile('|'.join(['assessments','kilobyte','international'])) ismatch = (pattern.search(thing_name) != none)

php - Sort Multidimensional array by a defined order -

this question has answer here: how can sort arrays , data in php? 7 answers i have example array, , sort each first level item ( 66000 , 66001 , 66002 ) in order: new store first in list, store relocation second in list, , didn't include underperforming stores in example array, last. need sorted open date how can sort them way? i believe need use usort accomplish this, don't understand usort function, can this? here function far... usort($mainpgarr, function($a, $b){ }); example original array: array( [66000] => array( [january] => array( [status] => new store [sales] => 100.00 [open] => 2013-05-01 ) [february] => array( [status] => new store [sales] => 200.00 [open] => 2013-05-01 ) [march] => array...

localization - Translate open graph Facebook API with gender variations -

i'm trying translate custom open graph action. the problem in portuguese variation in sentence according "gender" of object in question. looked in documentation , saw can translate differently according "gender", did not find how tell gender of object facebook. i tried in various ways, creating field in object, sending information without field, none of ways facebook api identified, entering condition if gender had not been informed, know how solve question? i had same problem translating "male" or "female" value native language. solution this: var getfacebookdata = function(){ fb.api('/me?fields=gender,',function(response){ if (response.gender === 'male'){ var genero = 'hombre'; // change "male" value other } else { // "female" value other var genero = 'mujer'; }; $('#some_div_id').text('sexo: '+ genero); })}; i hope helps, greetings. ...

asp.net mvc 4 - HTML.ActionLink querystring param not passed to method -

examining code, don't see why fails. primary controller's index method looks this: public actionresult index(int appeventid = -1) there isn't querystring param, there's need route main page , pass particular id auto-display. default value of -1 indicates should display normally. works fine normally. in page, razor code generates valid hyperlink: @html.actionlink("back main", "index", "maincontroller", new { appeventid = -9 }, new { }) // things renamed protect innocent! when testing locally works charm. controller index method detects -9 particular value , specific case. however, when deployed on web server, application in subfolder, not root. works fine, in above case, generates url this: http://server/appsubfolder/?appeventid=-9 and above url looks correct, controller's index method not passed -9. is there limitation mvc app cannot deployed subfolder? i'm not 1 decided deploy way, i'm trying make sens...

vb.net - Common class to few forms -

i find nice code making form semi transparent while moving. have multiproject solution 1 project common other , compiles dll referenced projects. code making form semitransparent needed few forms in every project not forms. i have problem on , how use code used forms. code: imports system.componentmodel public class clstransform inherits system.windows.forms.form private _opacityresize double = 0.5 private _opacitymove double = 0.5 private _opacityoriginal double private const wm_nclbuttondown long = &ha1 private const wm_nclbuttonup long = &ha0 private const wm_moving long = &h216 private const wm_size long = &h5 protected overrides sub defwndproc(byref m system.windows.forms.message) static lbuttondown boolean if clng(m.msg) = wm_nclbuttondown lbuttondown = true elseif clng(m.msg) = wm_nclbuttonup lbuttondown = false end if if lbuttondown if clng(m.msg) = wm_moving if me.opacity <> _opacitymove...

php - Laravel4 duplicate / copy table row -

i'm sure there has quicker way following. wasn't able find how save laravel modal object new row without overwriting existing item. essentially, simpler of existing code: $olditem = item::find(1); $newitem = new item; $newitem->key = $olditem ->key; $newitem->name = $olditem ->name; $newitem->path = $olditem ->path; $newitem->save(); instead, copying id of row: $olditem = item::find(1); $newitem = $olditem; unset($newitem->id); $newitem->save(); you can try $newitem = item::find(1)->replicate()->save();

Encrypt data block with C/C++, platform independent -

say, if have byte array of various length , pass-phrase, quickest way encrypt in platform-independent way? ps. can make sha1 digest on pass-phrase how apply byte array -- doing simple repeated xor makes obvious. ps2. sorry, crypto guys, if i"m asking obvious stuff... a hash (like sha1) create one-way result, cannot decrypt hash. xoring data not secure means, don't that. if need able decrypt data, suggest using twofish uses symmetric key block cipher , not restricted licensing or patents (thus can find platform independent reference code).