Posts

Showing posts from July, 2013

c - Explanation of Output of Bitwise operations -

this question has answer here: what bitwise operators? 10 answers void main() { int x=7; printf("%d",x&(x-1)); int y=6; printf("%d",y&(y-1)); printf("%d",y>>2); } when put odd number output n-1 n odd number when put y= number output 0.i not able understand please help. my second question when print y>>2 6>>2 ouput 1.please explain me also. know these bitwise operations concept not clear.thanks let's break each line up: x&(x-1) => 0x111 & 0x110 => 0x110 => 6 ... and: y&(y-1)) => ox110 & 0x101 => 0x100 => 4 ... , finally: y>>2 => 0x110 >> 2 => 0x001 => 1 remark: it's idea review knowledge of bitwise operations .

Vim multiple filtering of a file, with 2 filters based upon number values -

i not know if title sound adequate … let have file (> 1000 lines) homogeneous structure throughout consisting of 3 "fields" separated space : 1. integer (negative or positive) <space> 2. integer (negative or positive) <space> 3. text (description) the integers >-10000 , < 10000 my problem : how can i a) filter file criteria such "1st integer <= 1000" , "2nd integer >=250" , "text contains : boston or new-york" b) , put subset in new buffer, allowing me read results , results of filter(s) ? i wish vim only, not knowing if feasible or reasonable (anyway above skills) thanks @fdinoff : sorry, should have done suggest, of course : it chronology startdate, enddate, , description : 1 -200 -50 period 1 in italy 2 -150 250 period 1 in greece 3 -50 40 period 2 in italy 4 10 10 event in italy 5 20 20 event 2 in greece the filter : filter items (to mimic sql) startdate <=-50 , enddat

excel - VBA strange behavior converting string to date, some are ok, some are not -

like title says, cells end correct value, , month , day switched, if constant, fix it, messes values, , can't understand why. here code: for v2temp = 0 4 form1(v2temp) = trim(form1(v2temp)) & ";" tmpp = left(form1(v2temp), len(form1(v2temp)) - 1) arr = split(tmpp, "-") activeworkbook.worksheets("temp2").range("i2").numberformat = "dd-mm-yyyy" if tmpp <> vbnullstring dt = dateserial(arr(2), arr(1), arr(0)) activeworkbook.worksheets("temp2").range("i2").value = dt form1(v2temp) = activeworkbook.worksheets("temp2").range("i2").value else form1(v2temp) = "" end if next v2temp = 0 4 activeworkbook.worksheets("temp2").range("c7").offset(v2temp, 0).value = form1(v2temp) next so, should write dates cells c7 c8 c9 c10 , c11, , does, problem described. i've added debug.print in code write step step value received , value tran

hyperlink - Tie Image to Repeater link Button -

i have link button getting populated repeater template here, <asp:repeater id="repeater" onitemcommand="repeater_itemcommand" runat="server"> <itemtemplate> <asp:linkbutton id="btnlinkgroups" commandname="cmd" runat="server" text='<%# eval("itemtypedescription") %>' commandargument='<%#eval("itemtypeid") %>'/><br /> </itemtemplate> </asp:repeater> currently text (itemtypedesc) link buttons name. how can add png image in same directory instead of text. images aren't stored in db need way link each image correct link button thanks

three.js - How to create PlaneGeometry object at some height along z axis? -

i using this: new three.mesh( new three.planegeometry( 1000, 1000 ), new three.meshbasicmaterial() ); to create new plane. how change height along z axis? none of arguments related it. assuming mesh captured variable this: var planemesh = new three.mesh( new three.planegeometry( 1000, 1000 ), new three.meshbasicmaterial() ); then, need move is: planemesh.position.z += 50; also, icemonster correct plane render facing start, depending on use, may want rotate mentioned in comment.

java - Can a WebLogic Singleton Service be used for wait/notify? -

we have app maintains hashmap in memory keyed specific user ids , had values representing system events. basic functionality user makes request web server checks hashmap events keyed id otherwise waits short amount of time on hashmap until either time out or notify executed on hashmap wakes client , processes event. this working fine in single server environment moving clustered environment , unsure of best way handle particular piece. thinking need utilize database queue these events , lose instant callback effect wait/notify unless possible somehow achieve using singelton service feature. using singleton service able wait on object 1 server , notified thread on other server in cluster? i suggest use jms that. jms cluster-friendly , can configured persist events either in file storage or database. can select 2 models: queue or topic depending on how users need handled.

SQL Server Inserting a previous value into the new column -

i have these 2 tables: table1: customername billdate city - beautification lm 2013-05-30 00:00:00.000 city - beautification lm 2013-06-28 00:00:00.000 city - parks/rt 66 2012-07-12 00:00:00.000 city - parks/rt 66 2012-07-12 00:00:00.000 and on... table2 has field: cyclestartdate i want insert data table1 table2 following: each unique customername, cyclestartdate billdate previous record. if previous record not exist, replace null 2013-07-1 00:00:00.000. is possible can that? if have sql server less 2012, try this select t.customername, isnull(tp.billdate, '20130701') cyclestartdate table1 t outer apply ( select top 1 t2.billdate table1 t2 t2.customername = t.customername , t2.billdate < t.billdate order t2.billdate desc ) tp if have sql server 2012, see lag() function

