Posts

Showing posts from June, 2012

iphone - how to check key available or not in json response in ios -

after request server , recieve 2 different type of response if success response this [{"id":5,"is_default":0,"name":"dutch","language_id":3},{"id":4,"is_default":1,"name":"french","language_id":2}] other response type {"status":102,"response":"empty record list."} is way detect whether "status" key available or not in response in objc. thanks found solution //break result tag if([[responsestring jsonvalue] iskindofclass:[nsdictionary class]]){ nsdictionary *dict = [responsestring jsonfragmentvalue]; if([dict count]==2){ return; } //nothing load } the response dictionary, see if have key looking can use nsdictionary methods: // assume have created dictionary, jsonresponse, json // first, keys in response nsarray *responsekeys = [jsonresponse allkeys]; // see if array contains key looki

excel - Function without return doesn't work -

i have macro calls function: function escreve_mapa(row integer, lastcolumn integer, equipamentos interger, abrangencia string, medias) dim cell range dim colunas range dim integer sheets("mapa de sinais (tabela)").select cells(row, "a").value = abrangencia cells(row, "b").value = equipamentos set cell = range("c" & row) set colunas = range(cell, cell.offset(0, lastcolumn - 3)) = 0 each cell in colunas if medias(i, 1) > 0 cell.value = round(medias(i, 0) / medias(i, 1), 2) end if = + 1 next cell end function but when gets function returns error user-defined type not defined any idea why? you've got typo in functions (although doesn't return sub) arguments. equipamentos interger should equipamentos integer

javascript - Jquery Text editor issue -

the following code of page want use jquery text editor (jqte). however, after trying nothing seems working. have included required files in same folder aspx page.the jquery reference included on masterpage. <%@ page title="" language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codefile="articleview.aspx.cs" inherits="articles_articleview" %> <asp:content id="content1" contentplaceholderid="head" runat="server"> <link href="jquery-te-1.3.6.css" rel="stylesheet" type="text/css" /> <script src="jquery-te-1.3.6.min.js" type="text/javascript"></script> </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <div></div> <div> <textarea class="jqte-test" na

PHP sessions getting unset -

i'm using session variable store login data. locally, works smooth, logs in nicely , doesn't log out inbetween pages. but when put same files on server, reason logged out. i've found this post, , tried using following code prevent caching of dynamic pages: header("cache-control: no-cache, must-revalidate"); header("expires: sat, 26 jul 1997 05:00:00 gmt"); // date in past though doesn't seem work. there other possible solutions problem? edit: note session_start() on every page. edit 2: did little further investigation , appears of links link www.mysite.com when on mysite.com . going new page makes $_session[] vars aren't set, , when returning previous page button can see $_session[] still set. sessions use cookies, when change domains (www.site.com site.com) cookies aren't being transmitted. set webserver have 1 canonical url, , redirect (for example, standardize on site.com, redirect www.site.com site.com).

listview - Android on Long Click is not working properly - custom list -

my custom listview not working properly. works fine till didnt scroll end, scroll end onclick feature stop working, m using custom list extending base adapter.. i have set click listener on toogle , it, have set focusable false in custom row. but thing noticed whenever list stop taking clicks, following error generated in logs. 05-18 17:54:02.674: w/keycharactermap(4343): can't open keycharmap file 05-18 17:54:02.674: w/keycharactermap(4343): error loading keycharmap file '/system/usr/keychars/cy8c-touchscreen.kcm.bin'. hw.keyboards.65537.devname='cy8c-touchscreen' 05-18 17:54:02.674: i/keycharactermap(4343): using default keymap: /system/usr/keychars/qwerty.kcm.bin list view <listview android:id="@+id/main_list" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margintop="3dp" android:cachecolorhint="#00000000" android:clickable=

logging - Python logger not respecting setLevel? -

