Posts

Showing posts from February, 2010

javascript - A couple of issues with JSHint: 'is defined but never used' and 'is not defined' -

i have application pretty modular , such, jshint giving me 'x' defined never used error. my setup goes this: app/assets/scripts/bootstrap.js: var x = 5; app/assets/scripts/kickstart.js: console.log(x); and here's output jshint: app/assets/scripts/bootstrap.js line 1 col 6 'x' defined never used. app/assets/scripts/kickstart.js line 1 col 13 'x' not defined. 2 problems i know /* exported x */ cumbersome if have lots of variables this. is there anyway solve these 2 issues without disabling specific options? because come in handy in other, more important, situations. you can add @ top of file. /*jshint unused: false, undef:false */ notice options can applied specific scopes. works unused , apparently not undef . (function () { /*jshint unused: false */ // stuff }());

Windows Task Scheduler running an Excel VBA script -

i have vba script in excel wish run every morning. want use windows task scheduler run vba script. i use windows task scheduler run automated matlab process. have done putting path of matlab exe in program/script box , putting other parameters in add arguments & start in text boxes. possible similar excel & if how? i have seen lots of people mention writing vba script not wish do.

arrays - How to add set as wallpaper option in following code in Android -

i creating swipe action in android app. working perfectly. want create set wallpaper option user can set current image wallpaper. add code. not working. please me make current image wallpaper. code- public class fullimageactivity extends activity { int position; linearlayout full; button btn; public integer[] mthumbid = { r.drawable.kri1, r.drawable.kri2, r.drawable.kri3, r.drawable.kri4, r.drawable.kri5, r.drawable.kri6, r.drawable.kri7, r.drawable.kri8, r.drawable.kri9 }; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.full_image); // intent data intent = getintent(); // selected image id position = i.getextras().getint("id"); full = (linearlayout) findviewbyid(r.id.full); btn = (button)findviewbyid(r.id.btn);

How to include opos service objects and controls in c# application? -

i want write small c# application using opos controls communicating through serial comm port . i have opos dll . i have installed opos commoncontrolobjects . to use instance of controls in application how should include these controls in app. (for eg: want include msr, sigcap controls similar button control in app) or can included components in project. if how can done? go toolbox , right-click on it. then select -choose items-. having done this, browse folders find opos dll. last, add items want.

sql - Is looping through IQueryable the same as looping through a Datareader with Reader.Read() in C# -

sorry long title :) i couldn't find answers , question has been circling through head time now. short summary of question @ end. basically i'm wondering if linq entities/sql loops through datareader before maps resultset 1 of entities/sql classes or mapped. iqueryable have loop through data reader before can loop through iqueryable. show mean in code i'm wondering if foreach(object o in someiqueryableobject) { ...do stuff object } will result in either a: while(reader.read()) { someiqueryableobject.add(reader.translaterow()); } //now iqueryable has been loaded objects , can loop through //with above code foreach(object o in someiqueryableobject) { ...do stuff object } or result in b: while(reader.read()) { ...do stuff object } //iqueryable doesn't have loop through reader //before can loop through iqueryable. short summary: when use foreach on iqueryable, equivalent of looping through datareader reader.read() afaik ef use s

java - Sessions showing null error -

i have jsp page, xyz.jsp in i've set session request.getsession().setattribute("path", loc); and in a.java i've used session , sent response jsp page, string fpath = request.getsession().getattribute("path").tostring(); but, when use same session value in b.java getting null pointer exception. my.jsp->on button click->a.java->get session1->send response my.jsp->my.jsp reloads->b.java trying use session1->nullpointerexceptionerror i've tried, using different session variables session.setattribute("session1", loc); session.setattribute("session2", loc); creating new session variable in a.java , access same in b.java still same error. my.jsp looks like, string loc = "/u/poolla/workspace/firstservlet/webcontent/web-inf/" + ip +"/" +timestamp; session.setattribute("path", loc); a.java looks like protected void dopost(httpservletrequest request, https

sql - Joining to tables while linking with a crosswalk table -

i trying write query de identify 1 of tables. make distinct ids people, used name, age , sex. in main table, data has been collected years , sex code changed 1 meaning male , 2 meaning female m meaning male , f meaning female. make uniform in distinct individuals table used crosswalk table convert sexcode correct format before placing distinct patients table. i trying write query match distinct patient ids correct rows main. table. issue sexcode has been changed. know use update statement on main table , changes of 1 , 2 m , f. however, wondering if there way match old new sexcodes not have make update. did not know if there way join main , distinct ids tables in query while using sexcode table convert sexcodes again. below example tables using. this main table want de identify ---------------------------- | name | age | sex | toy | ---------------------------- | stacy| 30 | 1 | bat | | sue | 21 | 2 | ball | | jim | 25 | 1 | ball | | stacy| 30 | m

