Posts

Showing posts from February, 2011

r - Use tryCatch() but don't overwrite object when error/warning encountered -

i want iteratively fit lmer() model within for loop , store results. when encounter error, don't want mermod object (the output lmer() model) overwrite mermod object previous iteration. example: # install.packages(c("lme4", "dplyr", "ggplot2"), dependencies = true) library("lme4") library("dplyr") library("ggplot2") predlist <- list() j <- 1 for(i in 2:9){ tr <- sleepstudy %>% filter(days < i) pr <- sleepstudy %>% filter(days == i) fm <- trycatch({lmer(reaction ~ days + (1|subject), data=sleepstudy)}, warning = function(w) {#code move along `predict` without overwriting `fm`}, error = function(e) {#code move along `predict` without overwriting `fm`}) #predict reaction pr$prre <- predict(fm, pr) predlist[[j]] <- pr j = j + 1 } pred <- bind_rows(predlist) %>% arrange(subject, days) ggplot(data=pred, aes(reaction, prre)) + ge

javascript - How do I detect whether a position is at the beginning of a line in a textarea? -

i have textarea this: <textarea> test1 , test2 plus test3 </textarea> as see, positions in beginning of line: 0 (t), 14 (a), 32 (p). now need determine whether position (i mean number of position) @ beginning of line? for example: 10 : false 5 : false 14 : true 40 : false how can that? if want know n-th position @ beginning, then: n == 0 || $("#textbox").val()[n-1] == '\n'

r - How to aggregate several months (seasonal) from a "ts" object? -

i'll use airpassengers data set reproducibility: data(airpassengers) class(aispassengers) ## [1] "ts" airpassengers ## jan feb mar apr may jun jul aug sep oct nov dec 1949 112 118 132 129 121 135 148 148 136 119 104 118 1950 115 126 141 135 125 149 170 170 158 133 114 140 1951 145 150 178 163 172 178 199 199 184 162 146 166 1952 171 180 193 181 183 218 230 242 209 191 172 194 1953 196 196 236 235 229 243 264 272 237 211 180 201 1954 204 188 235 227 234 264 302 293 259 229 203 229 1955 242 233 267 269 270 315 364 347 312 274 237 278 1956 284 277 317 313 318 374 413 405 355 306 271 306 1957 315 301 356 348 355 422 465 467 404 347 305 336 1958 340 318 362 348 363 435 491 505 404 359 310 337 1959 360 342 406 396 420 472 548 559 463 407 362 405 1960 417 391 419 461 472 535 622 606 508 461 390 432 is there way obtain annual seasonal average (see expected results table below) without converting "ts" object class? right i'm able transforming "ts&quo

windows phone 7.1 - XAP file invalid -

i have submitted app in windows phone marketplace,here link http://www.windowsphone.com/en-in/store/app/mywannado/23068282-3b9b-4cb2-aa6e-e2318b13f3a7 i have selected india market , price 0.0(free app)while submitting. i tried download system, shows "you can't apps in region. can check windows phone store in home region see if app available there" when try download app mobile, couldn't find app in market place. using nokia lumia510, , using same account sign in @ mobile. tried "download , install manually" but failed,i can down load "xap" file but, when try deploy it, shows "xap file invalid". can please give me clarification why happening, , should install app marketplace. thank you. i got solution developer forum, cant install xap files downloaded market place emulator,because encrypted. can install xap files developer side.

How to create a list in Python, based of another master list and user input as index? -

i'm relatively new python. i have list like master = ['apple','banana','clementines','dates','fig','guava'] i user input like choose fruits: > 1,3:5 based on user input, want create sub-list like selectedfruits = ['apple','clementines','dates','fig'] if perform command follows, error index string. userinput = input() selectedfruits = master[userinput] can kindly help? you can this; master = ['apple','banana','clementines','dates','fig','guava'] inp = input().split(",") # input "1,3:5" selectedfruits = [] elem in inp: if ":" in elem: i, j = elem.split(":") selectedfruits.extend(master[int(i):int(j)]) else: = int(elem) selectedfruits.append(master[i]) # ['banana', 'dates', 'fig'] assuming input entered 1 time commas, c

