Posts

Showing posts from June, 2014

ruby on rails - Add undefined fields in MongoDB -

i have created mongo model described here: http://docs.mongodb.org/ecosystem/tutorial/model-data-for-ruby-on-rails/ but it's creating schema. need add fields, don't know. can't describe in model. how should be? you may check dynamic fields. depending on odm using there ways of implementing it. mongoid can check here . mongomapper has similar implementation described in thread .

performance - Is including unused JavaScript files a bad practice? -

i use jquery in lots of websites, obvious reasons. include in header.php file. include other javascript libraries in end this: <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="http://example.com/js/classes.js"></script> <script type="text/javascript" src="http://example.com/js/common.js"></script> there more includes, , of them use in 1-2 pages. practice include these javascript files in every other page too? decrease performance? mean, know have downloaded first time, cached after it, won't they? so how including (without using it) affect performance? how cached files change situation? if affects performance, should like: <?php if (jsfileneeded) { ?> <script type="text/javascript" src="http://example.com/js/classes.js"></script> <?php } ?> what o...

c# - How to bind a list count to a label -

Image
i have datagridview binding list , label showing number of records. run same problem khash had. (so steal title). add or delete operations on grid won't update label. based on sung's answer, facade wrapper , create custom list inheriting bindinglist , implementing inotifypropertychanged . public class countlist<t> : bindinglist<t>, inotifypropertychanged { protected override void insertitem(int index, t item) { base.insertitem(index, item); onpropertychanged("count"); } protected override void removeitem(int index) { base.removeitem(index); onpropertychanged("count"); } public event propertychangedeventhandler propertychanged; private void onpropertychanged(string propertyname) { if (propertychanged != null) propertychanged(this, new propertychangedeventargs(propertyname)); } } however, throw exception when binding. cannot bind proper...

How are the magento enterprise banner xml nodes inserted into the layout xml? -

background i have taken on development of magento enterprise website has custom theme. when custom theme created base default templates used rather enterprise default templates , therefore theme doesn't have of enterprise functionality. i've setup vanilla magento enterprise install matches version number used on site (1.11.1.0) , i'm working through diffing 2 sites , adding functionality in 1 module @ time. however i've run hurdle how banner functionality works , therefore having problems trying debug missing custom theme them work correctly. what know the functionality works fine on vanilla enterprise site. there's no xml layout files banner module, makes sense created dynamically within admin section allows select page/block want insert banner widgets into. using commerce bug , looking @ compiled page layout xml banner xml nodes being inserted not being created programatically (via php) within other templates or blocks. i've looked right th...

ios - how to call a method that returns NSMutableAttributedString -

i have create method create nsmutableattributedstring partly bolded. having trouble calling return data should. this how have implements code //.h // creates bold portion of labels in toolbar - (nsmutableattributedstring *)createboldstring:(nsstring *)labelstring intrangea:(int)rangea intrangeb:(int)rangeb; //.m - (nsmutableattributedstring *)createboldstring:(nsstring *)labelstring intrangea:(int)rangea intrangeb:(int)rangeb { // ios6 , above : use nsattributedstrings const cgfloat fontsize = 12; uifont *boldfont = [uifont boldsystemfontofsize:fontsize]; uifont *regularfont = [uifont systemfontofsize:fontsize]; uicolor *foregroundcolor = [uicolor whitecolor]; // create attributes nsdictionary *attrs = [nsdictionary dictionarywithobjectsandkeys: boldfont, nsfontattributename, foregroundcolor, nsforegroundcoloratt...

qt5 - QT 5 Application Crashes With No Monitor -

i running qt desktop application on centos 6.4 qt 5 libraries. when start application vnc, of our servers not have monitors, application crashes. starting from: qapplication a(argc, argv); i have tracked down core file call qxcbconnection.cpp , line: xcb_create_window(m_connection, xcb_copy_from_parent, m_connectioneventlistener, m_screens.at(0)->root(), 0, 0, 1, 1, 0, xcb_window_class_input_only, m_screens.at(0)->screen()->root_visual, 0, 0); the problem is, if there no monitor connected then, m_screens empty, , therefore causes "index out of bounds" error. my question is: there way around this, or perhaps mimic monitor somehow? you may have found regression bug in qt, don't find relevant in qt4 qt5 changelog nor in qtapplication documentation . imho should not crash , , should unnecessary work (like in qt4). can choose type of instance want create. doc gives minimal example : qcor...

html - Css Media Queries Resolution Issue -

i wondering how can use css media queries detect screen resolution , make different page load if screen resolution under 1024x768? need know if can place query in master.css script? or need placed? sitemap (without java included) index.html (main page) about.html (about page) missing.html (404) small.html (the smaller version trying load) ie8.css (conditional css internet explorer 8) master.css (main stylesheet) you can serve different styles page based on width of browser viewport in various ways, such this: @media screen , (max-width: 1024px) { styles here } you can put anywhere in style sheets. be aware, though, can't use media queries load different page . that, you'd need kind of device detection script.

utf 8 - DateTime objects from MongoDB have unreadable characters in Object Definition -