mysql regex match any character except line break -

i use regex using regexp instruction in mysql query. regex contains rule character except line break. select * column regexp 'exp1.*=*.*exp2' but mysql seams treat .* character including line break any ideas how change regex match character except line break thanks depending on line ending style, either use [^\n]* match other line feeds, or [^\n\r]* match other line feeds , carriage returns.

c# - AutoMapper mapping nested List object -

i trying map nested list dto object, not working. here tried. returns null. error is: an exception of type 'automapper.automappermappingexception' occurred in automapper.dll not handled in user code public class ordersview_dto { public int orderid { get; set; } public string ordernumber { get; set; } public float? ordertotal { get; set; } public string lastname { get; set; } public string firstname { get; set; } public list<productsdto> productsdto { get; set; } } public class productsdto { public int id { get; set; } public int orderid { get; set; } } this how mapping: mapper.createmap<orderheader, ordersview_dto>() .formember(h => h.productsdto, k => k.mapfrom((m => m.orderlines))); ienumerable<orderheader> orderslist = new ordersrepository().getorders(); ienumerable<ordersview_dto> ordersflow = mapper.map<ienumerable<orderheader>, ienumerable<orders

c++ - Keeping two sorted vectors linked by pointers -

(yes homework) i trying create simple database person identified name + address combination or unique account number. need able add/delete/access information person when provided acc number or name + addr. i have created version works without account (using overloaded operator < searching in database lower_bound), trying add account feature. here i've got: struct sperson { string s_name, s_addr; int s_income, s_expense; saccount * s_accountptr; sperson ( const string &, const string & ); // constructor }; struct saccount { string s_account; sperson * s_personptr; sperson ( const string & ); // constructor }; the idea have vector of accounts , vector of people , keeping them linked pointers. seemed simple until came across these questions: if create object , insert vector, copy of object created , inserted? or original object? what happens addresses of objects in vector when insert it? can make work somehow? bool

tikz - Designing multivariate density plot in R -

Image
i saw appealing multivariate density plot using tikz , wondering if there way replicate plot own data within r. not familiar tikz, found reference seems imply may able use feature within r. http://www.texample.net/tikz/examples/tikzdevice-demo/ in short, best way produce plot similar (different distribution of course) 1 shown below using 2 data samples provided? here sample data can used create distribution plot. # sample data var1 <- exp(rlnorm(100000, meanlog=0.03, sdlog=0.15))/100 var2 <- 1-(var1 + rnorm(100000, 0, 0.01)) here reference page found original chart https://tex.stackexchange.com/questions/31708/draw-a-bivariate-normal-distribution-in-tikz you start persp function draw 3 dimensional plot (if data rather formula need use form of density estimation first, example plot looks smooth enough based on formula rather estimated data). use return value persp project additional plotting info. there may option using rgl package, seem remember has

c - Unix system call to print numbers in ascending then descending order -

i have small program needs print numbers in following format: 0 1 2 3 4 3 2 1 0 which try accomplish c code: int main() { int i; (i = 0; < 5 && !fork(); i++) { printf("%d ", i); } wait(null); return 0; } but prints 0 1 2 3 4 0 1 2 3 0 1 2 0 1 0 and can't figure out how omit digits. can see what's wrong? each iteration fork s new child. parent exits loop , wait s child, , child prints iteration number. however, because there no newline, characters remain buffered. however, each fork duplicates buffer in current state. so, each child inherits of printed values ancestors, , waits child die before exiting. so, last child exits, buffers this: parent: "" child-0 : "0 " child-1 : "0 1 " child-2 : "0 1 2 " child-3 : "0 1 2 3 " child-4 : "0 1 2 3 4 " child-4 exits (because wait not block), causing stdout buffer flushed. causes child-3

node.js - Installing OpenCV on Node problems -

i have installed dependencies , have compilers installed etc. when try install opencv in node.js node package manager, following error: /bin/sh: pkg-config: command not found gyp: call 'pkg-config --cflags opencv' returned exit status 127. while trying load bind has had same problem?

python - ImportError for jsonrpc -

Image
i trying follow this walkthrough on how use serviceproxy in jsonrpc . i followed directions getting error no import of serviceproxy . here code using: #!usr/bin/python import sys import json jsonrpc import serviceproxy givex = jsonrpc.serviceproxy() print "foo" which resulting in: would able me out ideas on how fix this, or have suggestion better jsonrpc library use. the tutoral following seems outdated. try from jsonrpc.proxy import jsonrpcproxy givex = jsonrpcproxy.from_url("http://localhost/url/of/your/service.py")

How to remove index.php in url in zend framework -