AngularJS app.module vs app.route -

i read article best practices angularjs project structure: https://scotch.io/tutorials/angularjs-best-practices-directory-structure under title "app folder" explains shortly difference between files app.module.js , app.route.js didn't understand. can give me example short pseudo code both of files? any profoundly appreciated! under structure, app.module.js used create main module application (eg. app ), configure services using throughout application, or running arbitrary code once module has loaded of dependencies , configured services may wish configure. app.route.js configuring 1 service: router using handle state in application. create own module or re-use 1 app.module.js , if use custom module, have depend on choice of router directly. in addition, have add dependency main app.module.js eg. angular.module('app', ['app.routes']); angular.module('app.routes', ['routermodule']); example using 1 module named a

parsing - Lexer/Parser design for data file -

i writing small program needs preprocess data files inputs program. because of can't change format of input files , have run problem. i working in language doesn't have libraries sort of thing , wouldn't mind exercise planning on implementing lexer , parser hand. implement lexer based on this simple design. the input file need interpret has section contains chemical reactions. different chemical species on each side of reaction separated '+' signs, names of species can have + characters in them (symbolizing electric charge). example: n2+o2=>no+no n2++o2-=>no+no n2+ + o2 => no + no are valid , tokens output lexer should be 'n2' '+' 'o2' '=>' 'no' '+' 'no' 'n2+' '+' 'o2-' '=>' 'no' '+' 'no' 'n2+' '+' 'o2-' '=>' 'no' '+' 'no' (note last 2 identical). avoid ahead in

python - Django Category Model and Template View Issue -

my question 2 phased it's same django model. trying category model work petition model. currently, i 'fielderror' error when define queryset 'categoryview' class: cannot resolve keyword 'created_on' field. choices are: description, id, petition, slug, title here code 'categoryview' class: class categoryview(generic.listview): model = category template_name = 'petition/category.html' context_object_name = 'category_list' def get_queryset(self): return category.objects.order_by('-created_on')[:10] here code in models.py: class category(models.model): title = models.charfield(max_length=90, default="select appropriate category") slug = models.slugfield(max_length=200, unique=true) description = models.textfield(null=false, blank=false) class meta: verbose_name_plural = "categories" def __str__(self): return self.title def get_a

php - What is a good database design approach for my Online Quiz Android Application? -

Image
i have been working on android online quiz application php & mysql. know attributes need when designing relationship becomes complex , confusing when analysed it. not know if database design before write in mysql , implement in project. see erd below: as design above, trying design work creating charts android chart generation library. not sure design , thinking might struggle ending redone database design. suggestions this? in advance. from experience, can built in better way json documents of nosql database mongodb, allows following: schema less : mongodb document database in 1 collection holds different different documents. structure of single object clear. no complex joins. deep query-ability. tuning. ease of scale-out: mongodb easy scale. http://www.tutorialspoint.com/mongodb/index.htm try out mlab provide mongodb-as-a-service , can connected web app deployed using heroku. https://mlab.com/

How can I write a recursive python function that splits a dictionary into an array of dictionaries? -