whenever fetch data mongodb collection, , 1 of fields has datetime object, this: object(datetime�����w )[359] public 'date' => string '2012-12-12 00:00:00' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'america/caracas' (length=15) i when outputting var_dump utf-8 charset in browser, when using print_r, xdebug_var_dump, accessing public methods... i error if try output data of 1 of public properties: invalid utf-8 sequence in argument in (file>) i using mongodb 2.4.3. any suggestions? edit 1: thought symfony-related problem, using mongo shell , when insert new entry, have same problem, issue's not coming symfony, it's irrelevant, unless has fact db schema created symfony. the real issue defective installation of mongo extension php 5.4. ended using liip.ch's amazing php package os x , replacing mamp me.

angularjs ui-router parent state -

using angularjs , ui-router can i: a.) define custom variables when defining state (see 'data' below). success, wanted make sure proper. .state('parent', {url:'/parent', templateurl: 'views/parent.html', abstract: true, data: {stuff: 'stuff'}}) b.) have child state inherit variable data ( how? ) .state('parent.child', {url:'/child', templateurl: 'views/parent.child.html', data: parent.data}) ? you don't specify "data" child state, inherited parent/abstracted state. access : $state.current.data

Django read only/view permission on models + row level permission -

i making photo sharing application using django framework. stuck 2 problems 1) user has uploaded photo can edit photo. other users cannot edit photo. can see/view list of photos users. , can add photo under username 2) need define row level permissions 1 of functionality. eg - rating of photo other users. now, u can when u give write permissions user. if give write permissions, user able edit other stuff (name, album etc..) not want. want user can edit ratings. i tried searching answer not able any. would glad if can help 1) in picture class, have variable hold username of person uploaded picture. in editing view, make sure aren't confining editing ability username. 2) @ django tutorial @ https://docs.djangoproject.com/en/1.5/intro/tutorial01/ , head on part explain how create voting in poll app. should give foundation project.

c# - XNA game Development, update sprite -