i have installed zend framework website 1 server server. eg: http://localhost/test/html ---- website url where test folder---- zend framework files kept there.... index.php file under html folder.... , below display code index.php.... my website runs link "http://localhost/test/html" where test folder this below .htaccess code rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l] this index.php file under test folder set_include_path('.' . path_separator . get_include_path() . path_separator . '../library' // . path_separator . '../application/classes/' // . path_separator . '../application/classes/forms/' // . path_separator . '../application/models/' . path_separator . '../application/default/classes/' . path_separator . '../application/default/classes/forms/' . path_separator .

android - How to make sure the Broadcast Receiver is disconnected -

i wrote simple broadcast receiver catches incoming calls , starts activity caller's number: package com.example.nrsearch; import android.content.broadcastreceiver; import android.content.context; import android.content.intent; import android.telephony.phonestatelistener; import android.telephony.telephonymanager; import android.util.log; public class callreceiver extends broadcastreceiver { public callreceiver() { } public context context; @override public void onreceive(context context, intent intent) { log.i("callreceiverbroadcast", "onreceive() called. "); this.context = context; telephonymanager telemgr = (telephonymanager)context.getsystemservice(context.telephony_service); phonestatelistener psl = new phonestatelistener() { @override public void oncallstatechanged(int state, string incomingnumber) { log.i("callreceiverbroadcast", "oncallstatechanged() called. "); switch (

html - Horzontal list - bullet equal distance/centered between list items -

i bullet in horizontal list in middle/center between each list item. want bullet centered between each item here css code: .tags-mid { padding: 20px; margin-top: 15px; text-align: center; } .tags-mid ul { font-size: 25px; font-family: 'open sans', sans-serif; } .tags-mid li { display: inline; line-height: 25px; padding-right: 20px; padding-left: 20px; } .tags-mid li:after { content: " · "; } .tags-mid li:last-child:after { content: ""; } .tags-mid { color: #000; text-transform: uppercase; text-decoration: none; } .tags-mid a:hover { color: #000; text-decoration: none; } try applying padding :after pseudo element rather list items. here link jsfiddle: http://jsfiddle.net/ged4k/

java - Working with data from table -

i wondering if advice on implementing algorithm creating jfreechart. basically, extracting data jtable contains information patients. there age categories patients such 20-26, 26-30, 31-35, 35-40, 50-55, 55-60 etc. there 30 of them , every patient belongs corresponding age category. there button on top of jtable opens frame containing age distribution graph. thinking of doing: create integer variable every category loop through age details patients in jtable compare variables jtable data , increment 1 if there match (lots of if statements go in loop) store categories names , amount of people registered under every category in hashmap pass map chartframe i suppose might relatively way of doing wondering if possibly suggest way of avoiding having create variable every category , having comparisons using 30 if statements. edit: not have patient's exact age - category belong to. i've assumed you've got own class agerange stores range of ages. can stor

Copy the input value to a div with jQuery -

i'd implement functionality, if user clicks on date datetime-picker window, value gets copied into div class. here html code sample: <input type="text" class="start_time" id="time2" name="beginn" placeholder="00:00" style="width: 35px" > <div class="start_time_paste"> paste here value datetime input!! </div> here jquery code: jquery('#time2').datetimepicker({ datepicker:false, format:'h:i', step: '30' }); jquery('#time2').on('change', function() { if(jquery(this).val() === '0') { console.log("läuft"); var new_start_time = jquery('.start_time').val(); jquery('.start_time_paste').html(new_start_time); } }); here jsfiddle example: http://jsfiddle.net/c374e/ i don't know i'm doing wrong :/ hope can me. try

java - How to dynamically create a form based on submitting the first form -

for eg: 1) have 1 text box , submit button if person adds value , select submit button text box value sent java program internal calculations made , returned jsp page based on values new form should dynamically created on same page , form should have value of text box created before , if submit should send values java program... please post me sample code of jsp , java program asap if i'm understanding correctly how data flow like? html form data --> java servlet --> html data ? the approach would, using java beans populate data. normal java class private fields, getters , setters store value. refer here more information form <form action"yourservlet"> <!-- input e.g username , submit button --> </form> servlet //request data //do calculation //populate bean //dispatch jsp bean //private field correspond form data value e.g username //constructor no arg //getters , setters //other methods jsp <body> <jsp

vba - Check whether any cells in a given range have a value equal to the string -

how create boolean function searches cells in range , checks if have value equal specified string? if so, returns true. if not, returns false. this far i've gotten function nameexist(byval name string, namerange range) boolean boolean nameexist = false if (name = michael) here's 1 implementation: function nameexists(byval searchname string, namerange range) boolean nameexists = not namerange.find(what:=searchname, lookat:=xlwhole) nothing end function here's another, more manual / brute force one: function nameexists(byval searchname string, namerange range) boolean dim long dim j long dim v variant v = namerange.value nameexists = false = 1 ubound(v, 1) j = 1 ubound(v, 2) if v(i, j) = searchname nameexists = true exit function end if next j next end function both should give same results. example usage: if nameexists("michael",range