i've spent bit of time looking through site @ python logger questions hoping resolved there. i've set logger 2 stream handlers have both different formats , levels of logging, here's functional snippet codebase: import os import time import logging log_levels = [logging.error, logging.warning, logging.info, logging.debug] test_result_levelv_num = 51 # http://stackoverflow.com/a/11784984/196832 def status(self, message, *args, **kws): self._log(test_result_levelv_num, message, args, **kws) logging.addlevelname(test_result_levelv_num, "result") logging.logger.result = status def setup_logging(level=0, quiet=false, logdir=none): logger = logging.getlogger('juju-test') ffmt = logging.formatter('%(asctime)s %(name)s %(levelname)-8s: %(message)s') cfmt = logging.formatter('%(name)s %(levelname)s: %(message)s') #logger.setlevel(0) if level >= len(log_levels): level = len(log_levels) - 1 if logdir

plugins - How to dynamically hide/remove some menus from navigation? -

i'm working on wordpress plugin inserts pages using wp_insert_post() on activation. these pages used different purposes (user account dashboard, edit account info, change password, login, logout, etc...). issue these pages menus displayed frontend users not correct because non logged-in user example should not see logout menu or menu private page until authenticated. now, i'm stucked @ how that. idea ? i stress plugin login process seperated wp login wordpress can not assign restrictions , roles specific pages, posts or terms default. you create two separated menues , add custom logic template. if(is_user_logged_in()) { wp_nav_menu('foo'); } else { wp_nav_menu('bar'); }

java - connecting to jvm -