ios - Crash in NSDateformatter setDateFormat method -

-(nsstring*) converttodatestring:(nsstring*)str{ static nsdateformatter *indateformatter = nil; static nsdateformatter *outdateformatter = nil; nsstring *outdate = nil; if([str iskindofclass:[nsstring class]] && [str length] > 0){ nsstring *datestr = [[nsstring alloc] initwithstring:str]; if (indateformatter == nil) { indateformatter = [[nsdateformatter alloc] init]; indateformatter.dateformat = @"yyyy-mm-dd"; } if (outdateformatter == nil) { outdateformatter = [[nsdateformatter alloc] init]; outdateformatter.dateformat = @"mm/dd/yy"; } nsrange rangeofdash = [datestr rangeofstring:@"t"]; datestr = (rangeofdash.location != nsnotfound) ? [datestr substringtoindex:rangeofdash.location] : datestr; if([datestr iskindofclass:[nsstring class]] && [datestr length] == 10){ nsdate* date = [indateformatter datefromstr

How to specify the classpath to the acceleoCompiler ant task to compile mtl files -

i'm trying compile acceleo mtl files using ant task: <target name="compileemtsfiles"> <echo>...... running acceleo mtl=emtl file compilation</echo> <acceleocompiler sourcefolder="src/main/java" outputfolder="build/classes/main" binaryresource="false" dependencies="" packagestoregister="com.company.myacceleopackage"> </acceleocompiler> <echo>...... finished acceleo mtl=emtl file compilation</echo> </target> but acceleocompiler seems have problem find "com.company.myacceleopackage". can found in src/main/java, dont know how specify kind of classpath acceleocompiler: [echo] ...... running acceleo mtl=emtl file compilation [acceleocompiler] com.company.myacceleopackage build failed c:\path\build.acceleo.xml:24: com.company.myacceleopackage any ideas how can proceed? regards, michael

django - Calling a celery task from another celery task -

i have celery task called send_async_fax , called send_notifications . send_async_fax can called directly. if call send_notifications , however, send_async_fax called. send_async_fax has number of arguments 1 of list of file objects. if call send_async_fax directly, seems go planned. however, when it's called indirectly, via send_notifications , find list of valid open files degrades list of uninitialized files. my hunch send_notifications was, in fact, creating separate asynchronous tasks sending faxes when send_async_fax.delay called (which, of course, makes sense). doing this, however, suspect file references getting messed up, or send_notifications closing files before send_async_fax gets operate on them. to test hunch, tried calling send_async_fax in send_notifications without using delay function (i.e., send_async_fax(*args) instead of send_async_fax.delay(*args)). didn't change anything. then, commented out task decorator send_async_fax make regu

C - how can i reset the USB Bus under linux? -

daily--about 5 10 times--my usb camera disappears system. it's been happening day 1 because manufacturer driver not compatible linux. lsusb , dmesg show correctly @ first, after longer period of time disappears. best solution fix reset usb interface camera back. did few times manually using c source code , worked, when doing in bash loop seems it's failing on , over. idea? how can make both programs work, /dev/video0 or 1 or 2 available? step 1: resetting usb bus under linux using code: /* few times it's resetting when use in bash loop it's not doing */ #include <stdio.h> #include <usb.h> int main(int argc, char *argv[]) { struct usb_bus *busses; usb_init(); usb_find_busses(); usb_find_devices(); busses = usb_get_busses(); struct usb_bus *bus; int c, i, a; (bus = busses; bus; bus = bus->next) { struct usb_device *dev; int val; usb_dev_handle *junk; (dev = bus->devices; dev; dev = dev->next) { c

java - Changing background colors affects unrelated views in another activity -

i'm having weird issue in android app i'm developing. the short story background colors set programmatically in 1 activity appearing on unrelated views in activity. basically, in 1 activity have listview in user can select or unselect item tapping it. when selected, item highlighted orange background. background color set programmatically via listadapter. the user may navigate second activity different layout in every view supposed have white background (this set in appropriate style/layout xml files). however, sometimes, entire background of second activity turns same orange color highlighted listview items in first activity. in second activity background colors set programmatically, have no idea how they're changing color @ all, let alone why they're turning orange. if that's not weird enough, consistently happens on 1 device (a droid razr maxx android 4.1.2) out of 10-15 devices of varying manufacturers , android versions i've tested app on far. o

Bootstrap modal in joomla 3.1 -

how use bootstrap modal in joomla 3.1 ? have bootstrap loaded , when try initialise $('#confirmdelete').modal(); my modal window $(...).modal not function easiest way have found use data attribute , data-toggle="modal". example be: <a href="#my-modal" data-toggle="modal" class="btn">launch modal</a>

facebook - FB.login(): Unsupported Browser IE Mobile -

i using facebook javascript sdk in .net mvc mobile website. of sudden (since few days) fb.login() doesn't seem work on windows phone 7.8 phones. error "unsupported browser: ie mobile not support feature...". it work on mobile browsers on android , iphone. any ideas? thanks! edward in case of unsupported browsers should able fall use alternative flow: https://developers.facebook.com/docs/facebook-login/login-flow-for-web-no-jssdk/

c# - Creating a set from Table Valued Function in Entity Framework -

i have database big tables(some of them may have more 1,000,000 records) , every user of database should see of data, have multiple tvf(table valued function) user id , select records of table visible user(this operation require multiple select statements , think calling tvf far better implementing in code). in first release of program clients, had class multiple properties of type iqueryable implemented using linqtosql , worked great. have client want use assembly write wcf data service, have write class derived dbcontext (using ef) can used in specified service. problem is: dbcontext automatically expose dbset properties defined in it, every user minimum level of access can see entire data of table(of course client app restrict data, client can access data directly , import data excel or access using odata) i have multiple public properties of type iqueryable not appeared in list of data exposed wcf data service. in order solve problem, think complete solution able ca

shell - Strange regex behavior with grep -

grep '[:digit:]{1,}-{1,}' *.txt| wc -l this command outputs: 0 grep '1-' *.txt| wc -l however, command outputs: 10598 both commands being run same directory. first command should have returned greater or equal output of second command. can shed insight going on here? echo 1 | grep '[:digit:]' #nothing.... grep uses different syntax, need [[:digit:]] or [0-9] . the {1,} syntax not supported basic grep, can use other modes, extended 1 -e ... note: 1 use + matching 1 or more characters.... general note: test regexes in small parts see each part thought does. once expression gets complicated, it's hard tell went wrong.

url - Magento can't load some resource files (images, css and js) -

i have magento site in: www.petitebox.com.br which, of sudden, began mess design up. magento can't load resources files (some images, css , js), backend ruined. can see in image here . does know if it's more problem in .htaccess or in magento settings? or maybe else? how can fix it? edit magento can't load of files. group of files, magento can load without problems: image here thanks try changing permissions /var , /media folders, has 0775 permission. delete cache manually through command line: rm -rf /yoursite/var/cache/mage--* (be careful one). check core_config_data configuration: select * core_config_data path '%web/secure/base_url%'; select * core_config_data path '%web/unsecure/base_url%'; they have url, if different, try with: update core_config_data set value='http://www.petitebox.com.br/' path '%web/secure/base_url%'; update core_config_data set value='http://www.petitebox.com.br/' path '%w

ServiceStack returning JSV instead of JSON -

i have service created servicestack. updated servicestack libraries , getting jsv responses instead of json responses. the request looks like: post http://localhost/api/rest/poll/create?format=json&pollformat=1 http/1.1 host: localhost connection: keep-alive content-length: 160 accept: */* origin: http://localhost x-requested-with: xmlhttprequest user-agent: mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/28.0.1500.95 safari/537.36 content-type: application/x-www-form-urlencoded; charset=utf-8 dnt: 1 referer: http://localhost accept-encoding: gzip,deflate,sdch accept-language: en-us,en;q=0.8 cookie: question=this+is+a+test&answers=yes%2cno& and response looks like: http/1.1 200 ok cache-control: private content-type: application/json; charset=utf-8 server: microsoft-iis/7.5 x-powered-by: servicestack/3.956 win32nt/.net x-aspnet-version: 4.0.30319 x-powered-by: asp.net date: mon, 12 aug 2013 21:20:33 gmt content-length: 437 {id:1,q

delphi - Form as instance variable -

Image
in need form knows another, dispatch behavior. in past, need this, , solves using properties. now, same procedure, didnt works. i have next uml diagram class, sorry, name class confuse: so, need thaht enpviewgeneric knows enpview. , children inherit knowledge. im try in enpviewgeneric : unit enpviewgeneric; [...] protected { protected declarations } fenpform: tenp; public { public declarations } property enpform: tenp read fenpform write fenpform; [...] the enpviewaddafter instanciation performed within enpview instance: procedure tenp.optaddlastofclick(sender: tobject); var afterform: tenpaddafter; begin afterform := tenpaddafter.create(self); afterform.enpform := self; afterform.showmodal(); end; now, enpviewaddafter instance, needs querying enpview instance. so, defined public method in enpview query. method is: function getselectedrowvalues(): tstringlist; so, code, fails access violation in fisrt line: procedure tenpaddafter.formcr

ios - self.view.size in a custom view returns [0,0] -

i have custom view: @interface mailattributesview : uiview { ... @implementation mailattributesview { uiview *_selectionview; } (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { dlog(@"frame.size.width -[%f]; frame.size.height -[%f] ",frame.size.width, frame.size.height); } return self; } -(void)awakefromnib { [self initview]; } -(void)initview { dlog(@"self.frame.size.width -[%f]; self.frame.size.height -[%f] ",self.frame.size.width, self.frame.size.height); cgrect sectionsize = cgrectmake(0, 0 , self.frame.size.width, self.frame.size.height); _selectionview = [[uiview alloc] initwithframe:sectionsize]; [_selectionview setbackgroundcolor:[uicolor clearcolor]]; fromfield = [[jstokenfield alloc] initwithframe:cgrectmake(0, 0, self.frame.size.width, row_height)]; [[fromfield label] settext:@" from:"]; [fromfield setdelegate:self]; [_selectionview add

php - How are ajax options supposed to be added to a UActiveForm? -

i've looked in framework documentation , yii forums, can't seem find on this. trying add ajax options uactiveform widget. put way, want loading gif inserted div when submit button of ajax form clicked. know how in raw javascript/jquery/php, can't seem done framework. here begin widget code: <?php $form=$this->beginwidget('uactiveform', array( 'id'=>'login-form', 'enableajaxvalidation'=>true, 'clientoptions'=>array( 'validateonsubmit'=>true, 'validateonchange'=>false, 'validateontype'=>false, ), 'htmloptions' => array( 'enctype'=>'multipart/form-data','class'=>'white-popup-block'), ), )); ?> <!--form labels/inputs here--> <?php $this->endwidget(); ?> below part of ajax code looks if without framework: request = $.ajax({ url: "usersystem/login.php&

imagemagick - Perl Image::Magick Convert Format -

a few months ago installed image::magick on perl server, have unexpected behaviour.. after hours of research, i'm stuck on problem.. what i'm trying convert image .png .jpg. there no problem here.. problem comes here. converted file ".jpg" large .png after conversion.. here snippet of code: my $image = image::magick->new; $x = $image->read($serverpathdir.'/'.$serverfilename); # .png file $x = $image->set( gravity => 'center' ); $x = $image->resize(geometry=>'435x210'); $x = $image->set(quality=>'80%'); $x = $image->write($serverpathdir.'/'.'.jpg'); after research , theory, realized such problem may exist in specific images.. when test other images, result more satisfactory nothing gimp (png jpg)... don't know compressor image::magick uses, seems different others.. ie: gimp the problem may have png files compressed. when convert format, have

PHP Update script.. filemtime? -

i sort of beginner php , trying make script shows, in file can include on side part of index page, date of last update , plus underneath list of other pages have updated (in order of update). example if last time updated tuesday , edited news , index page say august 6, 2013 - home page updated. - news headlines updated. then underneath show other latest updates.. so: august 6, 2013 - home page updated. - news headlines updated. august 5, 2013 - staff updated. august 2, 2013 - home page updated. - forum updated. - join page updated. i able set limit on how many updates can shown.. had friend had script years ago , remember done through .txt file , chmod txt file have written permissions. updates.php , on every page wanted generate update status include few lines of scripting @ top of file.. plus list page names , wanted show in either txt file or updates file index.php > home page updated... have lost contact him , no way of me finding it. had go , and got: <?p

interface - Java 8: virtual extension methods vs abstract class -

i'm looking @ new virtual extension methods in java 8 interfaces: public interface myinterface { default string mymethod() { return "myimplementation"; } } i purpose in allowing interface evolve on time, , multiple inheritance bit, awfully abstract class me. if you're doing new work abstract classes prefered on extension methods provide implementation "interface" or these 2 approaches conceptually equivalent? one primary purpose of such constructs preserve backwards compatibility. addition of closures java language quite major alteration, , things need updated take advantage of this. example, collection in java 8 have methods such foreach() work in conjunction lambdas. adding such methods pre-existing collection interface not feasible, since break backwards compatibility. class wrote in java 7 implementing collection no longer compile since lack these methods. consequently, these methods introduced "default" imp

App disappears when I deploy onto CloudBees with IntelliJ -

i on free tier of cloudbees. want deploy simple clojure web app. first, create app in cloudbees' app manager. once this, looks fine in server logs. see default application come up, , can browse it. then try deploy own code intellij. when do, intellij makes connection cloudbees successfully, , sits around 5--10 seconds. says server-side error occurred, , should check server logs. when go check logs, find app no more. it's if intellij deleted it. able re-create same name. i've tried several times, same result. how can more visibility what's going on? you have intellij logs cloudbees plugin (i not sure provides plugin) - see how deleting it. deleting on cloudbees explicit action - must doing strange. suggest using cloudbees cli deploy app (is war app?)

ios - How to unload UIViewcontroller from memory? -

my app structure (targeting ios 6.1 w/arc): intro view controller ->presents-> main menu view controller ->presents-> stuff view controller the intro view controller shown once, on app launch. user able jump main menu view controller (currently achieved using dismissviewcontrolleranimated: ). but how rid of intro view controller still lingering in memory? you should use different structure this. make mainmenuviewcontroller root view controller of window, , present introviewcontroller modally mainmenuviewcontroller's viewdidappear method no animation. make introviewcontroller first thing user sees. dismiss when you're done it, , deallocated.

version control - Do i need to make new branch for bug fix or work on master branch in git -

i have 3 branches 1 is master develop release-1 there template alignment issue showing out of format data. want know should checkout master branch , edit file , them commit on master branch , update prod server. or need make new branch bugfix changes there , merge branches thats looks me time wasting , may have 5-6 lines fix code. but consdering best practices if single programmer working on not make life more complicated needs be. branching , merging have practical place in multi developer environment. if working alone, 1 use have "experimentation". there nothing wrong working on master , branching when want experiment. it common have develop branch , merge master. many more branches , complicating things yourself. remember it's supposed make life easier, not harder.

javascript - Google Plus JS API AddActivity -

i'm trying use google's js api post on logged in user's stream / wall / whatever. i've gotten point seems should working (no errors in chrome js console) nothing shows on google+ page. code looks this: <html> <head> <title>google+ api test</title> <script type="text/javascript"> function googleapionload() { console.log("google plus js loaded... calling client.load..."); gapi.client.load('plus','v1', function(e){ console.log("client loaded..."); console.log(e); }); } function signin() { console.log("signing in..."); gapi.auth.authorize({ client_id: "your_client_id", immediate: false, response_type: "token", scope: ["https://www.googleapis.com/auth/plus.login"

javascript - In Rails, how can we pass parameters in script? -

in java script, can define variable. var topping = data.getvalue(selecteditem.row, 0); and then, want use topping value this: console.log(<%= @ecs.where(status:topping).count %>); obviously, can't work because not find topping. question how should use parameters of script in <%= %>. you confuse between server side script , client side script. <%= %> server side script. javascript client side script. when rendering page, ruby on rails executes server side script first, send response browser, browser executes client side script later, can't use client side variables in <%= %>. if want result dynamically based on client side variables. use ajax. send parameter server, , response javascript. it's big picture. see tutorials below(not sure work) or start rails book(agile web development rails) or google it. rails ajax tutorials

php - carrying product_id value to an extra added page through url -

i using opencart. want give link product_form.tpl page. mean have added tab called 'allocation' in have given button 'add allocation' should redirect external page. i'd provide product_id within link it's not working properly... here code ( product_form.tpl ) <div id="tab-allocate"> <table class="list"><tr><td align="center"><a href="allocation.php?product_id=&product_id" target="_blank" class="copybutton" style="width:120px;">add allocation</a></td></tr></table> </div> but allocation.php?product_id=&product_id not working, goes allocate.php page doesn't carry product_id. doing wrong? i think, it's wrong in passing parameter, please try that <a href="allocation.php?product_id=product_id" target="_blank" class="copybutton" style="width:120px

c++ - Const pointer and pointer to const -

instead of doing this: int* const p; and this: const int* p; couldn't make easier read doing: typedef int* ptr; const ptr p; //constant pointer integer and: typedef const int ptr; ptr* p; //pointer constant integer there's no reason that. not make code less readable, doesn't make sense. typedef const int ptr; ^ makes no sense - const int call pointer. save , readers , type out const int* ptr; edit: to directly answer question: no, not make easier. edit #2 another point, happens when have typedef const int ptr; typedef const long ptr; typedef const float ptr; not not make sense, since aren't pointers, have bunch of things called ptr, , confused writing.

How to pass a service header when calling a WCF Service on a WinRT app -

i got 2 projects on solution - console application project , winrt project. i need consume wcf service, can through console application using following lines: static void main(string[] args) { var client = new servicereference1.comeandgoclient("basichttpbinding_icomeandgo"); var header = new servicereference1.serviceheader{ accountid = "a1", deviceid = "d1" }; var res = client.getemployees(ref header, ""); } the problem - i'm not finding out how can send same service header (accountid , deviceid) when calling same method through winrt app. var client = new servicereference1.comeandgoclient(servicereference1.comeandgoclient.endpointconfiguration.basichttpbinding_icomeandgo); public async task loaddata() { var sessions = await client.getemployeesasync(""); } note: on winrt project don't have getemployeesasync method gets serviceheader parameter have getemployees on console application pr

libgdx - How to force subclass to implement some methods in java? -

i have screen interface in libgdx framework. i create subclass called baselayout , initialize fields. now every actual screen e.g. menuscreen extend baselayout class. i want force these classes e.g. menuscreen implement 2 methods void initdata() , , void addbuttonstoscreen() . how this? i call these methods in show method implemented in base class baselayout . i want force these classes e.g. menuscreen implement 2 methods void initdata(), , void addbuttonstoscreen(). how this? make baselayout abtract class , make initdata() , addbuttonstoscreen() abstract methods. example public abstract class baselayout extends screen { public void initdata(); public void addbuttonstoscreen(); } then make subclasses extend , implement methods.. public class concretelayout extends baselayout { public void initdata() { // code here. } public void addbuttonstoscreen() { // code here. } }

Arabic not supported in mysql and php -

Image
this question has answer here: utf-8 way through 14 answers i have part of code works fine arabic issue. $result = mysql_query("select login, password, name, role qm_users login = '$login'"); if (!$result) { die('invalid query: ' . mysql_error()); } $row = mysql_fetch_array($result); echo $row["name"]; the name row contains arabic name. the output of echo ???? ???? ???? in myphpadmin of xamp server, here structure if going save utf8 encodings mysql database first set connection encoding utf8. <?php $connection = new mysqli('localhost', 'my_user', 'my_password', 'my_db'); mysqli_set_charset($connection, "utf8"); ?>

mysql - laravel 4 - how to Limit (Take and Skip) for Eloquent ORM? -

tl;dr can limit eloquent orm query using take() , skip() resulting mysql query limited, , doesn't have return entire dataset? if so, how modify: $test = user::find(1)->games->toarray(); to include limit 3 offset 2 ? tables: users games usergames -- id -- id -- user_id -- name -- name -- game_id -- steam_id models: class user extends eloquent { public function games() { return $this->belongstomany('game', 'usergames', 'user_id', 'game_id'); } } class game extends eloquent { public function users() { return $this->belongstomany('user', 'usergames', 'user_id', 'game_id'); } } limit in query builder using regular laravel query builder can games belong user of id 1, , limit result take() , skip() : $test = db::table('games') ->join('usergames', 'usergames.game_id

node.js - What is correct initialization for sequalize? -

i want use transactions , requests pooling. i've seen sequalize has pooling support, have question - have manually re-create sequalize object each request? mean: // main app context var sequelize = require('sequelize'); // request handler context function handle(req, res) { var sequelize = new sequelize('helpdesk', 'root'); } or can initialize sequelize object once , use everywhere?

google schemas - Action button not showing when sending to other gmail account -

my viewaction button working fine when using apps script send email myself. (same gmail account logged in) function testschemas() { var htmlbody = htmlservice.createhtmloutputfromfile('mail_template').getcontent(); mailapp.sendemail({ to: "myemail@gmail.com", subject: 'test actions in inbox - ' + new date(), htmlbody: htmlbody }); } when setting gmail account recipient, action button won't display. i've tried several gmail accounts. by of it, testing schemas possible when sending 1 self , not other gmail accounts. true? my action button: <html> <head> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "emailmessage", "action": { "@type": "viewaction", "name": "test action", "url": "https://mydomain.com/test" }, "descrip

scrum - How do I develop an application with a Layered Architecture using Agile methodologies? -

Image
in domain driven design applied architectures, should start developing domain model , test it. after model occurred, can use model objects in other layers presentation layer or persistence layer. my question how separated tasks team members project? before model created, frontend developers can not anything.because objects not ready. does domain model created multiple developers projects? example productservice , orderservice developing , testing 2 different developers? agile methodologies recommend approaching each feature in vertical slices (also see here ). this means should develop feature end-to-end. when doing should apply "you aren't gonna need it" or yagni . means should build "just enough" of each layer implement feature. you don't need full domain model implementing each feature. backend coders implement parts frontend coders need, before need it.

regex - How does \w work? -

in perl programming, \w kind of regular expression. what know how match? whether matches character or word,same question \w+ ? \w means "any letter, digit or underscore". many think it's equivalent [a-za-z0-9_] , not . every unicode character letter or digit, including non-latin characters such chinese, arabic, etc.

c# - Algorithm for xml document splitting -

i want split xml document several xml documents specified node name, (similar string.split(...).) example: have following xml document. <root> <nodea> hello </nodea> <nodea> <nodeb> node b text </nodeb> <nodeimage> image.jpg </nodeimage> </nodea> <nodea> node text </nodea> </root> i want split xml document 3 parts 'nodeimage', , keep original xml structure. (note: node name 'nodeimage' anywhere) 1. xml before nodeimage 2. xml nodeimage 3. xml after nodeimage for sample xml, results should be: xml document 1: <root> <nodea> hello </nodea> <nodea> <nodeb> node b text </nodeb> </nodea> </root> xml document 2: <root> <nodea> <nodeimage> image.jp

bash - checking if grep command returns correct output -

thing using wget extract url after want pipe grep check if matches pattern , if echo name of url. something this: wget url |grep "pattern" if successful display urlname an if condition true if command returns 0. grep returns 0 if matches pattern input. if wget -o - ... | grep -q ... ... fi

node.js - Bookshelf.js: how to define cross-relations? -

how can define hasmany space -> accounts relation? var space = bookshelf.model.extend({ tablename : 'spaces', // account variable not exist :/ }); var account = bookshelf.model.extend({ tablename : 'accounts', spaceid : function() { return this.belongsto(space); }, }); what correct way define this? p.s. there no tag bookshelf js library: http://bookshelfjs.org/ according docs , should work: var account = bookshelf.model.extend({ tablename : 'accounts' }); var space = bookshelf.model.extend({ tablename : 'spaces', accounts : function() { return this.hasmany(account, 'spaceid'); // spaceid foreign key account table } });

Crystal Report 9 Installation Hang on Window Server 2008 -

i need install crystal report 9 on server 2008. installation hang , cannot proceed. check if crystal report compatible window server 2008 or has install crystal report 9 on ws 2008 please advices thanks i believe cr 9 not supprted on server 2008

create windows 8 batch file to copy, rename and save files from sub directories recursively -

i'm trying copy thousands of image files , rename them name of folder in. file structure is:- c:\pictures\kitcam\1\master_01.jpg c:\pictures\kitcam\1\master_02.jpg c:\pictures\kitcam\2\master_01.jpg c:\pictures\kitcam\3\master_01.jpg c:\pictures\kitcam\3001\master_01.jpg i create new directory c:\pictures\kitcam\all , copy , rename files above following naming convention:- c:\pictures\kitcam\all\[directoryname]_filename] (pad directory name 4 digits director name 1 becomes 0001 etc) for example:- c:\pictures\kitcam\all\0001_master_01.jpg jonathan @echo off &setlocal set "startfolder=c:\pictures\kitcam" set "targetfolder=c:\pictures\kitcam\all" /r "%startfolder%" %%a in (*.jpg) ( set "fname=%%~nxa" set "fpath=%%~fa" /f "delims=" %%b in ("%%~dpa.") set "nname=000%%~nxb" setlocal enabledelayedexpansion echo move "!fpath!" "%targetfolder%\!

css - overflow-x on <html> inside iframe also does overflow-y -

i'm using jquery plugin happens apply overflow-x:hidden on tag, fair enough it's purpose. however oddly, when tag inside iframe, overflow-x acting overflow-y well! this happening in ie7 compatibility mode. any ideas, understanding, overflow-x supported in ie7 fine. explicitly applying overflow-y:scroll seemed fix it.

Best method to run a periodic background service in java blackberry -

objective : want develop ui application runs service/ task/method periodically update database. service should start after periodically if application not active/visible/user exits app. similar an android service . i'm using blackberry java 7.1 sdk eclipse plugin . the options came across following: 1) how run blackberry application in background this link suggests extend application instead of uiapplication . can't application has user interface . 2) make application go in background i don't want ui application go in background, instead want application call service periodically . 3) run background task mainscreen in blackberry? this link suggests run thread, don't think if user exits application thread run in background 4) blackberry install background service ui application? this suggests using codemodulemanager ,whose usage i'm unable figure . please suggest best way achieve objective or suggests other better method . i ne

jquery mobile trigger('create') method doesn't work with iframe -

when try call .trigger('create') method iframe contents, not work , css classes not applied input:text elements. when call .trigger('create') method html content outside iframe, works please go link 'here' on jsfiddle , click on "load mobile view" javascript code $('#mobile_view').contents().find('body').append("<div id='fbm_mob_menu'></div>"); $("#load_mobileview").click(function(){ var content = ' <form class="fbm_contactform">\ <div>contact us</div>\ <div data-role="fieldcontain"><label for="name" >name</label>\ <input name="name" type="text" class="m-field" /></div>\ <div data-role="fieldcontain"><label for="email">email</label>\ <input name="email" type="text" class="m-field" /

php - build an API for streaming audio/video from GridFS mongodb -

i have tried solution given in link stream audio/video files gridfs on browser still when use code file gets downloaded or plays default browser player. code as: header('content-type: audio/mpeg;'); $stream = $file->getresource(); while (!feof($stream)) { echo fread($stream, 8192); } i want solution build api can retrieve audio/video mongodb gridfs , play streaming phone application. help urgently needed. on topic welcome. i found way make api playing file straight mongodb gridfs in html audio video image widget. problem uses data retrieved mongodb base64 data. problem talking discussed in link: http://davidbcalhoun.com/2011/when-to-base64-encode-images-and-when-not-to . i hope find useful before deciding use solution using. solution follows: $stream = $file->getresource(); $stringcoded = stream_get_contents($stream); //converts stream string data $encoded = base64_encode($stringcoded); //encodes string data base64 now have audio

PHP Arrays and mysqli multi query -

i'm trying understand 2 things: if following possible; what doing wrong implementing it. i have array in php manually coded: $q[1] = 'monday'; $q[2] = 'tuesaday'; $q[3] = 'wednesday'; i have seperate mysqli multi-query bringing set of data. iterate though multi query , echo results, need include information within manually coded php array, detailed above - current code follows: echo "<tr><td class='qnum'><span class='bold'>". $n .".</span></td> <td width='450px' > ". $q[$n] ." (<span class='italics'>". $row[0] ."</span>)</td> <td class='set2'>".$row[9]."%</td>"; i have pointer $n increases mysqli query loops through results , i'm using $q[$n] try , pull in relevant data php query doesn't work. however, odd is change $q[1] = 'monday'; $q = 'monday'; , refe

java - Garbage collection when work is done with single or multiple threads -

i have jdbc program inserts around 50000 rows in table. have 2 version of program. first 1 insert 50000 rows using 1 thread while 2nd version inserts 50000 rows using 5 threads (each thread inserting 10000 rows). now when profiling both program found garbage collection taking more cpu cycles when 5 threads used (44256 1 thread vs 401836 5 thread). profiler give me number of objects created each program same. i wondering making gc take more cycle in multi threaded program. work done both program same (inserting 50000 rows) , number of objects same. thanks manoj every insert creates objects in jvm, must later garbage collected. if perform inserts in parallel in multiple threads, it's higher "throughput" (inserts per second) if performed inserts sequentially. background: because every individual insert, require round trip database, if inserts in parallel, thread can start insert before round trips have finished in others. the multithreaded case creat

javascript - Marionette Controller Function Declarations - Best Practices -

i'm writing large scale marionette application, ran router / controller. here's question -- practice include other functions in controller aren't meant routes? so have following method: index : function() { alert('test!'); } is consistent best practices able declare other functions in controller not called when routes initialized? so: norouteassociated: function() { alert('test!'); } index: function() { this.norouteassociated(); } obviously simplified example, trying avoid putting large amounts of information or function declarations inside of methods because they're associated routers. the roles , responsibilities of controllers best illustrated @davidsulc in this post , better yet new book . generally speaking, it's okay include methods aren't meant routes, if they're controlling workflow of app. event triggering example, if want change appearance of or retrieve data database, should move these met

java - Need to use dependency injection in unit tests - should I use junit or testng? -

we looking @ how use dependency injection unit tests (using jsr-330 syntax without explicitly specifying engine in basic tests if matters), , have used junit 4 far , been pleased it, appears not designed dependency injection in tests. question is, whether junit suited tests run in dependency injection context, or if should switch testng? just clarify: trying di-engine agnostic, , looking @ dagger. i appreciate if opinions backed fact, thanks. assuming using spring framework you can annotate junit test classes this: @runwith( springjunit4classrunner.class ) @contextconfiguration( "classpath:apptest-context.xml" ) public class appservicetest{ ... ... } and inside apptest-context.xml have regular spring config stuff injecting dependencies.

html - Dynamically read GET string of a form using javascript -

tl;dr: want easy way retrieve get-string created form dynamically load according data without refreshing. normally, pressing submit on form: <form action = "action.php" method="get"> <p> <input type="text" name="foo" value="bar" /> <input type="checkbox" name="check" value="true" checked="checked" /> <input type="submit" /> </p> </form> would create , access string: action.php?foo=bar&check=true i access string without reloading , without having fiddle iterating form elements (which i'm doing @ moment). aim put string xmlhttprequest if in form changes can update data on webpage accordingly. var string = $("form").serialize(); http://api.jquery.com/serialize/

html - Internet Explorer hides php content -

the problem i'm not advanced did wrong.. first page on site opens correctly on chrome , firefox, on internet explorer footer image sticks header image hiding 2 images in between. the website: http://www.joniart.com i've tried make similar landing html page, <div> content issue remains. your problem height of elements: <img width="355" height="inherit" alt="lietuviskai" src="http://joniart.com/wp-content/themes/tut/static_images/ranka_k.jpg" border="0" complete="complete"/> give them real height <img width="355" height="300" alt="lietuviskai" src="http://joniart.com/wp-content/themes/tut/static_images/ranka_k.jpg" border="0" complete="complete"/> and should work. from mdn: height the height of image in html5 css pixels, or html 4 in pixels or percentage. i don't thinkg inherit valid value.

php - Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' using IBM Informix and WAMP -

i got error ( fatal error: uncaught exception 'pdoexception' message 'could not find driver' in c:\wamp\www\test.php on line 30) when run php page using wamp server. first introduce technology used. 1) adobe dreamviewer cs6 2) wamp server 2.0 3)ibm informix 64 bit steps followed install ibm informix 64 bit make odbc connection (system dns) successsful download php_pdo.dll , php_pdo_informix.dll , paste these .dll on "c:\wamp\bin\php\php5.4.12\ext" add below lines in php.ini below extension extension=php_pdo.dll extension=php_pdo_informix.dll *create below php code connection test ibm informix <?php $db = new pdo("informix:host=10.81.32.12; service=1504; database=db_cra; server='servername'; protocol=onsoctcp; enablescrollablecursors=1", "userid", "pasw") or die("could not connect data); ?> restart wamp server , execute page then got fatal error: uncaught exception 'pdoe

for loop - Turning a Data.Frame with 28441 Rows in it to a Dataframe with 28 Rows and 1000 Columns in R -

i have data frame 28441 zip codes , column in data frame. want turn 28 rows 1000 zip codes each in , 1 441 zip codes: i have tried following in r language: zip.codes<-read.csv('e:/my docments/zip_codes.csv', header= true, fill=true quote="\"", na.strings='ns', stringsasfactors=false) (i in 1:length(zip.codes)) { for(j in 1:1000) { new.zip.codes[j,i]<-zip.codes[i,j] } } following error: error in new.zip.codes[j, i] <- zip,codes[i, j] : incorrect number of subscripts on matrix each zip code unique , not repeated. what missing? appreciated. robert i assuming want once. if have number of lists of zip codes of different lengths need modify somewhat. zip<-seq(1:28441) #fake zip codes example zip[28842:29000]<-na #pads zip codes fit nicely in matrix zipmat<-matrix(data=zip,nrow=29, ncol=100) #now in 29 row 100 column matrix the on matrix() command has couple of options (dimnames, b

How to create a Class when its attributes are dynamic & variable in Java, C++ or any Object-Oriented Language? -

ok, in object-oriented language (ool), when creating class know in advance attributes. ex, item class should have fixed attributes (color, model, brand, price). just: public class item{ private string color; private string model; //etc more attribute here //& set & method attributes public string getcolor() { return color; } public void setcolor(string color) { this.color = color; } public string getmodel() { return model; } public void setmodel(string model) { this.model = model; } } but if attributes dynamic? ex, in 1 company, item attributes color, brand, in other company, don't have color & brand attributes have width, height, size... how create class accepts dynamic attributes in java, c++ or in ool? how create class accepts dynamic attributes in java, c++ or in ool? it depends on how want use this. in many cases, rework class contain

c# - Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs -

i using solr search server asp.net 4.5 application. i've installed solr on windows 8 laptop computer. according solrnet this documentation , need use specific attributes on pocos. the thing using entity framework , classes auto generated. there option assign type of solr attributed , make sure presistant , won't erased if suggested solution based on editing template (.tt) file. i want use entity framework, if not possible, copy pocos , create classes myself attributes. prefer searching solution allow me use solrnet entity framework. thanks. i suggest create separate classes map solr index schema, typically structure of ef classes , index schema not identical. way have clean separation between persistence classes (those auto-generated ef) , index mapping classes , can control how mapping between 2 occurs. recommend use of automapper assist translating objects ef solr , again needed.

playframework 2.1 - how to invoke a play application without hitting the URL (http request)? -

i'm using play application (using play version 2.1.0) rabbitmq , not have view component. invoke play application without hitting execution url (http://localhost:9000/<routing_info>) on server startup. would know if there way in play 2.1.0 version run application on server startup, mean bootstrapping. option available in play 2.1.0. i've read through documentation mentioned 1.2 version. please help!! play allows define 'global' object instantiated automatically play when application starts. in application.conf should find following: # global object class # ~~~~~ # define global object class application. # default global in root package. application.global=global.global on new play application, line commented out. i've uncommented , made point object called global in global package. can make ever want. your global object should extend globalsettings . in applications, use static initialiser block run code when class loaded: pu