java - IllegalStateException: zip file closed during file write -

this bug occurs when program enters shutdown hook , tries write settings file text document. strange thing is, doesnt throw exception everytime. exception in thread "thread-4" java.lang.illegalstateexception: zip file closed @ java.util.zip.zipfile.ensureopen(unknown source) @ java.util.zip.zipfile.getentry(unknown source) @ java.util.jar.jarfile.getentry(unknown source) @ java.util.jar.jarfile.getjarentry(unknown source) @ com.crimson.server.jarclassloader.findjarentry(jarclassloader.java:514) @ com.crimson.server.jarclassloader.findjarclass(jarclassloader.java:584) @ com.crimson.server.jarclassloader.loadclass(jarclassloader.java:956) @ java.lang.classloader.loadclass(unknown source) @ com.crimson.universalutils.datastore.store(datastore.java:66) @ com.crimson.server.servershutdownhook.run(servershutdownhook.java:38) here datastore.store(settings): public static file set = new file("settings.properties"); public

python - show two plot together in Matplotlib like show(fig1,fig2) -

Image
in general, don't have problem put 2 plots in figure plot(a);plot(b) in matplotlib. using particular library generate figure , want overlay boxplot. both generated matplotlib. think should fine can see 1 plot. here code. using beeswarm , here its ipython notebook . can plot beeswarm or boxplot not both in figure. main goal trying save column scatter plot , boxplot figure in pdf. thanks, from beeswarm import beeswarm fig=plt.figure() figure(figsize=(5,7)) ax1=plt.subplot(111) fig.ylim=(0,11) d2 = np.random.random_integers(10,size=100) beeswarm(d2,col="red",method="swarm",ax=ax1,ylim=(0,11)) boxplot(d2) the problem positioning of box plot. default positioning list starts 1 shifts plot 1 , beeswarm plot sits on 0. so plots in different places of canvas. i modified code little bit , seems solve problem. from beeswarm import beeswarm fig = plt.figure(figsize=(5,7)) ax1 = fig.add_subplot(111) # here may want use ax1.set_ylim(0,11) instead fig.

javascript - Html Dropdownlist built with jquery not working correctly -

Image
i have following code dynamically build dropdown list on ie10 browser, depending on values retrieved database function buildoption(container, namepreface, id, val, txt) { var obj = $("<option />", { id : namepreface + id, value : val, text : txt}); $("#"+ container).append(obj); return obj; } here html generated, copied f12, dom explorer <li> <span class="div120ralgn inlineblock"> <label for="costcenter">cost center:</label> </span> <span class="editor-field-allw220"> <select id="costcenter"> <option id="costcenter_0" value="0"> </option> <option id="costcenter_3" value="3">all</option> </select> </span> </li> however first time click drop down arrow, empty box, isn't initialized. when click on again, app

c# - Start Process and wait for Exit code without freezing -

