Posts

Showing posts from March, 2012

Javascript Jquery Fadeout Woes -

my javascript isn't working. guess while i'm @ it, there programs can use can give me errors made able trouble shoot myself? javascript... <script type="text/javascript" src="/js/jquery-ui.min.js"> $(document).ready(function() { $(".button").click(function(){ $("#tickettable").fadeout( 'slow', function(){ }); }); }); </script> button used fadeout... <button class="button">respond</button> html want fade out... <div id="tickettable"> <table border="1" width="1000" class="transparent"> <tr><th width="15%">ticket</th><th width="15%">queue</th><th width="15%">severity</th><th width="15%">created</th><th width="15%">creator</th><th width=...

Change global variable across class in python -

i trying make change global variable across classes. here code: file main.py import class2 class first: def changea(self): global print += 2 print test0 = first() test1 = class2.second() test2 = first() test3 = class2.second() test0.changea() test1.changea() test2.changea() test3.changea() file class2.py a = 1 class second: def changea(self): global print += 1 print but returns error: global name 'a' not defined. there proper way access , change global variable across files in python? in advance global variables don't exist in python. the global statement misnomed statement. means variable module 's variable. there no such thing global namespace in python. if want modify variable multiple modules must set attribute: import module module.variable = value doing simple assignment create or modify module's variable. code from module import variable variable = ...

validation - Validate datetime in Symfony2 -

i trying validate posted datetime string getting generic error "error: value not valid". data posted on restful api (if makes difference). validation constraints through annotations in entity: /** * @var \datetime * * @orm\column(name="created_at", type="datetime", nullable=true) * @assert\datetime(message="createdat must valid datetime string") */ private $createdat; controller code processing form $user = new user(); $form = $this->createform(new usertype(), $user); $form->submit($request); if ($form->isvalid()) {..} if field not passed validation works.

javascript - search in textbox for different fields help is required -

we have requirement, search different fields using single text box. example, search has based on 3 fields; product, brand , place. initially user given below text in textbox cannot modified: product:-brand:-place when user wants search product, brand , place, add values: product:"tv"-brand:"samsung"-place:"london" when user wants search product: product:"tv"-brand:-place can body me, how can done in jquery or angular js? this can done using angular filter.. you can pass object second parameter achieve if can have 2 search fields <div ng-repeat="friend in user.friends | filter:{name:searchnametext, age:searchagetext}"> otherwise you'll need write custom filter use same field both, or pass custom filter function third parameter described in docs. http://docs.angularjs.org/api/ng.filter:filter

javascript - How to uncheck a checkbox when checked option is other than 'All' -

i've multiple checkboxes populated database, except 1 checkbox "all" (used check/uncheck other checkboxes onclick) when options checked , if option other 'all' unchecked checkbox of should unchecked. when option checked except 'all' 'all' should checked. how proceed? my code: <script> $(document).ready(function () { ('#check').append('<input type="checkbox" id="checkall" name="mycheckbox[]" value="all" > </input>' + "all" ); //'datadb' data db in json array //datadb={'apple','banana','orange'} $.each(datadb, function(i, fruit) { $('#check').append('<input type="checkbox" name="mycheckbox[]" class=".chk" value="' + fruit + '" > </input>' + fruit ); $('#check').append('<b...

javascript - DataTable - Column 1 cells ( use values from array ), column 2 cells ( use custom html) -