would tell did wrong in code...i trying move sprite whenever left arrow on keyboard pressed. when run code game window open , shut off prtty quickly public class sprite { private texture2d texture; private vector2 position; public sprite(texture2d texture, vector2 position) { // todo: complete member initialization this.texture = texture; this.position = position; } public void draw(spritebatch spritebatch) { spritebatch.draw(texture, position, color.white); } void update(keyboardstate keyboardstate, gametime gametime) { // throw new notimplementedexception(); if (keyboardstate.iskeydown(keys.left)) { velocity = new vector2(-1, 0); position+= ((velocity) *(float) gametime.elapsedgametime.totalseconds); } } public vector2 velocity { get; set; } }

python - "execution_count" error when running a job on a remote IPython cluster -

i running ipython cluster (ssh) on remote linux machine, , using mac os x ipython use cluster. in ipython on mac write: from ipython.parallel import client c = client('~/ipcontroller-client.json', sshserver="me@remote_linux_machine") dview=c[:] dview.scatter('m', arange(100)) where '~/ipcontroller-client.json' file copied remote_linux_machine . works point. when try use parallel magic %px error: /opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/ipython/parallel/client/client.pyc in __init__(self, msg_id, content, metadata) 80 self.msg_id = msg_id 81 self._content = content ---> 82 self.execution_count = content['execution_count'] 83 self.metadata = metadata 84 keyerror: 'execution_count' same idea, when run cluster on localhost works perfectly. should parallel magic work @ remote ssh cluster case? the problem fixed:...

Bash: how can I use read to echo (or do things to) an array member -

array content somecommand=$(cat /etc/somelog) #pseudo array creation array=($somecommand) array length arraylen=${#array[@]} for loop iterates array length for (( i=0; i<${arraylen}; i++ )); adds someprefix (for readability ) $(($i + 1 )) appends number list (for clear options) starting @ 1 echo "$(($i + 1 )) ${arr[$i]/#/someprefix}" done printf "\n" echo "please enter 1-${arraylen} --> " asks user input read anwser stores value (a case statement woud better # replace loop - concept script) trying work. this need ### (i think?) echo "${array[$anwser]}" # things # you reading variable named $answer , indexing array $anwser .

Highcharts with inverted y-axis, but not inverted data? -

is possible invert y-axis, not data? have ranking should start 1 @ top, not @ bottom, columns should stay normal. thanks hints! there no easy direct way (afaik). there variety of approaches take, however. this example uses reversed axis , stacked columns: http://jsfiddle.net/jlbriggs/jvnjs/301/ stacking:'normal', it relies on adding second series difference between value , max, means must specify y axis max. i left second series light grey can see them, can set opacity 0 invisible. other options might include doing calculations on y axis label formatter display axis labels want without having touch data.

ios - Is there any library to get audio data in vorbis format with AVCaptureSession in iPhone? -

i have captured video frames , converted them vp8 data using following code : https://github.com/chris838/vp8-ios.git i want capture vorbis audio data according vp8 data available me in order combine vp8 data , vorbis data webm file. there available ios library fetching vorbis data ? thanks in advance there's ogg or may find audiolib helpful. there link ogg source code here

ios - Async image loading from url inside a UITableView cell - image changes to wrong image while scrolling -

i've written 2 ways async load pictures inside uitableview cell. in both cases image load fine when i'll scroll table images change few times until scroll end , image go right image. have no idea why happening. #define kbgqueue dispatch_get_global_queue(dispatch_queue_priority_default, 0) - (void)viewdidload { [super viewdidload]; dispatch_async(kbgqueue, ^{ nsdata* data = [nsdata datawithcontentsofurl: [nsurl urlwithstring: @"http://myurl.com/getmovies.php"]]; [self performselectoronmainthread:@selector(fetcheddata:) withobject:data waituntildone:yes]; }); } -(void)fetcheddata:(nsdata *)data { nserror* error; myjson = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; [_mytableview reloaddata]; } - (nsinteger)numberofsectionsintableview:(uitableview *)table...

How to override values in JMeter? -

Image
i facing situation currently, have 2 threads inside 1 thread group. both threads use different csv's. i've put 1 csv data set config in each thread. problem there variable called userid common in variable names in csv data set config both. due when first thread executes assigns userid value carried forward thread. for example, thread1 >> reads values csv >> assigns userid=1104. thread2 >> reads values csv >> cannot assign userid=1105 keeps previous assigned value userid=1104. i've tried sharing mode current thread doesn't seems work in case. please suggest way out. if have 2 csv data sets, same variable names, at same level in test plan tree, see behaviour describe. if both have variable called var1, example, have same value throughout level. you can use simple controller element, each csv data set config on own level, , variable values not shared. simple controller has no logic, other grouping other elements togeth...

payflowpro - Paypal recuring get no response from test account number -

i using these credit card test number test. got null response form of these number test paypal credit number. for example visa : 4012888888881881 got null response form number. not got error. number valid or changed . i found randomly . if got no response no error create recurring profile or not. i checked account, , show requests reaching paypal , paypal sending api response every request. successful, returned api error none less did generate successful response system. make sure code using correct, , set read response being sent back. can find sample code may here .

amazon web services - React on initialization errors for ec2 autoscale instances -

i have webserver running on ec2 behind elb scaled using aws autoscale. when new instance starts fetches recent application code git repository. what's best way react on errors during initialization? git server might not up/reachable disk might corrupt, git pull exists error (yes has happened me) this did: on start create file instance_starting once initialization finished delete file the elb health check accesses special url returns error 500 if instance_starting file exists a cloudwatch alarm reports me unhealthy instances

asp.net mvc 4 - Starting Multiple Visual Studio 2012 Web Applications in Tabs of a Single Browser Instance -

i have 2 asp.net mvc 4 projects in single solution in visual studio 2012. have solution set use multiple startup projects, action set start. when click start toolbar button, each project starts in different internet explorer browser window. but i'd 2 projects start in 2 tabs of single browser instance. there way that? thanks! the way know of is: add simple view in 1 of projects empty html. set project launch simple view startup page, , set other projects "don't open page, wait request". in head section of empty view, add following javascript script section: <script> // open project in newtab (works in ie) window.open('http://localhost:<otherprojectport>/otherprojectpage', 'tab1'); // many of these well, open other actions/pages project: window.open('@url.action("edit", "user", new { id=1 })', 'tab2'); // note different name // , open third page in original tab opens: doc...

.net - [System.Net.Dns]::GetHostEntry method resolves IP to HOSTNAME without PTR record? -

i trying use dns.gethostentry method hostname given ip dns server. according documentation , method first tries reverse lookup on ip address. in case successful when use dns.gethostentry . now, strange thing same ip nslookup doesn't give me anything. either times out or gives me error: unknown can't find 10.4.202.16: non-existent domain . when dns server (2008 r2), can not find ptr records in de reverse lookup zone. fact nslookup fails doesn't surprise me much. but going on here? dns.gethostentry using undocumented ways obtain hostname? i ran this, though different on laptop. called "redmonster". i'm @ facility i've been given ip address via dns. , if reverse lookup on ip address using nslookup address "123.123.123.123-dns.organization.ch". however, if use gethostentry reverse lookup, "redmonster.organization.ch". makes me think gethostentry doing "clever" when run in default way, , must using local cache ...

delphi - Indy10 TCP and asynchronous data exchange -

good morning all.i building delphi tcp server/client application using indy 10.0.52,with tidtcpclient , tidtcpserver. have problem receiving asynchronous responses server. here's part of sample code: client: procedure tfrmmain.clientsend(); begin tcpclient.iohandler.writeln('100|helloserver'); if tcpclient.iohandler.readln() = '1100' //here 1100 begin tcpclient.iohandler.writeln('200|are_you_ready_for_data?'); if tcpclient.iohandler.readln() = '1200' begin end; end; end; server: procedure tfrmmain.tcpserverexecute(acontext: tidcontext); var command:integer; var received,value:string; begin received := acontext.connection.iohandler.readln; command := strtoint(somesplitfunction(received,'first_part')); //here 100 value := somesplitfunction(received,'second_part'); //here 'helloserver' case command of 100:begin //do value... ...

java - Regular expression Notepad++ OK JDK 1.6 NOK -

as part of internship, have use regular expressions parse log file. it's java log , have problem detection of exceptions. in fact, regular expression works on notepad++ not java (1.6), matcher.find() take very, ..., long time, , find 0 match finally. this regular expression: (.*\berror\b.*)\r?\n((\tat|.*[ee]xception|\t\.\.\.|\r?\n|ora-).*\r?\n)+(^(?!.*error).+)\r?\n do know why ? thanks. back slash \ both escape character java programming language , regular expressions. therefore when slashes regular expressions inside java (and many other programming languages) have duplicate slash. for example write \\s instead of \s requires syntax of regular expression.

sql - Selecting joined distinct/last -

ok, have 2 tables, this: person: | id | name | +----+------+ | 0 | carl | +----+------+ | 1 | max | +----+------+ | 2 | lars | status | personid | submitted | status | +----------+------------+--------+ | 0 | *datetime* | 1 | +----------+------------+--------+ | 0 | *datetime* | 1 | +----------+------------+--------+ | 0 | *datetime* | 3 | +----------+------------+--------+ | 0 | *datetime* | 1 | +----------+------------+--------+ | 1 | *datetime* | 5 | +----------+------------+--------+ what want recive persons in user table among last submitted status. if use this: select distinct person.name username, status.status userstatus person left join status on status.personid = person.id i result this: | username | userstatus | +----------+------------+ | carl | 1 | +----------+------------+ | carl | 3 | +----------+------------+ | max | 5 | +----------+---------...

c# - Button is not working with Update Panel -

i have placed timer , label displaying countdown time in update panel. have placed next button displaying next question outside update panel. my problem button click not working update panel. without using update panel , timer works well. how can solve problem? i have tried place whole tools inside update panel. didn't me. here code: <asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> <table class="style1"> <tr> <td class="style2"> <asp:timer id="timer1" runat="server" interval="1000" ontick="timer1_tick"> </asp:timer> <asp:label id="lbltimer" runat="server"></asp:label> </tr> <tr> <td style="margin-left: 40px" class="style3"> <asp:label id=...

c# - keyboard hook as a windows service -

hi trying create application in c# hooks button clicks want application run before user logon. (so should hook user actions , can account password parents set). found out if want run before logon should service have crated one. read article http://www.codeproject.com/articles/7294/processing-global-mouse-and-keyboard-hooks-in-c sample program works fine (captures hooks if app minimized ) when lunched manually without windows form not working. when trued make without windows form failed. when lunching service not able display windows form (i dont want t create interactive service ) app not working. available create app not need windows form or run form hidden or , run before logon? p.s using windows 7 . in windows 7 service cannot interact user desktop. impossible. it security reasons, describing.

javascript - How to get Id in ext.net, Code line return null (extjs)? -

i try use below line id, works fine in ext.net v1.x create problem v2.x ie10. var f=ext.get('<%=btnid.clientid%>'); as same function does't work extjs control. same thing happen with: var jj = ext.get(<%=grd.clientid %>.getview().getheadercell(0).childnodes[0]); ok ... in v2.x, can access controls without ext.get. like; var f=<%=btnid.clientid%>;

jquery - Spring MVC autocomplete works just in one page in the eclipse project -

i applied tutorial doing autocomplete in project alright when put autocomplete in page want put same code in page , not working. input fileds in 2 pages have same name of "id" , include necessary files in second page in first. wrong ? thank you. this code of second page : <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <%@ page import="org.springframework.security.core.context.securitycontextholder"%> <%@ page import="org.springframework.security.core.userdetails.userdetails"%> <%@ page import="org.springframework.security.core.grantedauthority"%> <%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <%@ taglib prefix='security' uri='http://www.springframework.org/security/tags'%> <%@ taglib prefix="c" uri="http://jav...

c++ - decltype as a return type in class member function -

i got error compiling below code. struct b{ double operator()(){ return 1.0; } }; struct { auto func() -> decltype(b()) { return b(); } b b; }; however, if reorganize a , compiles. gcc 4.8 said 'b' not declared in scope. struct { b b; auto func() -> decltype(b()) { return b(); } }; so, wrong first?? the definition of class processed 2 passes: first member declarations collected, including function signatures , , bodies of definitions parsed. the function body therefore has access member declarations, including subsequent ones, function prototype sees preceding declarations.

linux - How to preempt one process from another process/kernel thread? -

i have process p , kernel thread kt. want synchronize execution of p kt. kt event handler. requirement kt should not go ahead processing events if p running. need pause p , go ahead event processing in kt , resume p. question is, kt, how force preempt p ? resuming later, can use wake_up_process(). for scheduling out process, commonly used trick set state task_interruptible , call schedule(). work if have task_struct pointer of p saved, kt, schedule out p, set state of p(instead of current) task_interruptible , call schedule ? hack, work ? see clean way missing ? is there signal can send p ask preempt ? you cannot asking. sure set state task_interruptible process/thread running on same or on different cpu/core. can't invoke schedule() on cpu/core (for same reason can't invoke other function on cpu/core). consider schedule() not take cpu/core id argument how tell core1 should reschedule? another popular solution these types of synchronization requirements use r...

c# - Six channel output with NAudio? (Or suggestions for other .NET library that supports it?) -

i've written method in c# using naudio outputs 2 channel sound, fails @ 6 channel sound. when using waveout, 'mmexception unhandled: invalidparameter calling waveoutopen' here's code: public class audiooutput { private waveout latestaudioout = null; private wavememorystream latestmemorystream = null; public void playaudio (byte[][] buffers, waveformat format) { if (latestaudioout != null) { latestaudioout.stop(); latestaudioout.dispose(); } latestaudioout = new waveout(); if (latestmemorystream != null) { latestmemorystream.dispose(); } int longestchannellength = 0; foreach (byte[] b in buffers) { if (b != null) if (b.length > longestchannellength) longestchannellength = b.length; } byte[][] finalisedbuffers = new byte[buffers.length][]; (int = 0; < buffers.length; ++) { finalisedbuffers[i] = new byte...

perl - How to compare array from file with sql database query? -

this question has answer here: why file content/user input not match? (missing chomp canonical) [duplicate] 1 answer i tried select columns table @ database same on row in array in file. example: table: id name 1 2 b 3 c file: b i want select , b. my source: use dbi; use cgi; $file = '.\input.txt'; # name file open(file, $file) or die("unable open file"); @data = <file>; foreach $line (@data) { #print $line; $sth = $dbh->prepare("select columna table columna '%$line%'"); $sth->execute; $result = $sth->fetchall_arrayref; foreach $row ( @$result ) { print "- "; print "@$row\n"; print "<br />"; } } but write last line of select hmmm... output b output want b i tried this: input:...

hdfs - Hadoop datanode cannot communicate with KDC but the kinit works -

hadoop datanode cannot communicate kdc kinit works. sudo kinit -k -t /etc/hadoop/conf/hdfs.keytab hdfs/symbio5.us-west-1.compute.internal@us-west-1.compute.internal and udp port ok. nc symbio5.us-west-1.compute.internal -v -z -u 88 connection symbio5.us-west-1.compute.internal 88 port [udp/kerberos] succeeded! but in hadoop kerberos debug output, said "receive timed out". krbasreq calling createmessage krbasreq in createmessage krbkdcreq send: kdc=symbio5.us-west-1.compute.internal udp:88, timeout=30000, number of retries =3, #bytes=216 kdccommunication: kdc=symbio5.us-west-1.compute.internal udp:88, timeout=30000,attempt =1, #bytes=216 sockettimeoutexception attempt: 1 kdccommunication: kdc=symbio5.us-west-1.compute.internal udp:88, timeout=30000,attempt =2, #bytes=216 sockettimeoutexception attempt: 2 ...

If condition inside a target in a Makefile -

i want this, want run svn commit if file has changed. file has timestamp changes. if more timestamp changes , want commit file. the makefile have similar this. if condition not working properly. getting executed when if not satisfied. can me out problem in if here. update_state_file : $(eval no_lines_changes_in_state = $(shell svn di state/build.state --diff-cmd=diff -x --normal | grep "^[<>]" | wc -l)) @echo $(no_lines_changes_in_state) ifneq ($(strip $(no_lines_changes_in_state)), 2) ifneq ($(strip $(no_lines_changes_in_state)), 0) @echo $(no_lines_changes_in_state) $(svn) commit; $(svn) update; endif endif you cannot mix make conditionals inside command rules. make conditionals preprocessor statements in c or c++; handled file read in, before processing (like running rules) performed. if want conditionals inside rules have write rule using shell conditionals, not make conditionals: upda...

c# - Returning Expression<> using various class properties -

i have this: public expression<func<message, bool>> filterdata() { switch (this.operatorenum) { case filterparameteroperatorenum.equalto: return message => !string.isnullorempty(message.body) && message.body .equals(this.value, stringcomparison.invariantcultureignorecase); case filterparameteroperatorenum.notequalto: return message => !string.isnullorempty(message.body) && !message.body .equals(this.value, stringcomparison.invariantcultureignorecase); case filterparameteroperatorenum.contains: return message => !string.isnullorempty(message.body) && message.body.indexof(this.value, stringcomparison.invariantcultureignorecase) >= 0; case filterparam...

python - append a list into end of list in list -

is there way 'merge' 2 lists item in 1 list can appended end of list in list? example... a2dlist=[['a','1','2','3','4'],['b','5','6','7','8'],[........]] otherlist = [9,8,7,6,5] thefinallist=[['a','1','2','3','4',9],['b','5','6','7','8',8],[....]] i'm not sure if matter a2dlist made of strings , otherlist numbers... i've tried append end thefinallist=[['a','1','2','3','4'],['b','5','6','7','8'],[.......],[9,8,7,6,5] >>> a2dlist=[['a','1','2','3','4'],['b','5','6','7','8']] >>> otherlist = [9,8,7,6,5] >>> x, y in zip(a2dlist, otherlist): x.append(y) >>> a2dlist [['a', '1', ...

fortran77 - Function pointers in fortran -

is possible have function pointers in fortran? right have code lines this: subroutine flag(iflag,a,b) integer n, a, b, ii, iflag ii = 1, n if (iflag.eq.0) a+b else a-b end return end the variable "n" has huge value , run code, feel wasting lot of time "if" command. possible write function pointer (i not sure mean that), such @ code this: subroutine flag(iflag,a,b) *depending on iflag subroutine flag automatically precompiled call either flag_plus or flag_minus* return end subroutine flag_plus(a,b) integer n, a, b, ii ii = 1, n a+b end return end subroutine flag_minus(a,b) integer n, a, b, ii ii = 1, n a-b end return end if possible can save lot of time avoiding "if" loop. remotely possible? in fortran 77 can have limited variant of function pointers, namely can pass name of procedure argument procedure (a function pointer, essentially). cannot have variable contains address of proc...

facebook javascript sdk - Mobile Safari FB.login Oauth Redirect Error -

i have mobile web application integrates facebook graph api. basically, uses js sdk obtain details viewing user can use render user specific content. i use fb.login function have user login facebook app. should work follows: js on pages detects user has not logged in facebook app user given button click fire fb.login user redirected facebook page authorise app , login user redirected mobile web application js on pages detects user is logged in facebook app, polls user data graph , renders it. this works fine on android, redirect step not work on mobile safari the user gets error referring entityref, looks content-type being sent browser xml content includes illegal character: error on line 1 @ column 49: entityref: expecting ';' this actual link generating error: https://m.facebook.com/dialog/oauth?display=touch&domain=cgfoodscomp.herokuapp.com&scope=email&e2e=%7b%7d&app_id=135937919902029&locale=en_us&sdk=joey&client_id=...

java - Text file is processed using Hashmap containing List(of maps) as values-How to process? -

my text file contains datas like... dept->studentid-studentdata(name , email).. it-> 1->john->john@ymail.com cse->2->santosh->s@gmail.com it->3->mike->mike@ymail.com first,i have stored studentid key , studentdata , dept values in hashmap , added in arraylist(list of multiple objects-each list object each row). now, dept key, how retrieve studentid , studentdata list? say, map key, how take data list , store value key? ( should display both matching rows it). new working collections , in advance given complete this. why not use student object instead of arraylist. make code more organized. make hashmap < string, student > string student id , student class student attributes. class student{ string name; string dept; string email; /** getters & setters **/ } so next time go map.get("student_id_here").getname() or getdept() etc..

solr - Connections are hanging in CLOSE_WAIT even after successful shutdown of Camel context/ routes -

i have 1 question regarding camel route shut down. below code snippet route - from("seda:" + this.getdumpidentifier() + "_insertinsolr?concurrentconsumers=50&polltimeout=1") // use streaming increase index throughput .setheader(solrconstants.operation, constant(solrconstants.operation_insert_streaming)) .setexchangepattern(exchangepattern.inonly) // define solr endpoint , options .to("solr://" + this.getsolrendpoint() + "?defaultmaxconnectionsperhost=50&maxtotalconnections=150&maxretries=3&allowcompression=true") // .log(logginglevel.debug, "successfully indexed document id=${header.document_id}.") // end route .end(); i m using org.apache.camel.main.main start camel context (this route). on successful processing m doing - camelmain.stop(); camelmain.shutdown(); but after succes...

c# - Search within Enum attribute -

this question has answer here: get enum enum attribute 4 answers i want check in enum passed code exists in of enum or not. problem enum defined below using code attribute. public enum testenum { none, [code("fmng")] functionsmanagement, [code("inst_mast_mgt")] masterinstmanagement } [attributeusage(attributetargets.field, allowmultiple = false)] public class codeattribute : attribute { readonly string _code; public string code { { return _code; } } public codeattribute(string code) { _code = code; } } now, have string available (e.g. "fmng") , want search enum enum exists passed string in enum attribute. how can check/get enum using or passing string? tr...

group concat - MySQL group_concat query help needed -

i have mysql database.i have table contains list of procedures , estimated time suggested different developers. as follows: proc_name user_id est_time ------------------------------- 'a' 1 20 'a' 3 15 'b' 2 16 'b' 4 18 'c' 1 20 now need output this a|1_20|2_0 |3_15|4_0 b|1_20|2_16|3_0 |4_18 c|1_20|2_0 |3_0 |4_0 if user not posting hours proc_name , '0' printed. any appreciated. this isn't "group_concat". example of pivoting. select proc_name, concat('1_', max(case when user_id = 1 est_time else 0 end)), concat('2_', max(case when user_id = 2 est_time else 0 end)), concat('3_', max(case when user_id = 3 est_time else 0 end)), concat('4_', max(case when user_id = 4 est_time else 0 end)) t group proc_name i find strange, though, putting...

iphone - How to disable pan mode for certain view controllers in the MFSideMenu class? -

i'm using mfsidemenu github link in project. it's working, disable in viewcontroller. i added in viewcontroller doesn't disable panmode: #import "mfsidemenucontainerviewcontroller.h" -(void) viewwillappear:(bool)animated { mfsidemenucontainerviewcontroller *sidemenu = [[mfsidemenucontainerviewcontroller alloc] init]; sidemenu.panmode = 0; } my plan re-enable panmode in viewdiddisappear method. fyi in mfsidemenucontainerviewcontroller.m file if add self.panmode = 0; - (void)setdefaultsettings {self.panmode = 0;} disable menu pan except disables entire app of course. i must not referencing mfsidemenucontainerviewcontroller property panmode correctly. in appdelegate: .h @property (nonatomic, strong) mfsidemenucontainerviewcontroller *container; .m mfsidemenucontainerviewcontroller *container = [mfsidemenucontainerviewcontroller containerwithcenterviewcontroller:self.navcont...

sql server - T-SQL: Get top n records by column -

struggling what's simple problem. have query this: ;with rankeddata ( -- big, complex subquery) select userid, attributeid, itemid rankeddata rank = 1 order dateventdate desc the sub-query designed grab big chunk of interlined data , rank itemid , date, rank=1 in above query ensures unique itemids, ordered date. partition is: rank() on (partition itemid order dateventdate desc) rk the problem want top 75 records each userid, ordered date. seeing i've got rank inside sub-query sort out item duplicates date, can't see straightforward way of doing this. cheers, matt i think query should like select t.userid, t.attributeid, t.itemid ( select userid, attributeid, itemid, rowid = row_number() on ( partition userid order dateventdate ) rankeddata ) t t.rowid <= 75

python - SQLAlchemy MySQL STRAIGHT_JOIN -

my code executes queries fine in sqlalchemy orm layer so: session().query(model_a).join( (model_b, == somethingelse) ).join( (model_c, == somethingelse) ) # etc ... but i've come across query taking minutes finish. turns out mysql blame because it's not joining in order ask to. adding straight_join after select like: select straight_join table_a.id table_a inner join table_b ... fixes problem can't figure out if there's way make sqlalchemy add straight_join after select . docs suggest hints can added select() via with_hint(table_a, "straight_join") adds text in wrong place causes mysql syntax error. involve stepping outside of orm not ideal. i've tried using various mysql debugging techniques explain , analyze table etc... can't seem find out why mysql choosing wrong path. manually switching around order of joins doesn't seem either i'm in position need straight_join work. any ideas? we support directly ca...

c# - Import ForeignKey values by ComboBox -

i'm trying import foreignkey values using combobox , combobox loads string values , foreignkey type int ,i tried convert tostring() ,then got error: "the left hand side of assignment must variable property or indexer" shippingdocumentdataclassesdatacontext dc = new shippingdocumentdataclassesdatacontext(); t_tracking newinvoice = new t_tracking(); newinvoice.supplierid.tostring() = combobox1.text; dc.t_trackings.insertonsubmit(newinvoice); dc.submitchanges(); any appreciated. this line wrong: newinvoice.supplierid.tostring() = combobox1.text; you trying assign value method call. instead line should be: newinvoice.supplierid = int32.parse(combobox1.text); or safer way: int id = 0; if (int32.tryparse(combobox1.text, out id)) { //we valid integer combobox newinvoice.supplierid = id; dc.t_trackings.insertonsubmit(newinvoice); dc.submitchanges(); } else { //wrong value ha...

vector - Trying to calculate the slope of a plane from a normal -

i have set of 3d normal vectors points on 3d mesh, , need calculate slope of area below each of them. have no idea how this. don't need x or y slope, need total incline of point in question (although fair, don't know how derive total slope x , y slope individually, part of problem). did see this article , couldn't make heads or tails of it... vectors outward-facing. if can explain 1 me, i'd grateful. if have normal vector, you're there. need angle (look dot product) between normal , vertical line (what vertical means depends on application). if your normal vectors normalized (have length 1) , vertical (0 0 1), cosine of slope angle z coordinate of normal vector. to demonstrate this: take pen , let stand on table. table's normal vector. angle between vector , vertical line zero, table has no slope @ all. if tilt table amount, angle between normal , vertical line increase same amount.

ios - Cannot get image and no visible interface -

when use saving code error @ interface "secondviewcontroller" decalres selector getcachedirectorypath . used @interface getcachedirectorypath : uiimagepickercontroller in .h file. below .m file -(uiimage *)getimagefromcachewithname:(nsstring *)name {nsstring *_imagepath =[nsstring stringwithformat:@"%@/%@.png",[self getcachedirectorypath],name]; if([[nsfilemanager defaultmanager]fileexistsatpath:_imagepath]) {uiimage *_image =[uiimage imagewithcontentsoffile:_imagepath]; return _image; } return nil;

sql - how to do calculations with qelement results in xml? -

i have xml code returns result sql query: <qelement fname = "machine_dt" dbname="db"> declare @dt int set @dt =(select top 1 [value] [db].[dbo].[configdbe] [line] = '1' , [name] = 'hello') select isnull(@dt,0) </qelement> how can use result perform calculations it?

JMETER + query regarding Mysql database -

i using wordpress application , running jmeter perform load test on "wordpress" app. when creating blog, capture through jmeter via proxy , 1 blog created, new record in mysql database id 2. when run again same suite of jmeter, results new records not added mysql still same id 2 used. if no of threads 2 , loop count 1, 2 new records added mysql? don't see happening. need clarification on this. yes 2 records should created. once record, need variabilize dynamic before replaying, typically use regular expression extractor extract id example , can use ${}

C++, class with method and enum type - can method and enum value have same names? -

i have following class: class washm_t { public: enum door_t { closed = 0, open = 1 }; private: door_t door_state ; public: int open() ; }; the problem class open name defined both name of method inside of class , value of enum type. the question is: can somehow modify code both open names work inside of class or should pick other name open() method or open enum type value? this how open() function looks like: int washm_t::open() { if(door_state == open) // ~fails, 'open' interpreted name of method // not name of enum type value return 1 ; else return door_state = open, 0 ; } in c++11 can use enum class : enum class door_t { closed = 0, open = 1 }; but have refer door_t::open instead of open . has advantages , disadvantages of verboseness. enum class in these cases name conflict likely, , adds generic prefix enumerators of enumeration. (actually, in c++1...

oop - MVC - Is It Wrong To Redirect From Model -

i ask whether it's approach redirect within model instead of controller. the reason want because easier unit test redirection model (i pass mock redirector object model in tests) opposed controller more difficult unit test. keeps controller thinner in controller create instance of model , pass parameters request object. there not single if/else in controller way. is bad practise? neither controller nor model should redirecting anywhere. http location header form of response, strictly in purview of views. model layer deals business logic, should oblivious existence of presentation layer. basically, goes down this: controllers handle input, views handle output . http headers part of output. note: when dealing rails clones, common see redirects performed in "controller". because call "controller" merger of view , controller responsibilities. side-effect of opting replace real views simple templates 3rd side of triad.

windows - Check network activity in C++ -

is there way check if there network activity in system. don't want send or receive data want know if there type of network activity going on. know socket programming , have developed sockets send , receive data. specifically, don't want use network if in use. it great if can share resource. in advance.

php - SoapClient result "failed to open stream: HTTP request failed" -

i'm trying open socket between server , other server, returns following warring msg : soapclient::soapclient() [soapclient.soapclient]: failed open stream: http request failed my soapclient should connected using specific ip, i'm using following code: $aopts = array('socket' => array('bindto' => 'my ip')); $rstreamcontext = stream_context_create($aopts); $client = new soapclient($this->_wsdl_test_url, array('stream_context'=>$rstreamcontext)); the server keep giving me same warning, failed open stream: http finally fixed, problem encryption of file, put utf8 without bom instead of utf8

android - Update APK error -

after making changes project have uploaded google play. time after i've tried update (google play has been refresh application info , saw new version number) i've got error - "error retrieving data server rpc:s-5:aec-0...". same report appears on other devices (5pcs) , users began mail me same problem. searching gives me this support report . after minutes of googling found solution - reconnect google account , works me. have 40k users - can them all? i've implemented new fancy features in game , available new users. so, question - faced such problem? have done solve this?

android - Take picture with camera before starting new activity -

i have activity take picture upon touch of screen. after taking picture, i'd switch different activity. structure of code looks following: class myactivity extends activity implements ontouchlistener { ... @override public boolean ontouch(view v, motionevent event) { mcameraview.takepicture(); // intent intent = new intent(whatever); // startactivity(intent); return false; } } as shown, if commented out startactivity , picture taken , saved correctly. if attempt start activity after taking picture, picture not saved correctly (size 0). don't know sure if picture taking in separate thread or not, if is, should eventually saved, doesn't appear case. idea how resolve this? start activity @ end of camera.picturecallback() mcameraview.takepicture(new camera.shuttercallback() { @override public void onshutter() { log.e("shutter closed",...

asp.net mvc - Razor intellisense & external assemblies -

i have external assembly named t4mvcextensions using system.web.mvc namespace. classes within assembly in system.web.mvc namespace. in project have view , trying use extension methods reside in assembly. the system.web.mvc namespace has been added (by default) config file. the view cannot provide intellisense these extension methods (with red underline), compiles without runtime extensions. how can make sure intellisense works correctly? the output folder set different folder (plugin architecture). razor expects references present in bin folder. adapted project output folder normal one. post-build events copy dll files towards other folder. so make sure references in bin folder razor.

how to set formatting of all textbox in asp.net website with css, without set cssclass property of each textbox -

i working on asp.net web site. want set font, color , background color of textbox in website. want css. but dont want assign "cssclass" property of each textbox. and textbox want set formatting in requiredfieldvalidator. is possible set globally in asp.net css just add in css file input[type=text] { background-color:black; font-family:callibri; color:white; } this style applied on every textbox