i'm trying port program on had once made in nsis c# winforms , , having issue when call process, adb.exe, whole program locks throws me final output after few seconds. i realise may have been asked number of times, still can't find solution myself after lot of googling (plus i'm new @ using winforms). below code: public static int runadb(string args, out string output) { badbrunning = true; adbproc.startinfo.arguments = args; adbproc.exited += new eventhandler(adbexithandler); adbproc.start(); // read output string output output = adbproc.standardoutput.readtoend(); while (badbrunning) { system.threading.thread.sleep(100); } return adbproc.exitcode; } private static void adbexithandler(object sender, eventargs args) { badbrunning = false; } and code calls it: public static void baseoperations(label outputwindow, progressbar operationsbar, int opindex) { // run server if (opindex == 0) {

html - Bootstrap 3: nested columns stacked on desktop, inline on mobile -

i'm trying nest columns in following way: for desktop view, should see long column 1 on left, long column 2 in middle, , short column 1 on top right short column 2 , short column 3 stacked beneath it. for tablet view, should see long column 1 @ full width, long column 2 @ full width below that, short column 1, short column 2 & short column 3 stacked next each other below long column 2. here sketch of how hoping (sorry messy drawing): http://imgur.com/jdi5cex i've tried code below it's stacking short column 1-3 next each other on both views. any appreciated! cheers, charlie <div class="container"> <div class="row"> <div class="col-md-4"> long column 1 </div> <div class="col-md-4"> long column 2 </div> <div class="col-md-4"> <div class="r

java - Eclipse: Failed to load the JNI shared library -

this question has answer here: failed load jni shared library (jdk) 38 answers how resolve error? failed load jni shared library "c:\program files (x86)\java\jre7\bin\client\jvm.dll". make sure java , eclipse both same bit (e.g. both 32-bit). source

node.js - ninja and npm_executable-notfound -

trying build tangelo source (first time @ this) , can 90% of way through process git bash , ninja final part of process not working. having cd build dir ~/tangelo/build , ran ninja gitbash following error: $ ninja [6/135] installing phantomjs failed: cmd.exe /c cd /d c:\users\usr\tangelo\build && npm_executable-notfound install phantomjs $ ninja [6/132] installing uglify-js failed: cmd.exe /c cd /d c:\users\usr\tangelo\build && npm_executable-notfound install uglify-js 'npm_executable-notfound' not recognized internal or external command, operable program or batch file. [6/132] installing phantomjs failed: cmd.exe /c cd /d c:\users\usr\tangelo\build && npm_executable-notfound install phantomjs 'npm_executable-notfound' not recognized internal or external command, operable program or batch file. [6/132] creating virtual python environment new python executable in c:/users/usr/tangelo/build/venv\scripts\python.exe installing setuptools..

ruby - Traversing Through Multiple Associations (Rails) -

i little stuck on one. appreciate input. overview i trying output require in friendship model i.e. files current user's friends have uploaded. models like other friendship models, user self-referencing :friend . class share < activerecord::base belongs_to :user belongs_to :friend, :class_name => "user" end this paperclip model: class upload < activerecord::base belongs_to :user has_attached_file :document end this 1 generated through devise: class user < activerecord::base attr_accessor :login has_attached_file :image, :styles => { :medium => "120x120!" } has_many :uploads has_many :shares has_many :friends, :through => :shares has_many :inverse_shares, :class_name => "share", :foreign_key => "friend_id" has_many :inverse_friends, :through => :inverse_shares, :source => :user end attempts the furthest have gotten level in able output user

java - dygraph error - this.rawData_ is undefined -

i using dygraph generate graph using csv file , getting below error @ firebug. typeerror: this.rawdata_ undefined i investigated issue , found csv not being loaded entirely , label formatting being done. hence have used drawcallback. graph_obj_2 = new dygraph( document.getelementbyid("graphdiv2"), "http://localhost:8080/report_2.csv", // path csv file { //options legend: 'always', animatedzooms: true, drawcallback: function(g, is_initial) { if (!is_initial) { return;} }, axes: { x: { valueformatter: function(x) { var label; switch (x){ case 1: label = '0'; break; case 2: label = 

java - Solutions for "too many parameters" warning -

in of methods, there too many parameters , hard maintain , read source code. , worried question " are passing appropriate values in appropriate order? " i using checkstyle eclipse plugin , gives me warning more 7 parameters . i not sure may coding standard , don't care it. when passing many parameters through view , service or dao , have noticed hard read , hard modify @ later times. so, trying pass these parameters with... a number of objects or beans . give me problems because parameters wouldn't guarantee (not sure whether present or not) . hashmap type parameters. may force me check validations , try match keys method-call sides. above 2 approaches may lose compile-time errors checking. there suggestions reduce parameter counts? there techniques reduce # of parameters; use minimized methods (break method multiple methods, each require subset of parameters) use utility classes (helper classes) hold group of parameters (typically

orchardcms 1.7 - Orchard CMS - Workflow Custom Activity Recipe -

can me create recipe activates custom activity have created? i have module in have created custom workflow activities. i'd activities activated when install module wouldn't have go workflow panel each time , create activities. please, me pointing me example or resource demonstrates way this. if using 1.7.2, check orchard.roles.activities or 'orchard.comments.activities'. need decorate tasks [orchardfeature("orchard.comments.workflows")] in module.txt, add feature name orchard.comments.workflows dependency of module check piedone.helpfullibraries gallery. there nicely , author: piedone orchard team member. download combinator module, calls helpfullibraries. should it. going it, week. thought way. let me know, cheers

How to create a hyperlink within a PDF using ColdFusion, so that this hypelink will open in a new browser tab? -

i creating pdf dynamically using cfdocument tag of coldfusion 9. hyperlink there in body of dynamically created pdf. opening pdf in browser, when clicking hyperlink, opening in same tab if have added target="_blank" hyperlink. so, there way open hyperlink in new browser tab? here sample code, <cfdocument format="pdf" filename="d:\test\newpdf.pdf" overwrite="yes" mimetype="text/html"> more <a href="https://www.google.co.in/" target="_blank">click here</a>. </cfdocument> please help. this simple html. need open link before execution o cfml page. so, if want open tab pdf should call execute in new table <a href="mycfmaspdf.cfm" target="_blank">link</a> code mycfmaspdf.cfm <cfdocument format="pdf" filename="d:\test\newpdf.pdf" overwrite="yes" mimetype="text/html"> more <a

javascript - Highlight a DIV on click in page with pagination -

i highlighting div on load. , passing div id form page. $(document).ready(function() { //this highlight on load $("#<?php echo $_get['id'];?>").effect("highlight", {}, 3000); }); but in result page have pagination. highlighting first page divs how can other divs on later pages? you have pass id next page also. ex www.mysite.com/index.php?page=2&id=thisid then $(document).ready(function() { //this highlight on load $("#<?php echo $_get['id'];?>").effect("highlight", {}, 3000); });

asp.net - How do I get a user's ip address with .NET code? -

how user's ip address .net code? i'm using foo basic web studio ide uses asp.net code. here way can ip address of users. string clientip = request.servervariables("http_x_forwarded_for"); if(string.isnullorempty(clientip)) clientip = request.servervariables("remote_addr")

ios - What does 'friend' do in Obj c? -

Image
this question has answer here: why xcode ide think `friend` reserved-word 1 answer i'm working on project have created class named friend , noticed xcode colors keyword or modifier. can use did in code, or has other purpose? updated: seems answered here: why xcode ide think `friend` reserved-word but guys! c++ provides friend keyword this. inside class, can indicate other classes (or functions) have direct access protected , private members of class. when granting access class, must specify access granted class using class keyword: friend class aclass; note friend declarations can go in either public, private, or protected section of class--it doesn't matter appear. in particular, specifying friend in section marked protected doesn't prevent friend accessing private fields.

Convert an int and bytearray into a ByteString Python struct Socket -

i need send 1 int und 1 bytearray(200) through socket server. socket.send() function accpets 1 string need int , bytearray bytes in 1 string. tryed convert both string struct.pack(), working int not bytearray. s = socket.socket(socket.af_inet, socket.sock_stream) s.connect((tcp_ip, tcp_port)) print "connected to: ", s.getpeername() #trying put int , bytearray 1 string a= 02 # int b= bytearray(200) #bytearray c = struct.pack("b", a) c += b s.send(c) print s.recv(1024) concatenate them: >>> import struct >>> struct.pack('<l', 1234) + bytearray([0]*10) b'\xd2\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' or specify bytearray: >>> struct.pack('<l10s', 1234, bytearray([0]*10)) # in python 3.x # struct.pack('<l10s', 1234, bytes(bytearray([0]*10))) # in python 2.x b'\xd2\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

git - Should I use separate branches when hosting at heroku? -

i want upload following project heroku: https://github.com/eranbetzalel/tick-logger . you've noticed doesn't contain "heroku files" (procfile, different configs, etc...). i want create following configuration local repository: heroku branch - contain "heroku files". master branch - contain source code (no heroku stuff). my plan regularly push local heroku branch heroku remote repository (to master branch) , push local master branch github remote repository (to master branch). does make sense? any suggestion better practices highly welcome. this isn't idea. it's best explicit project -- means making easier other developers figure out how stuff works. with heroku, don't need add project, dependency file, , procfile (usually). i'd vote in favor of including files directly @ top-level avoid future confusion. i can't see benefit of keeping them separate.

vb.net - Error in saving record into MS Access database -

i have got couple of errors in code in vb , cant figure out how solve it. first error in following part says value cannot null parameter name: data table da.fill(dt, "order") con.close() the second error in part: dsnewrow = ds.tables(0).newrow() and here whole code: private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load dbprovider = "provider=microsoft.ace.oledb.12.0;" dbsource = "data source=c:\users\pao\desktop\projecto1.accdb" con.connectionstring = dbprovider & dbsource con.open() sql = "select *from order" da = new oledb.oledbdataadapter(sql, con) da.fill(dt, "order") con.close() end sub private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click if name_.textlength > 0 , address_.textlength > 0 , key.textlength > 0 dim pizzaarr() = pizza.toarray() dim spagarr

transactions - Java and Spring implement transactional function -

i'm using java 1.6 , spring 3.0.4, want realize java functionality calculate new data values update one-by-one existing values on database if in of step there's error want rollback whole transaction , come previous state. i realized pieces of code, want put them together. how can manage existing spring values working @entity , @column annotations? thanks! short answer: you're using spring, easiest use the transaction management , creating service represents transaction unit , annotate method @transactional in practice, need configure platformtransactionmanager in application. seem use jpa, jpatransationmanager seems obvious choice. enable processing of @transactional annotation, can either use @enabletransactionmanagement or <tx:annotation-driven/> namespace. both explained in javadoc of @enabletransactionmanagement by default, runtime exception thrown annotated method manage transaction rollback. if code using checked exceptions, yo

regex - htaccess rewrite - redirect subdomain to directory for any domain -

i need coming correct .htaccess rule. there sort of variable allows 'brand1' , work correctly? if not, have have separate rewrite rule brand1, brand2, brand3, brand4, etc. same domain. there variable allow rule work domain entered browser? i'd prefer have 1 rewrite rule can handle brand , domain if possible, rather separate rule specifying each brand , each domain. magento multistore setup. rewritecond %{http_host} ^brand1\.domain\.com$ rewriterule (.*) http://www.domain.com/brand1/$1 [p] any can provide appreciated! thanks! you can use: rewritecond %{http_host} ^([^.]+)\.domain\.com$ rewriterule (.*) http://www.domain.com/%1/$1 [l,p]

android - Tab Disappear when start new activity -

i developing android application having multiple tabs. now in launcher activity tabs display , can navigate through tabs. if call activity(which wanted show tab) on button clicked tabs seems disappear. please refer given code , let me know if doing wrong. this main tabactivity public class mytabactivity extends tabactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_tab); tabhost tabhost=gettabhost(); tabspec deshtab=tabhost.newtabspec("deshboard"); deshtab.setindicator("deshboard"); intent deshboardintent=new intent(this,deshboardactivity.class); deshtab.setcontent(deshboardintent); tabhost.addtab(deshtab); tabspec clienttab=tabhost.newtabspec("client"); clienttab.setindicator("client"); intent intent=new intent(this,clientactivity.class);

How to edit wordpress page from mysql query -

i need 1 thing. don't know wordpress structure. need query show me id_pages belong menu want. want content of pages. use sql query not idea. should use wp tags

angularjs - pass button id in ng-click angular.js -

i need pass button id in ionic framework. here have tried. in js code: angular.module('todo', ['ionic']) .controller('todoctrl', function($scope) { { $scope.showalert = function(btnid) { alert(btnid); }; } }); in html: <button id="a" class="button button-light" data="{{button.id}}" ng-click="showalert(data.id)"> click me </button> o/p: undefined or <button id="a" class="button button-light" data="{{button.id}}" ng-click="showalert(data)"> click me </button> o/p: undefined or <button id="a" class="button button-light" data="{{event.id}}" ng-click="showalert(data.id)"> click me </button> o/p: undefined or <button id="a" class="button button-light" ng-click="showalert(this.id)"> click me

html - Phonegap Windows Phone 8 White Space at the bottom solution not working -

this question has answer here: phonegap + windows phone 8 : viewport meta & scaling issue 3 answers i developing phonegap app windows phone 8. testing app on 2 devices, htc windows phone 8s , nokia lumia 820. app displayed correctly on htc device leaves white space @ bottom of nokia device. can assume, address bar present in web view. the solution have @ moment removes white space @ bottom presents problem. body, html { -ms-overflow-style: none !important; } @-ms-viewport { height:513px; width: 320px; user-zoom: fixed; max-zoom: 1; min-zoom: 1; } it rid of white space @ bottom when click on input field within app, width of app adjusts device width. anyone have ideas? include in index.html, <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densitydpi=medium-dpi, user-scalable=0&qu

Using MAT to Understand Android Memory Leaks -

Image
i'm writing first app , trying understand how use mat find potential memory leaks. keep things simple, compiled default hello world app provided when starting new project in android studio, i.e., public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } } nice , simple. after launching app on tablet take heap dump ( heap-conv-1.hprof ) using ddms , hprof-conv conversion tool. rotate tablet 20 times activity goes through number of life cycles, after take heap dump ( heap-conv-2.hprof ). i load both heap dump files mat, compare them , regex .*mainactivity.* . result is: now there 7 instances of mainactivity after rotations. since i'm not doing app, right in thinking purely because instances haven't been gc'd yet? in case , right in thinking android doesn't gc after orientation change, , when need

ruby - How to embed a link in a Facebook post through the Graph API -

Image
i want post in behalf of user message contains link facebook page. achievable through facebook interface choosing autocompleted name of page: i use ruby koala gem. tried this: graph = koala::facebook::api.new(access_token) graph.put_object(page_id, "feed", message: "embedded @[23497828950:national geographic] link") but doesn't convert link. post full url doesn't nice. is there way achieve same thing on facebook (a linked page title) through graph api? this can accomplished using open graph actions . post /me/cookbook:eat? recipe=http://www.example.com/recipes/pizza/& message=you should try recipe @[115401158528672]& access_token=valid_access_token if not aware of open graph api, can start here: https://developers.facebook.com/docs/opengraph/ just follow steps mentioned in tutorial, quite easy integrate , make stories more beautiful.

c# - Dependency Injection with ASP.NET Web API -

i trying use di in asp.net web api controller. apparently there few implementations out there. wondering of these (castle, ninject, unity etc.) easiest configure/maintain in combination asp.net web api? getting error: di.controllers.importjsoncontroller' not have default constructor. if add empty constructor, constructor ifilter ignored. this controller: public class importjsoncontroller : apicontroller { private readonly ifilter _filter; public importjsoncontroller(ifilter filter) { _filter = filter; } public httpresponsemessage post([frombody]dynamic value) { //do return response; } } you don't need di container this. here's how hand: public class poormanscompositionroot : ihttpcontrolleractivator { public ihttpcontroller create( httprequestmessage request, httpcontrollerdescriptor controllerdescriptor, type controllertype) { if (controllertype == type

php - Can I Count How Many Results Come From Each MySQL Select / Union -

i have query follows format: (select t.column1, t.column2 table t t.status = 1 limit 10) union (select t.column1, t.column2 table t t.status = 2 limit 10) the end result need have 20 rows. if first select statement can find 9 rows t.status = 1 , second select statement use limit 11 instead of limit 10 i using php write , run query, looking execute within mysql can run 1 query. any ideas appreciated. add 1 more limit 'outside' total count , use same limit of 2-nd query. ( select t.column1, t.column2 table t t.status = 1 limit 10 # 1/2 of total rows ) union ( select t.column1, t.column2 table t t.status = 2 limit 20 # total rows ) limit 20 # total rows

Seemingly simple python regex does not match -

i'm using beautifulsoup's (python) find_all function regex scrape data off webpage. quite specifically, i'm scraping individual classified ads here . if inspect each classified ad, can see typically encapsulated in either of following divs: <div class="item c-b-#">...</div> or <div class="item c-b-# premium">...</div> where # number (typically 0 or 2). my goal here tell these 2 apart using regex. here's i've done: regularads = soup.find_all('div', attrs={'class': re.compile('item.*')}) and premiumads = soup.find_all('div', attrs={'class': re.compile('item.*premium')}) the former works expeced - returns all classifieds (including premium), latter returns nothing. wrong it? why doesn't 'item.*premium' map second div-class? as secondary question: how alter first regex "i want have word 'item' not word 'premium' ? edi

c# - The name 'xyz' does not exist in the current context -

this basic in c#, looked around lot find solution. in mvc controller's action method, have incoming routeid ( programid ) need use create string variable ( accounttype ). have if/else evaluate value of accounttype . later in same action method's code, have nother if/else takes variable accounttype , creates json string pass payment gateway. error "the name 'accounttype' not exist in current context.' need declare public or something? here 2 if/else statements: if (programid == 0) { string accounttype = "membership"; } else { string accounttype = "program"; } later on in same controller action, need use accounttype variable calculate string variable (url) if (results.count() > 0) { string url = accounttype + "some text" } else { string url = accounttype + "some other text" } the problem you're defining accounttype variable within scope of if , else block, it's not def

laravel 4 - Show form field based on item list -

is possible display input form field based on value of select menu? or i'd have in javascript/jquery? my list pulled database if changes anything. if want make happen during form filling, yes need use ajax (via vanilla javascript or jquery), if need query database options selected, or css: http://www.coderanch.com/t/594720/html-css-javascript/show-hide-text-box-select , if populated via database don't need check again changes.

c++ - node js segfault in Buffer javascript code -

my node app crashing pretty randomly when handling large amount of packets in node extension. when open dropped core file in gdb (node compiled debugging symbols) get: program terminated signal 11, segmentation fault. #0 0x5e02190a in ?? () (gdb) bt #0 0x5e02190a in ?? () #1 0x5e01316a in ?? () #2 0x08210303 in v8::internal::invoke(bool, v8::internal::handle<v8::internal::jsfunction>, v8::internal::handle<v8::internal::object>, int, v8::internal::handle<v8::internal::object>*, bool*) () #3 0x0821062f in v8::internal::execution::new(v8::internal::handle<v8::internal::jsfunction>, int, v8::internal::handle<v8::internal::object>*, bool*) () #4 0x081bfadd in v8::function::newinstance(int, v8::handle<v8::value>*) const () ... looking @ source code of c packet handling extension newinstance call node's buffer constructor. here offending fragment of code (packet regular c data structure): ... v8::local<v8::function> bufferconst

javascript - How to detect change in youtube getCurrentTime()? -

is there way detect change of time in getcurrenttime() of youtube api ? purpose:to play single video limited time(<1 min) in page , move on next video. i thinking use object.watch works variables not functions. i try bind in original source code https://s.ytimg.com/yts/jsbin/www-widgetapi-vfl9twtxr.js complicated. because youtube player wrapped in iframe, dependent on player exposes, , while they've exposed current time via getcurrenttime() function, haven't exposed events raised whenever time might updated (in fact, time updated exposed function 6 or 7 times per second, , isn't consistent). so option set javascript timer. lots of ways that; simple 1 this: setinterval(function(){ // here you'd raise sort of event based on value of getcurrenttime(); },100); // polling 8 times second, make sure every time changes. as postmessage iframe isn't consistent, have interval timer greater. or use requestanimationframe poll 60 times second.