i want create datatable wherein first column values come array , second , other columns contains custom html ( select boxes, inputs etc) .i have used datatable before time reading data json ( columns ) this: function baskettable(data){ toptable = $('#at-top-100').datatable({ //layout of data table "dom": 'tlfrtip', "binfo" : false, "bdestroy":true, "bfilter" : false, "responsive":true, "aadata" : data, "aocolumns": [ { "mdata": "ap" }, { "mdata": "dp" }, { "mdata": "a"}, { "mdata": "s"}, { "mdata": "s"}, ], "idisplay...

Why is the combination of a $watch, a promise and ng-options behaving differently in angularJS 1.3? -

Image
after upgrading angularjs 1.2 1.3 have issue ng-options. selected value not shown in browser. i've got html select: <select ng-model="selectedfield" ng-options="field field in fields"></select> after setting selectedfield , loading fields (via promise) angularjs 1.2 works fine. angularjs 1.3 selected value not shown. changing ng-options query using "track by" option makes work in angularjs 1.3 again. <select ng-model="selectedfield" ng-options="field field in fields track field"></select> i discovered coincidence. in case "track by" should not needed fields list of strings. , selectedfield string well. default comparison used ng-options should work. this works i'm not happy. not make sense , need solution understand. i continued examination of issue , found out using $watch uses promise load data $scope.fields "toxic" combination. if call promise directly contr...

javascript - json from js to php - failed to open stream: http request failed -

i trying send json data js php, , pass mongo rest. the following outputs json string (that works fine later if put string in php file, please see snippet below). js send json: var s = json.stringify(send); //s contains previous data in arrays, etc ic(s); function ic(s){ var ajaxurl = './im.php'; $.getjson(ajaxurl, {da: s}, function(data) { console.log (data); }); } in im.php: $s = $_get["da"]; // <-- doesn't work //$s = '{"r":"pax","c":1,"w":["kiwi","melon"],"g":["cat","dog"]}'; //<-- works fine $opts = array( "http" => array( "method" => "post", "header" => "content-type: application/json", "content" => $s, ), ); $context = stream_context_create($opts); $result = file_get_contents("https://api.mongolab.com/api...

python - Get original values from cumulative sum -

>>> test.val.cumsum() 0 11 1 13 2 56 3 60 4 65 name: val, dtype: int64 how original values cumulative sum? have [11,2,43,4,5] you use diff() series method (with fillna replace first value in series): >>> s = pd.series([11, 13, 56, 60, 65]) >>> s.diff().fillna(s) 0 11 1 2 2 43 3 4 4 5 dtype: float64

servicestack - Configuring web.config in Service Stack 3.9 not working -

i'm following tutorial servicestack use version 3.9.71 , modify web.config gives me error. code this: <configuration> <system.web> <httphandlers> <add path="*" type="servicestack.httphandlerfactory, servicestack" verb="*"/> </httphandlers> <compilation debug="true" targetframework="4.0" /> </system.web> <!-- required iis 7.0 (and above?) --> <system.webserver> <validation validateintegratedmodeconfiguration="false" /> <handlers> <add path="*" name="servicestack.factory" type="servicestack.httphandlerfactory, servicestack" verb="*" precondition="integratedmode" resourcetype="unspecified" allowpathinfo="true" /> </handlers> </system.webserver> </configuration> that configuration servicestack v4 , document...

r - Rename model terms in lm object for forecasting -

i have regression models fitted on data want use forecasting, column names in training data , forecast data different. typical approach rename columns same in both datasets. however, i'm wondering if there way can instead directly modify names of terms in fitted lm object, example term x1 can renamed x2 , can run predict(model, data) data has column called x2 in it.

Unexplained StreamLimitationException thrown on Android with Deezer SDK -

i'm using deezer android sdk. first order have things working, throws "streamlimitationexception" explanation deezer account being used on device. however, know account not being used on device -- not on mobile device, , not in browser. changed account password make sure nobody else using it. i'm using trackplayer. i've found if try re-use same track player multiple songs, doesn't work. every time want play new song, call stop() , release() methods on existing trackplayer, obtain new one. the exception thrown when try start playback on new song. appears random me, in i'm not aware of fixed timeout respect time the deezerconnect object authorized. furthermore, i'm trying minimize possibility of timeout -- i've used both: deezerconnect.setaccessexpires(long.max_value); and deezerconnect.setaccessexpires(0); with no luck. additionally, i've tried periodically re-authorizing deezerconnect object every few minutes, hasn'...

c++ - G++ Linker error: undefined reference to -

this question has answer here: what undefined reference/unresolved external symbol error , how fix it? 27 answers i'm trying compile program in c++, compiler returning error: operadoraarquivos.o: in function `split(std::string, int&)': operadoraarquivos.cpp:(.text+0x0): multiple definition of `split(std::string, int&)' main.o:main.cpp:(.text+0x0): first defined here hash.o: in function `hashtable::hashtable(int)': hash.cpp:(.text+0x65): undefined reference `lista<palavra>::lista()' hash.cpp:(.text+0xba): undefined reference `lista<palavra>::~lista()' hash.o: in function `hashtable::~hashtable()': hash.cpp:(.text+0x134): undefined reference `lista<palavra>::~lista()' hash.o: in function `hashtable::inserir(std::string, int)': hash.cpp:(.text+0x2d0): undefined reference `lista<palavra>::vazia()' ...

C++ Why the call is ambigous? -

class myclass { int arr[100]; public: void *get(long i, void* const to) const; void *get(long i, bool nog); void *tstfn(void* const to) { return get(0l,to); } }; gcc -wall says: dt.cpp: in member function ‘void* myclass::tstfn(void*)’: dt.cpp:6:49: warning: iso c++ says these ambiguous, though worst conversion first better worst conversion second: [enabled default] dt.cpp:4:9: note: candidate 1: void* myclass::get(long int, void*) const dt.cpp:5:9: note: candidate 2: void* myclass::get(long int, bool) both function calls require type conversion: calling void* function requires adding const qualifer this calling bool function requires converting to void* bool . so, overload resolution rules, neither "better" match other, , call considered ambiguous. perhaps can add const second function; perhaps remove first (although i'd prefer not to); perhaps can explicit type conversion of either this or to force preferred override. ...

sql - Best practices when implementing Relational Models who need constraining logical cardinality across several entities -

there n cities. each city disposes m different types of souvenir fridge magnets then there y travelers. every traveler collects z magnets, single 1 per city @ most. 2 different travelers buy same city magnet. n city 1 <--> m magnets z <--> y traveler i'd appointed best way enforce traveler can have z magnets if , if each magnet corresponds single city, in relational fashion keys or better normalization, or know best practice strategy it. uml 1.magnet * <--> 1 city 2.bought - association class beetwen city , traveler 3.bought * <--> 1 magnet 4.ocl constraint: context bought inv:city=magnet.city database city 1.idcity (pk) traveler 1.idtraveler (pk) magnet 1.idcity (pk, fk) 2.idmagnet (pk) bought 1.idcity (pk, fk1) 2.idmagnet (fk1) 3.idtraveler (pk, fk2)

c# - How to show a scheduled dialog in a Windows Phone 8.1 Runtime app? -

i'm trying code timer-app c# windows phone 8.1 runtime. goal show dialog , play sound file when timer ended. if user press "ok" sound stopped. "snooze" function great. maybe not in app, i'm planning personalized alarm clock too. because add timespan timer datetime.now easiest way trigger @ specified time. here ideas had, don't want. register background task. there's no trigger specified time. timetrigger fires @ every 30 min. solution, not resource friendly, methinks, if expected time within next 30 minutes , await specified time in background task , use contantdialog. not sure if possible @ all. another possibility use toast notification, there no possibility of interaction , not impressive, if want notice timer. alarms , reminders no longer available rt apps... is there no other way? if there trigger background tasks if internet connection active, isn't there trigger scheduled time? or maybe possibility code old alarms , reminders ...

Pass digits of a numeric string to an array in bash -

i have number, say number=5684398 and want store digits fields of array coolarray follows: coolarray[0]=5 coolarray[1]=6 coolarray[2]=8 coolarray[3]=4 coolarray[4]=3 coolarray[5]=9 coolarray[6]=8 how can proceed? you can use fold -w1 break input string each character: number=5684398 coolarray=( $(fold -w1 <<< "$number") ) printf "%s\n" "${coolarray[@]}" 5 6 8 4 3 9 8

css - Controlling jQuery-ui Autocomplete's dynamic positioning -

Image
so i'm trying understand why jquery-ui's autocomplete, appendto used attach results dropdown div, still dynamically positions results absolute positioning. this: top: 38px; left: 8.5px; width: 251px; creating issues like: can turn off dynamic positioning? full control on ui fluid responsivity , custom styling. cannot find answer online. update: seems each widget has different rules, correct? figured out responsive width jquery-ui dialog popup by $("#dialog").dialog({ width: auto }); & in stylesheet, applying max-width wrapping dialog class. .ui-dialog{ max-width: 720px; } however top , left still mystery of yet. you can change css used either editing jquery ui css file, or else overriding in own css, such as: ul.ui-autocomplete { width: 250px !important; max-height: 300px; overflow-y: scroll; overflow-x: none; }

sql server - How do I turn this SQL pivot into an inner join pivot? -

i have 3 tables: pupils, ks3assessments , assessmentsets. pupils each have studentid, fname, sname etc. assessmentset contains title of assessment, deadline, year group must complete it, etc. new ones created throughout year, titles/ids can't named explicitly in sql. ks3assessments records each have studentid refers pupil completed work, setid refers relevant assessmentset record , 'nclevel' indicating result pupil achieved. i need results overview table looks this: - studentid ¦ fname ¦ sname ¦ creative writing #1 ¦ novel study ¦ random thingy test ¦ etc. ¦ etc. - 072509273 ¦ adam¦ adamson¦ 5.5¦ 4.8¦ 6.5¦ etc.¦ etc¦ - 072509274 ¦ bob ¦ bobson¦ 5.8¦ 5.2¦ 7.2¦ etc.¦ etc¦ ... that, @ time, teacher can see pupil has achieved in whatever assessments they've done far. so far, using pivot, i've managed this: - studentid, fname, sname, 147, 146, 154 (these numbers setids) - 072509273, adam, adamson, 5.5, 4.8, 6.5 - 072509274, bob, bobson, 5.8, 5...

activerecord - How to get current value of attribute before saving new one in AR? -

i have model such attributes: some_number some_string i want put value in some_string depending on current value of some_number , new value of some_number on updating. example: current some_number 4 new (updated) value of some_number 5 i want put 4+5 string some_string before some_number overwritten. how can worked? if need modify attribute depending on other attribute value on update event i'd that: class thing < activerecord::base before_update :modify_some_string protected def modify_some_string # actions self.some_string , self.some_number # , self.some_string_was , self.some_number_was end end

How does IN SQL looks in C# linq -

how in sql looks in c# linq, have tried select * acon.productdata.lngtext lngcod='swe' , textid in (select distinct [alfcod] [acon].[measure].[ratedcurrent]) this from l in lngtexts l.lngcod=="swe" && l.textid.contains((from m in measure_ratedcurrents select m.alfcod).distinct()) select l dosn't work you need use contains on result of inner query: from l in lngtexts l.lngcod=="swe" && (from m in measure_ratedcurrents select m.alfcod).distinct().contains(l.textid) select l

java - How to get the TimeZone of the local machine in JodaTime? -

how can detect timezone local machine in? i tried datetimezone.getdefault() not give me eg timezone "germany" if machine in germany. is possible @ all? datetimezone.getdefault() return id of timezone should berlin, if host located in germany. in formatter have formatter.withzone(datetimezone.getdefault()).parsedatetime(yourdatetime) in order have timezone in string.

What does exactly is the Microsoft.Owin.Cors middleware when used with ASP.NET Web Api 2.0? -

i have asp.net web api 2.0 project token authentication , done following article: token based authentication using asp.net web api 2, owin, , identity , bit of technology but struggling understand line of code in startup.cs does: app.usecors(microsoft.owin.cors.corsoptions.allowall); this not make web api add access-control-allow-origin header api responses, in other words not enable cors in web api (still trying understand how way). not add bearer token authentication server response. have have code oauthauthorizationserverprovider: public override task grantresourceownercredentials(oauthgrantresourceownercredentialscontext context) { context.owincontext.response.headers.add("access-control-allow-origin", new[] { "*" }); to enable cors on token provider end point responses. so use of microsoft.owin.cors middleware anyway? because everywhere read web api 2.0 , cors line of code app.usecors(microsoft.owin.cors.corsoptions.allowall); ...

javascript - Optimizing Regex for removing classes -

i have function use remove classes element in javascript. var reg = new regexp(cls+'(\\s|$)'); this.el.classname = this.el.classname.replace(reg, '').replace(/\s+$/g, ''); say have 3 classes on element show hide color the first 2 removed along whitespace after it, third get's removed since there no whitespace after it, leaves space before it. string has whitespace on end. added second replace function rid of that, used in 1 circumstance question: how rid of second replace function , have 1 regex want. thanks! maybe handle cases. # (?:\s(?:show|hide|color)|(?:show|hide|color)\s|\b(?:show|hide|color)\b) (?: \s (?: show | hide | color ) | (?: show | hide | color ) \s | \b # or ^ (?: show | hide | color ) \b # or $ )

onclick not running when specified in javascript -

when click button, doesn't run onclick. tried in console , worked fine. can help? function customalert(message) { sect = document.createelement("section"); sect.classname = "alert"; sect.innerhtml = message + "<br /><br />"; var = document.createelement("button"); but.innerhtml = "gotcha."; but.onclick = "document.body.removechild(sect);"; sect.appendchild(but); document.body.appendchild(sect); } you should use syntax: but.onclick = function () { document.body.removechild(sect); } so, onclick property . means has value. when btn clicked, javascript (the browser) calls property, expects function, code executed. instead, "sees" string , not know it.

version control - Overwrite obsolete solution in tfs dev branch with solution in tfs main branch -

in tfs 2013 how can overwrite folders , files under specific folder data branch? i have main , 2 dev branches , different functionality has been added same solution in both dev branches. main in sync 1 dev branch. functionality has been added dev branch not in sync obsolete , want sync solution in branch whats in main. solution differs alot between main , obsolete branch traditional merge wont work. why not delete branch (or rename archive purposes), , create new branch off main? another option rollback changesets in obsolete-dev branches history, merge main.

c# - Thread with while (true) loop exits somehow -

i have thread supposed run continuously in program , parse incoming serial data collection of sensors. //initialized global variable system.threading.thread processthread = new system.threading.thread(processserialdata); //this gets called when press start button processthread.start(); private void processserialdata() { while (true) { //do whole bunch of parsing stuff } int howdidyougethere = 0; } how possible program reaching "int howdidyougethere = 0" line?? full code can found here: /// <summary> /// processserialdata thread used continue testing connection controller, /// process messages in incoming message queue (actually linked list), /// , sends new messages updated data. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void processserialdata() { while (true) { updateahtextb...

io - Haskell interact() truncating my output? -

i'm working on basic haskell program contains line of code: interact (unwords . (map piglatin . words) ) however, after passing array of strings piglatin function, wrapping string, truncates last word enter. instance: *haskellpractice> getuserinput broken histay isway for reason not printing that. on mac, have following options declared in getuserinput before call interact: hsetbuffering stdin linebuffering hsetbuffering stdout nobuffering i'm guessing it's small detail have yet understand. input/help! osftw edit: here's whole program. import system.io piglatin :: string -> string piglatin word = if ( (head word) `elem`['a', 'e', 'i', 'o', 'u'] ) (word ++ "way") else (tail word) ++ [(head word)] ++ "ay" getuserinput = hsetbuffering stdin linebuffering hsetbuffering stdout nobuffering interact (unwords . (map piglatin . words) ) here program teste...

algorithm - Simple recurrence in C++ -

Image
simple recurrencemax. score 0 our hero - alex has been working on research week. , has gotten recurrence relation solving part of research. has no time. it? recurrence relation follows : f(n) = 3 * f(n-1) + 2 * f(n-2) + 2 * g(n-1)+3 * g(n-2) , g(n) = g(n-1) + 2 * g(n-2). you given initial value of f(1), f(0), g(1), g(0). you have output f(n) mod 10^9. input: in first line given 4 numbers : f(1), f(0), g(1), g(0) respectively. in next line given integer n. output: output f(n) mod 10^9. constraints: 1 <= f(0),f(1),g(0),g(1) <= 10 1 <= n <= 10^18 sample input (plaintext link) 1 1 1 1 4 sample output (plaintext link) 162 this indeed easy question. used iteration 6 variables f0, f1, f2, g0, g1, g2 solve it. in loop, first compute g2, f2, f0=f1, f1=f2, g0=g1, g1=g2. data types unsigned long long in c++. however, time limit 1 second , 1.06 second. therefore passed 1 test case in test, others "tim...

jquery - JavaScript array manipulation to delete odd array elements -

i need help; have array this: myarray = ["nonsense","goodpart","nonsense2","goodpar2t","nonsense3","goodpart3",] i need delete "nonsense" part array. nonsense have index. i'd suggest, on basis 'nonsense' words (as stated in question) 'even' elements: var myarray = ["nonsense", "goodpart", "nonsense2", "goodpar2t", "nonsense3", "goodpart3"], filtered = myarray.filter(function(el, index) { // numbers have feature number % 2 === 0; // javascript is, however, zero-based, want elements modulo of 1: return index % 2 === 1; }); console.log(filtered); // ["goodpart", "goodpar2t", "goodpart3"] if, however, wanted filter array-elements themselves, remove words contain word 'nonsense': var myarray = ["nonsense", "goodpart", "...

Trying to Load an Image with Dialogue Box in Python and Display it in a Layer - PYTHON 3.4 using Tkinter and PIL -

i trying make simple photo editor. got functions editing photos. trying make nice gui. when user presses file>open, open dialogue box comes , can choose image. want image load inside of layer in gui. here code far: p.s. when put code inside open_img function outise function, works, when put inside function, no image loads import os tkinter import * import tkinter.messagebox pil import image, imagetk tkinter.filedialog import askopenfilename def g_quit(): mexit=tkinter.messagebox.askyesno(title="quit", message="are sure?") if mexit>0: mgui.destroy() return #open menu def open_img(): file = tkinter.filedialog.askopenfilename(initialdir='d:/users/') w_box = 500 h_box = 500 pil_image = image.open(file) w, h = pil_image.size pil_image_resized = resize(w, h, w_box, h_box, pil_image) # wr, hr = pil_image_resized.size tk_image = imagetk.photoimage(pil_image_resized) label2.config(image...

javascript - Jquery selecting elements next/prev/closest -

hi have html , want add actions when user click on h4. <div class="row success"> <div class="col-sm-4 no-pad-r img-toggle"> <?php the_post_thumbnail(); ?> </div> <div class="col-sm-6 col-sm-offset-1 no-pad-l"> <h4 class="heading-toggle"><?php the_title(); ?></h4> <div class="line"></div> <p class="intro">"<?php the_field('first_line'); ?>."</p> <div class="toggle-content" style="display: none"> <div class="main-copy"> <?php the_content(); ?></div> <h5><?php the_field('author_name'); ?></h5> <p class="position"><?php the_field('author_position'); ?></p> </div> <button class="btn toggle btn-danger"></button> </div> so want ...

Java Programming nested loops -

so have of code written, there's 1 part of assignment don't understand. write program accept number (n) user represent size of board (nxn). if user not enter number greater 1, prompt user on , on until he/she gives valid input. once valid input obtained, print board every other column filled 1s along last row filled 1s. zeros everywhere else. board have equal number of rows , columns based on users input. i have pattern 0's , 1's don't understand how can last row have 1's. here code posted below import java.util.scanner; public class question1 { public static void main(string[]args) { scanner input = new scanner(system.in); int n; system.out.println("please input value board greater 1."); n= input.nextint(); while(n<1) { system.out.println("error, please enter value greater 1"); n=input.nextint(); } for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { if(j%2==0) { system.out.pr...

objective c - Is there anyway put a UILabel to a CPTSymbol? -

i need show text @ cptsysmol position,is there anyway can solve it? if want label data points values, use "data labels". otherwise, attach plot space annotation data point , use cpttextlayer in annotation display text.

java - PyLucene error with IceTea / JDK / JRE -

i have followed installation instructionrs http://bendemott.blogspot.de/2013/11/installing-pylucene-4-451.html pylucene using latest pylucene-4.9.0.0 . and when tried to lucene.initvm() , following error: alvas@ubi:~$ python python 2.7.6 (default, mar 22 2014, 22:59:56) [gcc 4.8.2] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import lucene >>> lucene.initvm() # # fatal error has been detected java runtime environment: # # sigsegv (0xb) @ pc=0x00007ffba22808b8, pid=5189, tid=140718811092800 # # jre version: openjdk runtime environment (7.0_65-b32) (build 1.7.0_65-b32) # java vm: openjdk 64-bit server vm (24.65-b04 mixed mode linux-amd64 compressed oops) # derivative: icedtea 2.5.3 # distribution: ubuntu 14.04 lts, package 7u71-2.5.3-0ubuntu0.14.04.1 # problematic frame: # v [libjvm.so+0x6088b8] jni_registernatives+0x58 # # failed write core dump. core dumps have been disabled. enab...

rules - drools working with dates -

in official documentation can't find information how write conditional statements java.util.date type fact fields in guided rules. example how compare such field current date, check if equal omitting time, or check if date before time now? drools isn't real-time program , doesn't have innate idea of time or now. if need investigate relations of fact property w.r.t. point of time x, you'll have establish fact carrying x data, , write rules based on that. a more or less coarse approximation of fact representing can made using timers. can implement rule modifies fact containing value representing time (e.g. java.util.date) every second, or less frequently. blending out time of day you'll have using java or drl functions. alternatively, if days interested in, use custom class representing days, suitable day 1 defined you.

java - Unexpected output in dividing two numbers -

this question has answer here: how make division of 2 ints produce float instead of int? 9 answers why code giving 0.0 answer? public static void main(string[] args) { float ans = (480/1080); system.out.println(ans); } you dividing 2 integers, result integer. 480/1000 < 1 , therefore truncated 0. result cast float stored in float variable. to divide numbers floats, cast 1 of them: float ans = ((float)480/1080);

javascript - Dynamically loading combo box values -

i have combobox on change triggers ajax call , fetches few values. these values used create combobox. the code below used dynamically load options of combobox: function appendoption(select,option) { try { alert(select.innerhtml+"--select--"+option.innerhtml+"--option"); alert(select.add(option, null)); // shows option tag formed select.add(option, null); // not adding option element combo } catch (e) { alert(e.message()); } } the select object inside method valid object. i have used chosen-select jquery plugin creating combo box. above method working fine in case of normal combo (not chosen-select). can please me? if problem "select control not populating added option" need add $('.my_select_box').trigger('chosen:updated'); method once finish adding options. in case after add method. chosen control need told changes made them.so calling above update trigger tells chosen ...

scroll - overflow hidden and scrolling no not working in embed -

i unable hide scrolling in embed. try 2 methods,- method 1: <embed scrolling="no" src="http://www.pjsindia.com"style="background-color: #55a97c;" width="400px" height="400px"></embed> method 2: <embed src="http://www.pjsindia.com"style="background-color: #55a97c; overflow:hidden;" width="400px" height="400px"></embed> you can try overflow: auto it may work in browsers not guaranteed work in browsers. should test in browsers.

python - pandas dataframe timeseries:linegraph per day -

first of all: although quite experienced in spss, i'm absolute beginner in python , pandas. i'm trying learn because think it's far more versatile , flexible... couldn't find python forum dummies ;) hope can help... my question: i've got dataframe traffic-data per period of 5 minutes: in[37]: df.head(3) out[37]: rws01_monibas_0121hrr0070ra_speed \ time 2014-09-29 15:00:00 101.124752 2014-09-29 15:05:00 100.626442 2014-09-29 15:10:00 102.247742 rws01_monibas_0121hrr0070ra_flow \ time 2014-09-29 15:00:00 1824 2014-09-29 15:05:00 2184 2014-09-29 15:10:00 1908 in[38]: df.tail(3) out[38]: rws01_monibas_0121hrr0070ra...

javascript - Unable to get property 'stringify' of undefined or null reference -

i getting error after ajax call fails , i'm trying log error object stringifying , saving sesssionstorage. site not in compatibility view or enterprise mode, ie11 , doctype <!doctype html> , document mode edge , user agent string default. happening once in blue moon it's hard track down happening. haven't been able error being thrown yet, create own string catches details of error need , able move forward. has else run situation json should available isn't? again, doctypes/compatibility settings fine , happens once in blue moon. read stringify here . the cause of problem try call stringify method of variable null reference or undefined . make sure not case, validate value valid json: function isnullorundefined(param) { return (!param); } then before call stringify foo: if (!isnullorundefined(foo)) { //some code involving foo.stringify }

How to design database table for dynamic added values in android? -

i have single registration form in application. when user clicks on submit button form, these values stored in database. want design table database, problem have dynamically added values. means have added "add(+)" button. when user clicks button, adds more text fields. if userfills fields, have more fields need entered database. an example of query: string create_medicine_table = " create table medicinetable " + "( id integer primary key ," + " class integer ,name text, instructions text , fdate text ,tdate text,time char)"; have fixed schema table default form elements. for storing data user keeps adding new fields have table bolew _id, user_id, field_key, field_value you have 1 many relation main table second table user_id foriegn key main table has default form entry user now if case like, dont have default entries in form, all dynamic keys, generate user_id user , follow second table describe...

Share a persistent disk between Google Compute Engine VMs -

from google's documentation: it possible attach persistent disk more 1 instance. however, if attach persistent disk multiple instances, instances must attach persistent disk in read-only mode. not possible attach persistent disk multiple instances in read-write mode. if attach persistent disk in read-write mode , try attach disk subsequent instances, google compute engine returns error. so, need have share persistent-disk frontend compute engine, good, how can write on shared disk? my guess (i hope) a read/write persistent-disk can attached 1 compute engine same disk can share in read others vms, thats right? lets have 2 compute engine vms , 2 persistent disks, flow possible? compute1 read/write disk1 , read disk2 compute2 read/write disk2 , read disk1 no, not possible, documentation cited @ time of writing said (since updated): however, if attach persistent disk multiple instances, instances must attach persistent disk in read-only mode. ...

javascript - Facebook Login - Tell joomla to login -

i'm developing facebook login (fb sdk javascript) joomla site add alternative way register/login. what i've done are: create fb app insert relevant code site get connected stat fb.login() . got basic information: name, email...etc i got found below function use login in joomla, way require me provide username & password. $result = jfactory::getapplication()->login(array('username' => $username, 'password' => $password), array('remember' => true)); my question is: after got permission fb, wish login joomla without enter email , password, module/helper/function should use?

join - Ideal solution for the following case scenario in database -

there 50 exams written around millions of students online, 1 person may or may not write more 1 exam. person can write single exam more 1 time ( retries ) .. so of below solution better case, i okay better solution these 2 well option 1. store each exam in single table : subject 1 +----------------+---------+ | student id | marks | +----------------+---------+ | 1 | 85 | | 2 | 32 | | 2 | 60 | +----------------+---------+ subject 2 +----------------+---------+ | student id | marks | +----------------+---------+ | 1 | 85 | | 2 | 32 | | 2 | 60 | +----------------+---------+ like above each table have student id if particular person has taken exam , , have multiple occurrences of student id if has taken more once. option 2 : +----------------+---------+---------+ | student id | subject | marks | +----------------+---------+--...

haskell - Square a list of numbers and divide it by the mean of the list -

i need square list of numbers , divide mean of list. far have got: square :: float -> float square x = x * x s2 :: [float] -> float s2 xs = map square (map (\c -> c - mean) xs) any apreciated. s2 :: [float] -> float s2 xs = sum $ map ((/mean).(^2)) xs mean= sum xs / fromintegral (length xs) test: λ: s2 [1.0, 2.0, 3.0] 7.0

r - RGA (CRAN) - "get_accounts" gives wrong accounts -

note says: rga package cran. different "rga" package github. nevertheless, have same problem both packages. question let's stick rga cran. **the questions updated , edited, because first aid not enough. still have problems accounts. i work 2 emails accesing google analtics. each 1 has access diffent accounts within google analytics. use email @ house, , email b @ work. now, im using rga (from cran) within r, , @ house need access google analytics accounts email b (work email, has access specific google analytics accounts). the problem when using code: for account 1: email (home email): client.id1 <- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" client.secret1 <- "bbbbbbbbbbbbbb" ga_token1 <- authorize(client.id1, client.secret1, cache = true, verbose = getoption("rga.verbose", false)) get_accounts(start.index = null, max.results = null, ga_token1, verbose = getoption("rga.verbose", false)) for ac...

javascript - Check selection inside or outside of a class -

Image
i have following lines of script selected area of document. sel = window.getselection(); console.log(sel); i have results in console image below. my question is, is possible check selected text inside or outside of element specific class/id? you can use anchornode (the node in selection begins) , focusnode (the node in selection ends) try determine whether or not selection in desired element. assuming element you're interested direct parent of text being selected, can do: var sel = document.getselection(); var startsintarget = sel.anchornode.parentelement.classlist.contains("target"); var endsintarget = sel.focusnode.parentelement.classlist.contains("target"); if(startsintarget && endsintarget) { //selection within element class "target" } here's jsfiddle demonstrating idea

convert byte[] from json in android -

how byte[] json using webservice my json format given below: [{"imglogo":[255,216,255,224,0,16,74,70,73,70,0,1,1,0,0,1,0,1,0,0,255,219,0,132,0, 9,6,7,20,19,18,20,20,19,20,21,22,20,22,20,21,24,22,21,21,20,20,20,20,20, 24,21,20,22,24,20,20,20,23,24,28,40,32,24,26,37,28,20, 21,33,49,33,37,41,43,46,46,46,23,31,51,56,51,44,55,40,45,46,43,1,10,10,10 ,14,13,14,27,16,16,26,44,36,28,36,44,44,44,44,44,44,44,44,44,44,44,44, 44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44, 44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,255,192,0,17,8,0,194,1,3,3....]}] i'm using following code json value : jsonobject jsonchildnode = jsonmainnode.getjsonobject(i); string imagestring = jsonchildnode.getstring("imglogo"); now, i'm getting above byte[] value string. how can convert string byte[] first create string containing data , byte[] data = base64.decode(iconstring, base64.default); now have byte array contai...

.net - Injecting SignInManager dependency: does not work with Unity, works when using OWIN -

i adding asp.net identity authentication functionality asp.net mvc 5 web application. i using unity dependency injection across project, decided inject dependencies required accountcontroller in constructor: public accountcontroller(usermanager<applicationuser> usermanager, signinmanager<applicationuser, string> signinmanager) { _usermanager = usermanager; _signinmanager = signinmanager; } my login method implemented following (actually, copied code asp.net web application project template individual user accounts authentication): // // post: /account/login [httppost] [allowanonymous] [validateantiforgerytoken] public async task<actionresult> login(loginviewmodel model, string returnurl) { var result = await _signinmanager.passwordsigninasync(model.email, model.password, model.rememberme, shouldlockout: true); // process result , return appropriate view... // however, there no authentication cookies in response! } the problem auth...