i looking write recursive function: arguments: d, dictionary result: list of dictionaries def expand_dictionary(d): return [] the function recursively goes through dictionary , flattens nested objects using _, in addition expands out nested lists array, , includes parent label. think of creating relational model document. here example input , output: original_object = { "id" : 1, "name" : { "first" : "alice", "last" : "sample" }, "cities" : [ { "id" : 55, "name" : "new york" }, { "id" : 60, "name" : "chicago" } ], "teachers" : [ { "id" : 2 "name" : "bob", "classes" : [ { "id" : 13, "name" : "math" }, { "id" : 16,

java - MySql (MAMP) jdbc connection error in eclipse -

i trying set connection mysql in eclipse. have tried following - i have added "my-sql-connector.jar" build path , class path. i have tried adding in web-inf. tried using class.forname. after trying above, still not able set connection. keep getting following error - java.sql.sqlexception: no suitable driver found jdbc:mysql://localhost/sampledb here code - public class main { private static final string username = "user1"; private static final string password = "user1"; private static final string conn_string = "jdbc:mysql://localhost/sampledb"; public static void main(string[] args) throws sqlexception { connection conn = null; try { conn = drivermanager.getconnection(conn_string, username, password); system.out.println("connected"); } catch (sqlexception e) { system.err.println(e); } { if (conn != null

python - Number of bins in matplotlib axes (number of majorticks) -

Image
i have 6 axes in 1 figure. limits on each axes different. on each axes gave command: ax.locator_params(axis='x', nbins=9) ax.locator_params(axis='y', nbins=7) but when plot get: i want 9 majorticks 9 labels on x axis of each axes, , 7 on y axis of each axes. how can achieve this? lot. from matplotlib.ticker import maxnlocator import matplotlib.pyplot plt fig, (ax1, ax2, ax3, ax4, ax5, ax6) = plt.subplots(nrows=2, ncols=3) # add plot code here ax1.xaxis.set_major_locator(maxnlocator(nbins=9)) ax1.yaxis.set_major_locator(maxnlocator(nbins=7)) #repeat other axes

bit manipulation - How to flip bits in C#? -

i have binary number in form of string as string input = "10110101101"; now need flip ( 0 1 , 1 0 ) first 3 bits of it. the resultant output 010 10101101 how in c#? an alternate way using convert.toint32 , convert.tostring (which otherwise unknown , unused), , bitwise-xor string input = "10110101101"; int flipno = 3; int output = convert.toint32(input, 2); (int = input.length - 1; >= input.length - flipno; --i) output ^= 1 << i; simply use output , or if want display output in string , do: string display = convert.tostring(output, 2).padleft(input.length, '0');

jquery - How To Make Animate When Closed?[Javascript] -

javascript here <script> function toggle2(showhidediv, switchtextdiv) { var ele = document.getelementbyid(showhidediv); var text = document.getelementbyid(switchtextdiv); $(ele).slidetoggle(); if(ele.style.display == "block") { ele.style.display = 'none'; } else { ele.style.display = 'block'; } } </script> and html <a id="myheader" href="javascript:toggle2('mycontent','myheader');" > <img src="gcont/images/cloud/folder.png" alt="" height="30" width="30"/> general </a> </div> <div style="clear:both;"></div> <div id="contentdiv"> <div id="mycontent" style="display: none;"> <a href="http://1drv.ms/1zn0hud" target="_blank">____test sub article</a><

javascript - Sorting order of Groups in kendo ui grid -

here have written stored procedure getting categoryname values based on id, values coming india, america, brazil service, in ui section values in automatically sorting in alphabetical order displaying groups america, brazil,india. wanted show in order display india, america, brazil format. doing wrong? in advance. $(document).ready(function () { var grid = $("#grid").kendogrid({ datasource: { type: "get", transport: { read: { url: "some url placed here", datatype: "jsonp" } }, pagesize: 20, serversorting: false, group: { field: "categoryname", aggregates: [{ field: "abc", aggregate: "count" }, { field: "def", aggregate: "sum" }, { field: "ghi",

c# - One or more unit test projects for solution -

i have console app 2 other class library projects -- totaling 3 projects -- in solution. i want add unit test project. question add "unit test project" per "regular project" in solution or single unit test project can test three? in other words, if projects proja, projb , projc, add 3 unit test proejects e.g. proja.tests, projb.tests, etc. or single unit test project can handle three? if question can single unit test project can handle three? answer yes proceed next step depends. personally, tend put of tests in single project, separate folders within project each assembly (plus further sub-folders necessary.) makes easy run entire set within visualstudio. if have thousands of tests, single project might prove difficult maintain. split them out because don't want deploy them our product. whether split them out per library or per solution there merits both. ultimately, want tests available developers, developers know find them when needed. wa

java - Proper Implementation of JDBC Multithreading with JNDI -

i'm working on project i'm doing lot of queries , time consideration want try , implement jdbc multithreading. i'm not sure proper way is. here's first draft implementation: spring datasource bean: private datasource ds; @resource(name="jdbc") public void setdatasource(datasource ds) { this.ds = ds; } initialization method: public void checkusersmulti(list<user> users) throws exception { if(users!= null || users.size() != 0) { executorservice executorservice = executors.newfixedthreadpool(20); queue<user> queue = new concurrentlinkedqueue<>(); queue.addall(users); (useruser: users) { executorservice.submit(new processuser(queue)); } executorservice.shutdown(); try { executorservice.awaittermination(1, timeunit.hours); } catch (interruptedexception e) { e.printstacktrace(); } } } runnable class: class pro

Weblogic & Tomcat simple java loop performance varies -

have issue performance of simple loop (see code below in looptest.performtest) varies dramatically, consistent lifetime of process. for example, when run within weblogic/tomcat may achieve average of 3.5 billion iterations per second. re-start , may achieve 20 million iterations per second. remain consistent lifetime of process. when has been run directly command line, on every occasion, has run fast. this has been run under linux, windows, tomcat & weblogic. slow execution occurs more regularly in weblogic tomcat. test specifics the test code moves potential os calls (timing) before , after test, differing size loops should allow slow os calls apparent progressive apparent performance improvement loop size increases. the number of iterations performed test determined time (see runtest) rather being fixed due large variation in performance , more complex may expected. public static abstract class performancetest { private final string name; public performa

Scala: How to Pattern Match a Union of Parameterized Types -

i using rex kerr's variant of miles sabin's idea implementing unboxed union types in scala. have following class: class foo[t] { trait contr[-a] {} type union[a,b] = {type check[z] = contr[contr[z]] <:< contr[contr[a] contr[b]]} def foo[u: union[t,foo[t]]#check](x:u) = x match { case _: foo[t] => println("x foo[t]") case _: t @unchecked => println("x t") } } this allows following: val aux = new foo[int] aux.foo(aux) // prints "x foo[t]" aux.foo(42) // prints "x t" aux.foo("bar") // not compile however: val bar = new foo[foo[int]] bar.foo(bar) // ok: prints "x foo[t]" bar.foo(aux) // not ok: prints "x foo[t]" is there way fix this, , maybe eliminate @unchecked ? edit think union type, particular example, can simplified to: type union[z] = contr[contr[z]] <:< contr[contr[t] contr[foo[t]]] and foo function can be: def foo[u: union](x:u) =

python 2.7 - Multiple label values support in graphlab.label_propagation.create -

below code tries add 2 vertices both vertices having multiple label values. tries apply label_propagation on label "labelx" graph created. from graphlab import label_propagation graphlab import sframe, sgraph, vertex, edge g = sgraph() verts = [vertex('h',attr={'labelx': [1,0]})] g= g.add_vertices(verts) verts = [vertex('i',attr={'labelx': [0,2]})] g= g.add_vertices(verts) g = g.add_edges(edge('h','i')) print g.summary m = label_propagation.create(g, label_field='labelx') but, throws error typeerror: typeerro...typed.',) in documentation of labelpropagation, not find multi label support information anywhere. hints on how resolve problem welcome. if graphlab.label_propagation not support multilabels on vertices, directions on other packages offers functionality helpful. thanks!

PHP - Text Field value based on selected value from List Box -

may know how can setting text field's value according selected value list box? table in database html form for example: if choose "dip" list box text field display "diploma in information technology (programming)" automatically since setting text field became disabled. p/s: list box function done. need guides settle text field var code = $('#code').val(); $.ajax({ type: "post", data: {code: code}, url: 'get_name_list.php', success: function(data) { $('#text_field').val(data); } in get_name_list.php make query fetch program_name , return value. can code $_post['code'] . , in success need set value textbox.

asp.net - Cant register vNext DI services using generics -

before moved aspnet5/vnext used simpleinjector. use simpleinjector register generic validators, using following: services.addscoped(typeof(ivalidator<>), new list<assembly> { assembly.load("my.other.assembly") }); my classes defined in other assembly public interface imyinterface : ivalidator<myobject> {} public class myvalidator : imyinterface { // methods here } is possible using standard vnext di system? yes, possible. take here: http://dotnetliberty.com/index.php/2016/01/11/dependency-scanning-in-asp-net-5/

matlab - Scatter plot color thresholding -

i trying write script plot florescence intensity microscopy data scatter plot , threshold data based on cells respond greater amount in cfpmax , plot these in green , cells not in red. when try plot this, unable assign proper colors points , end being blue , red. need each cell in image assigned 4 values, (3 values for each florescence channel , 1 value determine whether or not responded (green or red). wondering if possible assign proper color 4th column of matrix, or if going wrong way together. have attached code below. mchr=csvread('data1.csv'); myfp=csvread('data2.csv'); mcfp=csvread('data3.csv'); cfpmax=(max(mcfp))'; mchmax=(max(mchr))'; yfpmax=(max(myfp))'; c=zeros(length(cfpmax)); i=1:length(c) if cfpmax(i)>40 c(i)='g'; %// green responders else c(i)='r'; %// red non-responders end end mm=horzcat(mchmax,yfpmax,cfpmax,c); scatter(mm(:,1),mm(:,2),100,mm(:,4),'filled','marke

ElasticSearch: Design schema for hieararchy level data? -

for object have data in format title, description, tag e.g here mobile, tablet, real estate have tag heirachy this electronics - > mobile -> samsung electronics - > mobile -> nokia electronics - > tablet -> samsung realestate - > rent -> villa now want query like 1. find "mobile" of brand "samsung" exist in "electronics" category 2. find "tablet" of brand "samsung" exist in "electronics" category 3. find "tablet" of brand "samsung" exist in "electronics" category 3. find "villa" "rent" exist in "realestate" category how can design es schema kind of hearahi level data? this feels best case flat structure number of properties can query for. { "product": "mobile", "brand": "samsung", "category": "electronics", "anotherproperty": "and on&qu

php - Cannot Use a Scalar Value as an Array, But Data Successfully Updated -

i have code : public function updatesegmentgender ($product_id, $segment_gender) { $this->connect(); $product_id = $this->escapestring($product_id); $row_count = count($segment_gender); ($row = 0; $row < $row_count; $row++) { $this->select('product_seg_gender', '*', null, 'product_id = "'.$product_id.'" , gender = "'.$segment_gender[$row][0].'"', null, null); $res = $this->getresult(); $res = count($res); $gender = $segment_gender[$row][0]; $status = $segment_gender[$row][1]; if ($res <> 0) { // update $data = array ('status'=>$status); $this->update('product_seg_gender', $data, 'product_id = "'.$product_id.'" , gender = "'.$gender.'"'); }else { // insert $data = array ('pr

objective c - How to fix long NSString crash? -

in app i'm working on i'm reading numerical values text file in loop doing calculations , appending result results string. the file has 22050 values in it. noticed above number of loops/values appended (~5300) tends crash. i thought perhaps have memory leak, got rid of string appending , worked fine. tried getting rid of string appending , app crashed. have break point on exceptions , don't exception. i wanted make sure started new project. put there 1 uibutton when pushed calls piece of code: - (ibaction)testpressed:(id)sender { nsstring *teststring = @""; (int = 0; < 22050; i++) { teststring = [teststring stringbyappendingstring:@"12.34567890\n"]; } nslog(@"%@", teststring); } i have break point on nslog line. app crashes before. is there limit on nsstring length? use memory? the problem creating new string in every iteration. there 2 options fix this: either use mutable string create

shell - How to pass password from file to mysql command? -

i have shell script calls mysql command 1 parameter external file, looks (also saw example in other resources): mysql --user=root --password=`cat /root/.mysql` bit not working: failed connect mysql server: access denied user 'root'@'localhost' (using password: yes). i tried different quotes without success. how pass it? update 1: found can pass password without space symbol. problem in this, root pass contains spaces. finally line working: mysql --user=root --password="$(cat /root/.mysql)" or: mysql --user=root --password="$(< /root/.mysql)" root password must without quotes: bla bla bla if password not contains spaces can use: mysql --user=root --password=`cat /root/.mysql`

c# - Track Database Status Change sql server -

i want track database status changed in sql server . in solution ,i have database offline due restore primary server . want hint in application(c#) when database offline , when online. (like sql notification event) . . one way check state of database using timer application private void timer1_tick(object sender,eventargs e) { if(checkdatabasestate() == "online") messagebox.show("db online"); else messagebox.show("db not online"); } public string checkdatabasestate() { string constr = @"data source=.\sqlexpress;integrated security=true;initial catalog=master;"; string sql = string.format("select name, state_desc sys.databases name = '{0}'", dbname); sqlconnection conn; sqlcommand comm; sqldataadapter adapter; dataset ds = new dataset(); conn = new sqlconnection(constr);

c# - Unity3d - How to make method calling from another class that belongs to another game object efficiently -

this continuity question . what want here create program calculate score based on 3d model's movement , show change of model's color. but since model's movement recorder, score calculation, , coloring different classes attached on different game object, need make them connect each other work together. i come solution below snippet, system got laggy , freezing. new unity world, ask guys, there method more efficient kind of job? here code structure in detail, problem involving 3 different class calling each other (all attached different game object) 1) bonehighlighter.cs to re-coloring on model based on script previous question //declare skinnedmeshrenderer public skinnedmeshrenderer smr; //initialization //previously put initialization on start(), try put on awake() make initialization bit sooner void awake () { if (smr == null) smr = getcomponent<skinnedmeshrenderer>(); smr.sharedmesh = (mesh)instantiate(smr.sharedmesh); } // change vertex

servicemix - Fuse ESB - ODE installation -

in fuse esb, tried install ode feature using command (install ode), got error below. appreciated fuseesb:karaf@root> features:install ode error executing command: no feature named 'ode' version '0.0.0' available apache ode not supported fuse esb longer. apache ode not work osgi , project not active maintained , not recommend using it, jbi dead. and command correct says there no feature named ode. you can features:list see features available out of box.

regex - Arithmetic operations inside the parenthesis javascript -

hi please me resolve issue var str = '10+20-10-2'; var numbers = str.replace(/ /g, '').split(/[-+*\/]/g); var operators = str.replace(/ /g, '').split(/\d*/g); operators.shift(); var result = +numbers[0]; (var = 0; < operators.length - 1; i++) { result = eval( result + operators[i] + numbers[i + 1] ); } alert(result)​; above code working fine , when trying pass other input var str = '-(1)-(-2)'; var str = '-1-(-1)'; var str = '(-1)-2' ; not getting result i guess in case, besides eval, use var result = parsefloat(numbers[0]); and consequently result = eval( result + operators[i] + parsefloat(numbers[i + 1])) this bit more solid because works if strings in numbers contain numbers, , return nan if don't. also, more solid, go long way , use switch instruction: switch(operators[i]) { case "+": etc. } of course

how to make my android App faster using titanium App -

i have noticed when deployed app in android device using titanium alloy, working , seem android app need time redirect next page after touch , click.it goes next page within 3 or 4 seconds after clicked on ui elements(button,view,label,image) on other side, working ios devices (iphone , ipad) i don't know should problem android.i reset factory data in android , tested app again still issues arrives is android touch/click issue? please feedback on issues , give me suggestion how fix it. in advance your problem not device, login's api. suggest insert indicator bridge waiting time this: ----index.xml---- <alloy> <window class="login_container" height="auto" horizontalwrap="true"> <activityindicator id="activityindicator" message="wait please..."/> ----index.js---- function login(e) { var uname = $.username.value.split(' ').join(''); var pwd = $.password.value.sp

css - How to style jquery chosen select box -

i using jquery chosen multi-select box. however, find styles pre-defined in chosen.css file kind of hard overwrite, totally getting rid of chosen.css might not option. here fiddle: https://jsfiddle.net/k1lr0342/ html: <select class="chosen" multiple="true" style="height: 34px; width: 280px"> <option>choose...</option> <option>jquery</option> <option selected="selected">mootools</option> <option>prototype</option> <option selected="selected">dojo toolkit</option> </select> css: .chosen-choices { border-radius: 3px; box-shadow: inset 0px 1px 2px rgba(0,0,0,0.3); border: none; height: 34px !important; cursor: text; margin-top: 12px; padding-left: 15px; border-bottom: 1px solid #ddd; width: 285px; text-indent: 0; margin-left: 30px; } i tried directly write css .chosen-choices ul . works border

Spring Data JPA Fetching -

is there way define spring data specification (returning jpa predicate) sole purpose perform eager fetching? i have entity defines various relationships using lazy loading, there several queries want return entire entity representation including related collections, criteria of these queries may vary. i've seen few posts (e.g. on spring forum ) discuss potential introduction of fetch groups, ideal solution; however, since not yet part of jpa spec, spring data not provide support it. i'm looking reusable way perform eager fetching on variety of dynamic queries. for example, i've considered developing reusable specification sole purpose perform eager loading, , combined other specifications, e.g: private static specification<myentity> eager() { return new specification<myentity>() { @override public predicate topredicate(root<myentity> root, criteriaquery<?> query, criteriabuilder cb) { (pluralattribute<

android - HTTP post message with Java and PHP -

i new php , java http client, trying post message php script on server, tried following example: http://webtutsdepot.com/2011/11/15/android-tutorial-how-to-post-data-from-an-android-app-to-a-website/ however not able understand how send json result android app, following code using: java: public void send(view v) { // message message text box string msg = et.gettext().tostring(); // make sure fields not empty if (msg.length()>0) { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://animsinc.com/query.php"); try { list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("id", "12345")); namevaluepairs.add(new basicnamevaluepair("message", msg)); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpclient.execute(httppost);

python - Django Model Instance - Saving other attributes -

i'm trying support user uploads in django application. application should allow user create own repo of files , folders. the below model instance class project(models.model): name = models.charfield(max_length=255) def __str__(self): return self.name class folders(models.model): name = models.charfield(max_length = 255,default = 'main') project = models.foreignkey(case) class files(models.model): folder = models.foreignkey(folders) file = models.filefield(upload_to = get_upload_url) def get_upload_url(instance,filename): print('instance :',instance) return '/'.join([instance.folder.project.name,instance.folder.name,filename]) i'm getting error when i'm trying upload docs specific folders using django forms def projectpagealt(request,casenum,folder): proj = project.objects.get(pk=casenum) folder = folders.objects.get(name = folder,project=proj) files = files.objects.filter(folder=fol

php - WebUI-Popover didn't work inside while loop in a table -

Image
i'm trying create popover using https://github.com/sandywalker/webui-popover . here's scenario whenever click calendar button inside data table appear popover shows date , time of said data in mysql database. code doesn't work. here's interface: <table class="table table-condensed tablehead table-sortable table-hover" style="width:99%"> <tr> <thead> <th>transmittal #</th> <th>transmittal date</th> <th>sender name</th> <th>receiver name</th> <th>invoice #</th> <th>document type</th> <th>vendor name</th> <th>status</th> </thead> </tr> if($_session['userrole'] == 2){ $qry = "select en.`transid`, en.`transdate`, concat(userlist.lname, ', ', userlist.fname, ' ', userlist.mnam

angularjs - ng-click on accordion panel header -

i have been working on angularjs uib-accordion , able make functional, when click on panel title expands that's fine, trying when click anywhere on panel heading should expand. need suggestion on it. <uib-accordion> <uib-accordion-group style="border-radius:0px !important; margin:10px;"ng-repeat="filter in filtergroup" heading="{{filter.label}}"> code </uib-accordion-group> </uib-accordion> if don't mind adding property filter, can have is-open attribute assigned property , toggle on ng-click (as shown below). if don't want property assigned filter object, there other methods (for example, push filter isopen array, , is-open="isopen.indexof(filter)>-1" ) <uib-accordion> <uib-accordion-group ng-repeat="filter in filtergroup" heading="{{filter.label}}" ng-click="filter.isopen==!filter.isopen" is-open=&

javascript - How to use BBC's Imager.Js for responsive images in C# MVC -

i want use bbc imager.js library load responsive images on website based on device window size. have images of different sizes stored on server. i have followed documentation of bbc-news/imager.js/ on github, not work due lack of knowledge. kindly me how accomplish task or there better technique work. i resolved issue. going use old technique, days use <picture> tags auto image selection based on browser size our image directory. <picture> <source media="(min-width: 1024px)" srcset="www.example.com/image-large.jpg, www.example.com/image-large.jpg 2x"> <source media="(min-width: 768px)" srcset="www.example.com/image-medium.jpg, www.example.com/image-medium.jpg 2x"> <source media="(min-width: 480px)" srcset="www.example.com/image-mobile.jpg, www.example.com/image-mobile.jpg 2x"> <source srcset="www.example.com/image-small.jpg, www.example.com/image-small.jpg 2x"&g

authentication - Authenticate in Lotus Notes on localhost -

this might sound little complicated, i'm working on local databases in lotus notes got problem, can not authenticate. i'm working anonymous on database. the problem is, can not test functions, because need valid notesname. how can authenticate on localhost work name/account , not anonymous? you can not authenticate xpages/web applicatons using local http preview. need install local server (which thing anyway xpages development).

database - How to speed up mySQL query when I only need the latest entry of each group? -

so working on project transportation system. there buses reporting server. buses insert new rows table called events every 2 sec, large table. each bus has unique busid. want table contains buses latest report. here things tried: firstly think order time desc limit 20 turns out sorting entire table first doing limit thing second... make sense, how else sort? so googling , found out faster sort index. did order id desc limit 20; gave me latest 20 entries pretty fast. however don't need latest 20 entries instead need latest entry buses. thinking combining group bus order id somehow didn't figure out... next read post on site speeding things when need max value of column in each group. came select driver,busid,route,timestamp,max(id) events group bus seems using max(id) not help... and think first using order id limit (some number) make sub table, find newest entry of each bus within sub table. problem that, tablet on bus sending report might accidentally go

c - Check the value of character variable -

i'm writing code arduino , i'm not sure if i'm checking value of character variable correctly. can please tell me if correct: const char* front = "front"; const char* = "back"; eyeballs(front); eyeballs(back); void eyeballs(const char* frontorback){ if (frontorback == "front") { digitalwrite(fronteyes, low);}//end if else if (frontorback == "back") { digitalwrite(backeyes, low);}//end else*/ } you need use strcmp() compare c-strings. pointer comparison. if ( strcmp(frontorback, "front") == 0 ) { digitalwrite(fronteyes, low);}//end if else if ( strcmp(frontorback, "back") == 0 ) { digitalwrite(backeyes, low);}//end else*/ } in comparison, if (frontorback == "front") { the pointer value frontorback compared address of string literal "front" (in expression, string literal gets converted pointer first element).

javascript - How to display Html Entities in High Charts labels -

i'm using highcharts display donut-pie table. i'm trying display pound symbol in labels, when set usehtml true, i'm losing point select functionalities. additional-info : allowpointselect: true, will allow select segments in chart pointers. here pointers lose hover , click events. any appreciated. here fiddle it. fiddle sample you added usehtml option. forked jsfiddle , i'm able add euro symbol. datalabels: { enabled: true, color: '#3a4570', connectorcolor: '#ffffff', usehtml: true, distance: 10, style: { "fontsize": "11px", "fontweight": "bold", "textshadow": "false" }, formatter: function() { return '<b style="color:#000;font-size:16px;" >'+ this.point.name +'</b><br/><span>total: </span>&euro;'+ } } forked jsfiddle: https://jsfiddle.net/ramsunvtech/5hbpxel7/4/