i want access jvm heap iterate on objects. found following example of how done. use jdk1.7.0_11 . i tried following code: public static void main(string[] args) { runtimemxbean runtimebean = managementfactory.getruntimemxbean(); system.out.println(runtimebean.getvmname()); system.out.println(runtimebean.getvmvendor()); system.out.println(runtimebean.getvmversion()); string jvmname = runtimebean.getname(); bugspotagent agent = new bugspotagent(); agent.attach(integer.parseint(jvmname.split("@")[0])); // exception here!!!! vm.initialize(null, false); vm vm = vm.getvm(); system.out.println(vm.getvminternalinfo()); objectheap heap = vm.getobjectheap(); heap.iterate(new customheapvisitor()); } there following output: java hotspot(tm) 64-bit server vm oracle corporation 23.6-b04 and exception: exception in thread "main" sun.jvm.hotspot.debugger.debuggerexception: windbg error: attachprocess failed!

c++ - Hash set function for hashing -

i trying implement hash set have trouble hash function. want add in set, persons have name , phone number: class person{ string name; long long int phonenumber; } and indexes in set calculated summing digits of phonenumber. problem dont want functions this: int add(long long int nr, element e) - function adds element set { int hashcode = hash(nr);; ... } where long long int nr should phonenumber , element e should person. mean, it's pretty stupid. if have person parameter, why have it's phonenumber too? can see using templates, , teacher advised me virtual class hashfunction force respective type(something hashset in java). thing have no idea how that. have ideas me? if : int add(person p, element e) you restrict hastset class dependent on person class. taking integer or string value hash method more plausible in way. can determine parameter hash outside hash method , give input. moreover, when add member person class age , use i

AngularJS: ng-show / ng-hide -

i trying show / hide html using ng-show , ng-hide functions provided angularjs . according documentation, respective usage these functions follows: nghide – {expression} - if expression truthy element shown or hidden respectively. ngshow – {expression} - if expression truthy element shown or hidden respectively. this works following usecase: <p ng-hide="true">i'm hidden</p> <p ng-show="true">i'm shown</p> however, should use parameter object expression ng-hide , ng-show given correct true / false value values not treated boolean return false : source <p ng-hide="{{foo.bar}}">i shown, or hidden</p> <p ng-show="{{foo.bar}}">i shown, or hidden</p> result <p ng-hide="true">i should hidden i'm shown</p> <p ng-show="true">i should shown i'm hidden</p> this either bug or not doing correctly. i cannot find relat

php - why wordpress form not passing values to the result page -

when submit form values not passing action url instead shows result in search page .my form action url mysitename/showresults when submit form in url shows mysitename/showresults value in template not echoing instead shows results search.php file. in advance form ; area onlywithin ¼ mile age 3 4 5

xml - Loop selection with increment using XSLT -

i facing following issue: if have following xml data: <input> <error> <info> <code> 111 </code> <value>hello user </value> </info> <info> <code>118</code> <value>01</value> </info> </error> <error> <info> <code> 111 </code> <value>bye user </value> </info> <info> <code>118</code> <value>01</value> </info> </error> <error> <info> <code> 111 </code> <value>dead user </value> </info> <info> <code>118</code> <value>06</value> </info> </error> <error> <info> <code> 111 </code> <value>killed user </value> </info> <inf

c# - Why does a link is clicked when test is run in Selenium IDE, but it is not clicked when the test is run by nunit.exe? -

i have following selenium test: open /dealerproducts.preprod/mainpage.aspx type id=uctopbar_aspxroundpanel2_uclogin_cblogin_pnl_txtloginemail_i tester@gmail.com type id=uctopbar_aspxroundpanel2_uclogin_cblogin_pnl_txtpwd_i pass123 clickandwait css=#uctopbar_aspxroundpanel2_uclogin_cblogin_pnl_btnlogin_cd > span click link=search contract selectframe id=contentplaceholder1_tabpages_frcontent1 pause 1000 click id=grdlist_header2_colfilter_2_txtvalue1_2 type id=grdlist_header2_colfilter_2_txtvalue1_2 pm10000130 click css=span click id=grdlist_cell0_2_lnknumber_0 when run test in selenium ide last link (id=grdlist_cell0_2_lnknumber_0) clicked. when following test (which above test exported c#) run nunit.exe last link isn't clicked: [testfixture] public class elancetestwebdriver { private iwebdriver driver; private stringbuilder verificationerrors; private string baseurl; private bool acceptnextalert =

php - form is sending variables by get method -

i got form. <form id="site-contact-form"> <div> <div class="wrapper"><span>Ձեր անունը:</span> <div class="bg"> <div> <input type="text" class="input" name="contactname" id="contactname" /> </div> </div> </div> <div class="wrapper"><span>Ձեր e-mail-ը:</span> <div class="bg"> <div> <input type="text" class="input" name="email" id="email" /> </div> </div> </div>

loops - Jquery each return only first found element -

var x = $(".tabulardata tr").each(function(){ if($(this).hasclass("even")||$(this).hasclass("odd")){ return first found element, weather or odd current code returning elements //return $(this); } }); return $(this) return elements even|odd whereas need return first found element. if 'm not misunderstanding intent, can more with var $x = $(".tabulardata tr").filter(".odd, .even").first(); however, need "odd or even" test? since every row either odd or even, sounds simpler do var $x = $(".tabulardata tr:first");

java - Change bit depth from Bitmap -

Image
so have image 32 bit depth, when make blob sqlite database, , read out again following code has 24 bit depth (the quality lower, want same quality). how 32 bit depth? : databasehandler db = new databasehandler(camera.this); list<database> contacts = db.getallcontacts(); (database contact : contacts) { bitmapfactory.options bmpfactoryoptions = new bitmapfactory.options(); bmpfactoryoptions.inpreferredconfig = bitmap.config.argb_8888; //bmpfactoryoptions.inscaled = false; bmpfactoryoptions.outheight = 240; bmpfactoryoptions.outwidth = 320; // decodes blob bitmap byte[] blob = contact.getmp(); bytearrayinputstream inputstream = new bytearrayinputstream(blob); bitmap bitmap = bitmapfactory.decodestream(inputstream); bitmap scalen = bitmap.createscaledbitmap(

c# - SQL to LINQ Query with date in where clause is not working -

i try query database item via linq not working. exception just: object reference not set instance of object. the stacktrace unhelpful exception itself: at sqlite.tablequery 1.compileexpr(expression expr, list 1 queryargs) in d:\xx\xx\xx\xx\xx\sqlite.cs:line 2383 @ sqlite.tablequery 1.compileexpr(expression expr, list 1 queryargs) in d:\xx\xx\xx\xx\xx\sqlite.cs:line 2388 @ sqlite.tablequery 1.compileexpr(expression expr, list 1 queryargs) in d:\xx\xx\xx\xx\xx\sqlite.cs:line 2308 @ sqlite.tablequery 1.compileexpr(expression expr, list 1 queryargs) in d:\xx\xx\xx\xx\xx\sqlite.cs:line 2308 @ sqlite.tablequery 1.compileexpr(expression expr, list 1 queryargs) in d:\xx\xx\xx\xx\xx\sqlite.cs:line 2308 @ sqlite.tablequery 1.generatecommand(string selectionlist) in d:\xx\xx\xx\xx\xx\sqlite.cs:line 2274 @ sqlite.tablequery 1.getenumerator() in d:\xx\xx\xx\xx\xx\sqlite.cs:line 2521 @ system.collections.generic.list 1..ctor(ienumerab

jQuery-tokeninput not showing my search results -

i using jquery-tokeninput , not able work, ajax call not entering success method when result contains list of results. i use jquery version 1.9.1 , tokeninput version 1.6.1 i using html, , jquery script: <input type="text" class="selector" name="users"> $('.selector').tokeninput("/event/usersearch", { method: 'post', minchars: 2 }); when test following response: click on edit field provide focus. a dropdown shown text "type in search term" press letter u. the dropdown disappears expected set search after chars press letter p. the dropdown comes text "searching..." a request sent server query string "up" the server respond (content-type: application/json;charset=utf-8)(55 bytes): [{id:2, name:'superuser'},{id:3, name:'bo superduper'}] but dropdown still showing "searching..." press letter x a request set server query string &quo

How to export my sqlite database to csv in android? -

i export sqlite database csv in android. tried importing opencsv.jar didn't work out. issue due adt version 17 upgrade. there other way convert sqlite database csv in android. please me example. tried example this answer provides pretty code start exporting sqlite csv , sending email attachment. the first few columns hardcoded users data you'll have change own data but, core of need there.

range - Idiomatic Nested looping in racket/scheme -

has got idea idiomatic method nested looping on numbers within range in racket/scheme? in python have: for in range(numb1): j in range(numb2): what equivalent in racket/scheme? in racket it's simple this, using iterations , comprehensions : (for* ([i (in-range numb1)] [j (in-range numb2)]) <body of iteration>) the above work in racket. comparison, following snippets work in standard rxrs interpreter - instance, using pair of nested do : (do ((i 0 (+ 1))) ((= numb1)) (do ((j 0 (+ j 1))) ((= j numb2)) <body of iteration>)) yet option: using explicit recursion , named let : (let loop1 ((i 0)) (cond ((< numb1) (let loop2 ((j 0)) (cond ((< j numb2) <body of iteration> (loop2 (+ j 1))))) (loop1 (+ 1))))) finally, can following, refer sicp under section "nested mappings" details: (define (range start stop) (let loop ((i (- stop 1))

javascript - Can't get AJAX script to work -

i have table has list of transactions , trying update table contents @ set intervals. running page on linux red hat server. ajax not working right now. <!doctype html> <html> <head> <script> function updatetrans() { var xmlhttp; if (window.xmlhttprequest) { xmlhttp = new xmlhttprequest(); } else { xmlhttp = new activexobject("microsoft.http"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("transactions").innerhtml = xmlhttp.responsetext; } } xmlhttp.open("get", "update_trans.txt", true); xmlhttp.send(); } window.setinterval(updatetrans(), 4000);

objective c - Hide an application on launch when invoked using NSTask -

i'm launching application using nstask , using nspipe it's stdout , stderr. i'd hide (the gui) on launch, app commands , exits. can't use nsworkspace since need stdout/stderr. know of way achieve this? nsrunningapplication hand object representing app if have process id: +[nsrunningapplication runningapplicationwithprocessidentifier:] , should able obtain -[nstask processidentifier] . then can send hide nsrunningapplication instance.

symfony - Many to Many Relationship Setter -

i have many many relationship between entities: purchaseorder , supplier . when want add supplier order in symfony project, error message: property "suppliers" not public in class "acme\appbundle\entity\purchaseorder". maybe should create method "setsuppliers()"? when make setsuppliers() function myself in purchaseorder entity: public function setsuppliers(\acme\appbundle\entity\supplier $suppliers ) { $this->suppliers = $suppliers; return $this; } i error message: catchable fatal error: argument 1 passed doctrine\common\collections\arraycollection::__construct() must of type array, object given, called in /var/www/symfony/vendor/doctrine/orm/lib/doctrine/orm/unitofwork.php on line 519 , defined in /var/www/symfony/vendor/doctrine/collections/lib/doctrine/common/collections/arraycollection.php line 47 any ideas? /** * @route("order/{id}/supplieradd", name="order_supplieradd") *

CSS Layout CSS and HTML -

i trying create simple page (only using html , css) having difficulty elements: have attached links here want achieve , have done. question is: 1. how can put pink background overlap text , images? i tried in css: #setbackground { position:absolute; left:0px; top:0px; z-index:-1; } and in html: <div id="setbackground"> <img src="/images/pinkbg.png" alt="background"/> </div> but still didnt work. i know not fancy if give me suggestions appreciated. thanks. the pink not overlap underneath when place transparent things on top of it, can see pink underneath. in case set pink color require background-color: rgb(245,195,195); here example of how layout background: http://jsfiddle.net/eahqw/6/ all of additional content go inside 2 div's , placed on top giving them desired pink background. i went , made more complete example. http://jsfiddle.net/gewyj/2/ you'll see cheated circles, make ima

c++ - Interesting mistake in string pointer -

i created function transforms number equivalent in given base , prints string. looks flawless gives absurd results. code below should translate 100 base 9 , give "121". #include <iostream> #include <fstream> #include <string> using namespace std; void doldur(string *s,int u,int base){ *s=""; while(u!=0){ *s=""+u%base+*s; u/=base; } return; } int main() { ofstream fout ("dualpal.out"); ifstream fin ("dualpal.in"); int i; string hey; doldur(&hey,100,9); cout<<hey; cin>>i; return 0; } but ridiculously, prints dualpal.outualpal.outdualpal.out.(also gives other interesting results different bases) where's flaw? you're incrementing pointer empty string u%base places , using construct std::string , looks null terminator. causes undefined behaviour. use std::string off bat: *s = std::string() + ...; next, there'

twitter bootstrap - Implement typeahead such that items are links -

how can implement bootstrap-typeahead.js in such way looks @ long list of links , suggested options clickable take specific page? for example, on twitter's site, if search in searchbox, matches specific people return links allow click them go directly page rather having search them. default, typeahead replaces current input result click rather taking page corresponds link. the list bunch of hyperlinks. you can make typeahead source list of links, , use updater function navigate selected link. see answer to: utilizing bootstrap's typeahead search function if want show actual urls (links) in typeahead this.. var links = [ "/login", "/", "/user", "/tags" ]; $('.typeahead').typeahead({ minlength:2, updater: function (item) { /* navigate selected item */ window.location.href = item; }, source: links }); demo

python - More efficient way to get integer permutations? -

i can integer permutations this: myint = 123456789 l = itertools.permutations(str(myint)) [int(''.join(x)) x in l] is there more efficient way integer permutations in python, skipping overhead of creating string, joining generated tuples? timing it, tuple-joining process makes 3x longer list(l) . added supporting information myint =123456789 def v1(i): #timeit gives 258ms l = itertools.permutations(str(i)) return [int(''.join(x)) x in l] def v2(i): #timeit gives 48ms l = itertools.permutations(str(i)) return list(l) def v3(i): #timeit gives 106 ms l = itertools.permutations(str(i)) return [''.join(x) x in l] you can do: >>> digits = [int(x) x in str(123)] >>> n_digits = len(digits) >>> n_power = n_digits - 1 >>> permutations = itertools.permutations(digits) >>> [sum(v * (10**(n_power - i)) i, v in enumerate(item)) item in permutations] [123, 132, 213, 231, 312, 321]

Need instructions integrating a wrapbootstrap theme into a new rails app -

i purchased theme @ wrapbootstrap , fired new rails app experiment it. theme came no documentation , new rails, use help. none of other examples here detailed , there not seem blog posts online. thanks. this theme, if helps- presume running rails 3, have ran 'rails new experiment' , have installed no gems @ point, not bootstrap @ point. love have definitive instructions others, beginning, here on stackoverflow. i suggest following: 1. copy theme assets /vendor copy css files vendor/assets/stylesheets copy javascript files vendor/assets/javascripts copy images vendor/assets/images 2. create entries in asset manifests create entry in app/assets/stylesheets/application.css each css file wish include in application. files listed in there should automatically included pages use default layout app/views/layouts/application.html.erb . same thing javascripts under app/assets/javascripts/applications.js . 3. separate theme customizations original theme f

javascript - Editing navigation of this website -

http://www.madeinebor.com/themes/sliddr/index.htm#/logo as see website works pressing space bar , other keys, how can change clicking. when ever user click in empty area, navigate next step. or if thats not possible making box in side user click on box navigate? here navigation part of code: // prevent default keydown action when 1 of supported key pressed. document.addeventlistener("keydown", function ( event ) { if ( event.keycode === 9 || ( event.keycode >= 32 && event.keycode <= 34 ) || (event.keycode >= 37 && event.keycode <= 40) ) { event.preventdefault(); } }, false); and document.addeventlistener("keyup", function ( event ) { if ( event.keycode === 9 || ( event.keycode >= 32 && event.keycode <= 34 ) || (event.keycode >= 37 && event.keycode <= 40) ) { switch( event.keycode ) { case 33: // pg case 37: /

java - struts2 for modern I performance site -

i want create web app , looking best java web framework use. requirements of app needs handle @ least 600,000 user request. must have strong security architecture. iterator fast , lightweight. looking struts2 , easy learn fit project i believe not web application framework need considered here. struts surely light weight mvc based web application framework. if planning create webapp handle 600,000 requests need many other things, few mentioned here hardware/software load balancers cluster of web servers if there db interactions of requests load balance dbs proper cache frameworks there may different options available address above points. careful in whatever chose. may have run performance checks on different parts/frameworks in application. understand can slow down application. hope helps!

mysql - Submit button only sees the multiplequestions as onequestion using php and database -

so have problem. when select radio button of question 1 example selects radio button. when select radio button different question, first radio button i've selected isn't selected anymore , other radio button selected. i've tried searching solution,but can't find any. it's school project, have make poll. here's code: <?php mysql_connect(" ", " ", " "); mysql_select_db(" ") or die(mysql_error()); if(isset($_post['verzenden'])) { $query="update optie set stemmen = stemmen + 1 id='" . $_post['item']. "'"; } if(mysql_query($query)){ echo"stem opgeslagen! <br /><br/>"; } else { echo"fout tijdens opslaan stem!<br /><br/>"; } $result = mysql_query("select * poll"); while($data = mysql_fetch_assoc($result)){ echo"<b>" . $data['vraag'] . "</b><br/><br />"; echo

php - How to loop all folders and open it, read file put \n on the end of each line and make it a single line and save it as a new file -

i have directory contains lot of folders , each of folder has text file contain urls im trying create php code open text file on each folder , edit , make urls in single line \n character separating each urls this code far $path = "localpath here"; $handle = opendir($path); while ($file = readdir($handle)) { if(substr($file,0,1) !="."){ $text = preg_replace('/\s+/', '', $file); //echo $text."</br>"; $blast = fopen("$path/$text/$text.txt", 'r') or die("can't open file"); //echo $blast; while (!feof($blast)) { $members[] = fgets($blast); //echo $members; } } } foreach($members $x=> $order){ echo $order."</br>"; $string = trim(preg_replace('/\s+/', ' ', $order)); $linksonly = "write.txt"; $linksonlyhandle = fopen("$path/$text/$linksonly", 'a&#

vba - Select values based on the values of the first column -

Image
i have database looks this: name -finding 1 -finding 2 -finding 3 john -low cost john -accessible -low cost michael -high cost -good quality -good csr michael -low cost -friendly csr michael -average cost michael -lot of features -good quality charles -average cost bryan -high cost -friendly csr as can see, have same guy working different accounts , reporting on findings. i need findings per worker , put them in different columns, can remove duplicate values (for example, john found "low cost" in 2 different accounts - need listed once). and, once i've removed duplicates, need put remaining in 1 cell (as string of text) - per installer (not overall conglomerate). please help. i'm new in vba. note on side: started separating installers macro (thinking leaving space in between installers work out rest - i've worked little success in finding solution this). is looking

C# Entity Framework 5.0 Generic LINQ -

i trying use generics load record dbcontext cache. using following code. _context.set<t>().where(r => (int)r.gettype().getproperty("id").getvalue(r) == id).load(); this code throwing following error , cannot seem figure out how around it. system.notsupportedexception: linq entities not recognize method 'system.object getvalue(system.object)' method, , method cannot translated store expression. is doing possible or there way. the problem you're attempting use reflection methods ( gettype() , getproperty() , getvalue() ) linq entities, , doesn't understand them. methods you're allowed use inside linq query limited query provider supports, , in case of linq entities it's things can translated sql relatively easily. you won't able try match id way, unfortunately. using .find(id) work long primary key entity type specified t has single column , id correct type, that's going brittle approach if works in cases.

c++ - stringstream odd behavior after string with one word -

this question has answer here: how clear stringstream? [duplicate] 1 answer i have code example: #include <iostream> #include <sstream> using namespace std; int main(){ stringstream ss; string buffer,first_word; int i; for(i = 0; < 4; i++){ getline(cin,buffer); // getting line ss.str(buffer); // initializing stream ss>>first_word; cout<<first_word<<endl; ss.str(string()); // cleaning stream } return 0; } with input: line 1 spaces line 2 spaces alone line 4 spaces the output expect first words of lines, this: line line alone line but getting this: line line alone alone so, stringstream not updating after getting line has 1 word. please explain me, don't want right answer code, want know why. thank you. if bothered check s

Add new columns while generating scripts in sql server 2008 -

i' trying generate scripts ma db in sql server 2008.. , i'm able that, scripts generated : use [cab_booking] go /****** object: table [dbo].[user] script date: 05/19/2013 10:33:05 ******/ set ansi_nulls on go set quoted_identifier on go if not exists (select * sys.objects object_id = object_id(n'[dbo].[user]') , type in (n'u')) begin create table [dbo].[user]( [u_id] [int] identity(1,1) not null, [username] [nvarchar](50) not null, [password] [nvarchar](50) not null, add column new int not null, constraint [pk_user] primary key clustered ( [u_id] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] end go what should if need add new column in table through scripts... i know sounds easy...but, dont know missing... thanks.. right click on table name on sql server management studio , select "design". add co

cronexpression - use cron to implement 'From 12:24:20 to 16:20:56 Every 5 minites' -

how implement cron job this: from 12:24:20 16:20:56 run every 5 minutes or there solution on python, use package apscheduler finally solve problem myself, extend apscheduler library , define customized trigger fullfill requirement. useful links: http://pythonhosted.org/apscheduler/extending.html http://devlvl99.blogspot.com/2013/03/injecting-timezone-awareness-python.html