Posts

Showing posts from May, 2013

reactjs - React router and nested routes -

Image
i confused how create following (really simple) route structure. i have app has top-level route login component: and top-level route app (let's call home component): now, home component has header, sidebar, , main space child views. the login component should shown @ /login path; that's simple enough. confuses me want / path show home component particular child component (let's call welcome) in main view. also, of other routes can think of should render child components inside home component. so, reiterate: path / renders home component welcome component inside it path /foo renders home component foo component inside it ... path /login renders login component it feels structure thinking is: <route path='/' component={app}> <indexroute component={home}> <indexroute component={welcome}> <route path='foo' component={foo}/> </indexroute> <route path='login'

How to mimic something like "set intersection" and "set union" with Clojure(Script) strings? -

suppose s , t strings defined respectively follows: ;; s b c ;; t b c d are there analogous clojure(script) operations string-intersection , string-union (for lack of better name) satisfy following? (string-intersection s t) ;; => ;; b ;; c and (string-union s t) ;; => ;; ;; b ;; c ;; d as can see, string-intersection eliminate (on line-by-line basis) non-matching lines (leaving lines match), while string-union has effect of combining lines , ignoring duplicates. note: i'm using clojurescript, imagine answer generalize clojure well. from description seems treat strings set of lines , calculate set intersection , union. for working sets, can use clojure.set namespace. first convert strings set of lines: (require '[clojure.string :as str] '[clojure.set :as set]) (def s "a\nb\nc") (def t "b\nc\nd") (def s-set (into #{} (str/split-lines s))) (def t-set (into #{} (str/split-lines t))) then can cal

android - how to set width of widget programatically in dips -

i'm adding widget layout dynamically. need set widget width 100 through code below : width = 100; how can convert above given value dps in android /** * method converts device specific pixels density independent pixels. * * @param px value in px (pixels) unit. need convert db * @param context context resources , device specific display metrics * @return float value represent dp equivalent px value */ public static float convertpixelstodp(float px, context context){ resources resources = context.getresources(); displaymetrics metrics = resources.getdisplaymetrics(); float dp = px / (metrics.densitydpi / 160f); return dp; } credit: converting pixels dp

Cakephp foreach condition -

i have show table of reservation of 3 biens should show me 3 line of 3 reservation show me 1 line in controllers public function index_hote() { $this->reservation->recursive = 1; $this->loadmodel("bienspersonne"); if($this->session->read('auth.user.0.personne.id')){ $options = $this->bienspersonne->findbypersonneid($this->session- >read('auth.user.0.personne.id')); $this->loadmodel("personne"); $biens=$this->personne->findbyid( $options['bienspersonne']['personne_id']); foreach ($biens['bien'] $bien) { $reservations=$this->reservation- >find('all',array('conditions'=>array('reservation.idbien'=> $bien['idbien']))); debugger::dump($reservations); $this->paginate('reservation'); $this->set('reservations', $reservations); }}} in view <?php foreach ($reservations $reserv

sql server - SQL Northwind Practice -

i have practice question: show each order item – customer name , order id, product name, ordered quantity, product price , total price (ordered quantity * product price) , gap between ordered date , shipped date (the gap in days). order order id. northwind of course. my query was: select c.contactname, o.orderid, p.productname, od.quantity, od.unitprice, od.quantity * od.unitprice [total price] orders o, customers c, products p, [order details] od c.customerid = o.customerid , o.orderid = od.orderid , od.productid = p.productid order o.orderid; the thing not is: "gap between date , shipped date". don't it. thanks. pertinent question, gap between ordered date , shipped date refers calculated value of: datediff(day, date_ordered, date_shipped) gapdays using sql datediff () function, date_ordered , date_shipped corresponds field names in table (you may need rename them per actual fields; also, correct

how to create an IntSet on the heap in nim? -

there various libraries in nim return actual objects, rather references. want object on heap (regardless of efficiency) -- instance when have generic procedure expects ref object. the way construct intset on heap have found is: proc newintset() : ref intset = new(result) assign(result[], initintset()) this seems work, feels hack. worry if seems work. (are structures copied "assign" cleaned up?) there better way? there more generic way work other objects? your code valid. resulting reference subject garbage collection other referefence. if find doing often, can define following makeref template rid of code repetition: template makeref(initexp: typed): expr = var heapvalue = new(type(initexp)) heapvalue[] = initexp heapvalue here example usage: import typetraits type foo = object str: string proc createfoo(s: string): foo = result.str = s let x = makeref createfoo("bar") let y = makeref foo(str: "baz") echo "

Can I provide more permission to a user (Not manager) in Mantis Bug Tracker -

i'm administrator of mantis bug tracker in working place. there several reporter accounts, developer accounts on it. my question both of these user accounts have less permission. i'm facing 2 questions on it, 1. reporter not able edit issues. 2. developer not able create new version number. is possible provide more permission user without changing account type? thank you unprivileged reporters being able edit own issues not yet possible ( bug #8141 ). managing versions tied manage_project_threshold , if want developers able create versions need grant them full access project management pages.

python 3.x - Django Server autorun when Ubuntu startup or reboot? -

i want logic server(python3+django+uwsgi+nginx) autorun when ubuntu-server startup or reboot. so, write execute script ( uwsgi --ini=/data/xxx.ini ), , add /etc/rc.local . then, restart server, logic-server running, but when program print log file , python3 throw exception: traceback (most recent call last): file "/usr/lib/python3.4/logging/handlers.py", line 73, in emit logging.filehandler.emit(self, record) file "/usr/lib/python3.4/logging/__init__.py", line 1041, in emit streamhandler.emit(self, record) file "/usr/lib/python3.4/logging/__init__.py", line 984, in emit self.handleerror(record) file "/usr/lib/python3.4/logging/__init__.py", line 915, in handleerror traceback.print_stack(frame, file=sys.stderr) file "/usr/lib/python3.4/traceback.py", line 286, in print_stack print_list(extract_stack(_get_stack(f), limit=limit), file=file) file "/usr/lib/python3.4/traceback.py", line 30,

angular - angular2 - dynamic url for component(like: /heroes or /heroes/:id all for HeroComponent) -

@routeconfig([ {path: '/heroes(/:id)?', name: 'heroes', component: herocomponent} ]) ngoninit() { let id = this._routeparams.get('id'); if (id) { this._service.findbyid(id).then(hero => this.hero = hero); } else { this._service.findby(null).then(heroes => this.heroes = heroes) } } when has id, findbyid(id) other findby(model) ,because list view , detail view in 1 page,and want write code in 1 .ts file, how resolve? @routeconfig([ {path: '/heroes', name: 'heroes', component: herocomponent} ]) get url /heroes?id=11 ,not rest,and config 2 route badly

operating system - Are pages only secondary memory like hard drives, or are they used for RAM too? -

i'm confused this. are pages memory units exist in secondary memory or exist in ram too? paging memory management scheme computer stores , retrieves data secondary storage use in main memory. pages used in ram too, solution of external fragmentation. external fragmentation situation when total free space enough hold process space available not contiguous. compaction 1 of solution processes run-time loaded only. so, paging true solution external fragmentation implement page table gives illusion process has been given contiguous memory. every address cpu broken down page number , offset.

ios - client server json response -

i need display particular object key(currency) using post method after getting response web. #import "viewcontroller.h" @interface viewcontroller () @end @implementation viewcontroller{ nsmutabledata *mutabledata; nsmutablestring *arr; #define url @"website" // change url #define no_connection @"no connection" #define no_values @"please enter parameter values" } - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. } -(ibaction)senddatausingpost:(id)sender{ [self senddatatoserver :@"post"]; } -(ibaction)senddatausingget:(id)sender{ [self senddatatoserver : @"get"]; } -(void) senddatatoserver : (nsstring *) method{ nsstring *branchid=@"3"; serverresponse.text = @"getting response server..."; nsurl *url = nil; nsmutableurlrequest *request = nil; if([method isequaltostring:@"get"]){

ios - Assign Text in Code to UILabel! Swift 2.2 -

using tutorial ios 8/swift 1 create sample app in attempt assign text label, using xcode 7.3/swift 2.2. in advance. import uikit class viewcontroller: uiviewcontroller { @iboutlet var agecat: uitextfield! @iboutlet var resultage: uilabel! @ibaction func findagebutton(sender: anyobject) { var enteredage = int(agecat.text!) var catyears = enteredage! * 7 resultage = "your cat \(catyears) in cat years" } } replace ibaction func findagebutton following: @ibaction func findagebutton(sender: anyobject) { // here variable unwrapped. means code after not executed unless program sure contains value. if let text = agecat.text { // can use unwrapped variable , won't have place exclamation mark behind force unwrap it. let enteredage = int(text) if let age = enteredage { let catyears = age * 7 resultage.text = "your cat \(catyears) in cat years" } } }

performance - F# efficiency implications of passing large data structures between functions -

how f# pass data caller function called function? make copy of data before handing on or pass pointer? think latter want make sure. on related note, there performance implications of following 2 f# code styles. let somefunction e = 1//pretend complicated function let someotherfunction e = 2//pretend complicated function let foo f largelist= list.map (fun elem -> f elem) let bar largelist = largelist |> foo somefunction |> foo someotherfunction let bar2 largelist = let foo2 f f2 = largelist |> list.map (fun elem -> f elem) |> list.map (fun elem -> f2 elem) foo2 somefunction someotherfunction would expect bar have different performance bar2? if not, there situations should aware of make difference? the short answer: no. entire list not copied, reference is. the long answer: in f# (just in c#) both value , reference types can passed either value or reference. both value types , ref

Jquery datepicker: highlight 'today' when clicked? -

i have jquery datepicker on site, calendar visible. problem cannot seem select 'today'. well, can, doesn't change highlight other days do, keeps 'today-look' , pretty confusing. is there built-in way how highlight today when selected (as other elements are)? <- preferred is there way hide today's highlight js? thank you! you can override jquery ui css.try jsfiddle /*selected date */ .ui-state-active{ color:red !important; } /*todays date*/ .ui-state-highlight{ border:none !important; }

Modifying java array within a JSP input form -

i trying modify java array within <input> tag in jsp string[] userproperties = {"one", "two", "three"}; string[] propvalues = new string[userproperties.length]; . . . <% for(int = 0; < userproperties.length; i++) { %> <tr> <td> <input type="text" size="30" maxlength="150" name="<%=propvalues[i]%>" value="somevalue"> </td> </tr> <% } %> . . . i there 3 input forms in example, , each form, value entered user bound appropriate position in propvalues array once submit button clicked. modifying based on older code had name set local java variable, , successful in being able modify variable. not possible arrays in jsp? aware jstl has <c:foreach> tag makes simpler, since working single file in aged codebase want keep libraries has access consistent. possible using <%> java code blocks?

javascript - Progressbar.js setText dynamically -

i trying update text inside progressbar chart specific text when call function. js: var progressbarchart; function progressbar(progressvalue, textvalue){ if (progressbarchart == null) { progressbarchart = new progressbar.circle (progress_container, { color: '#aaa', strokewidth: 4, trailwidth: 1, easing: 'easeinout', duration: 1400, text: { autostylecontainer: false }, from: {color: '#aaa', width: 1}, to: {color: '#333', width: 4}, step: function (state, circle) { circle.path.setattribute ('stroke', state.color); circle.path.setattribute ('stroke-width', state.width); circle.settext (textvalue) } }); progressbarchart.text.style.fontfamily = '"raleway", helvetica, sans-serif'; progress

scorm2004 - Why the passed score is not storing in SCORM Cloud for SCORM 2004 3rd edition? -

Image
i launched scorm 2004(3rd edition) package in scorm cloud. passed exam of 80%, results not stored. attached sandbox registration state results. satisfied: true **completed: unknown** progress status: true attempts: 1 suspended: true activity objective #1 id: measure status: false **normalized measure: unknown** progress measure: true satisfied status: true runtime data **cmi.completion_status: unknown** cmi.credit: credit cmi.entry: resume cmi.exit: suspend cmi.learner_preference cmi.learner_preference.audio_level: 1 cmi.learner_preference.language: cmi.learner_preference.delivery_speed: 1 cmi.learner_preference.audio_captioning: 0 **cmi.location: 2_8 cmi.mode: normal cmi.progress_measure: cmi.score_scaled: cmi.score_raw: 80** cmi.score_min: cmi.score_max: **cmi.total_time: 0000:00:28** total time tracked scorm engine: 0000:00:29.12 cmi.success_status: passed cmi.su

ajax Json Web Method with amcharts in asp.net -

Image
error: after calling web method map comes blank..no map displaying in page <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link rel="stylesheet" href="ammap/ammap.css" type="text/css" media="all" /> <script src="http://www.amcharts.com/lib/3/amcharts.js" type="text/javascript"></script> <script src="http://www.amcharts.com/lib/3/pie.js" type="text/javascript"></script> <script src="http://www.amcharts.com/lib/3/ammap_amcharts_extension.js" type="text/javascript"></script> <script src="http://www.amcharts.com/lib/maps/js/worldlow.js" type="text/javascript"></script> <script src="https://code.jquery.com/jquery-2.2.1.js" type="text/javascript"></script> <script type

How to parse javascript in PHP page with Java? -

i want retrieve value of javascript section in php file application in java. the php page contain : <script type="text/javascript"> var tab= new array(); tab[0] = "value0"; tab[1] = "value1"; tab[2] = "value2"; </script> i'm using jsoup parsing html tag. tried use rhino don't find example. context context = context.enter(); scriptable scope = context.initstandardobjects(); object result = null; reader reader = new inputstreamreader(inputstreamofthepage); result = context.evaluatereader(scope, reader, "page", 1 , null ); scriptable varvalue = (scriptable)scope.get("tab", scope); string valuestr = (string)varvalue .get("tab[0]", varvalue ); it's giving me exception : java.lang.classcastexception: org.mozilla.javascript.uniquetag cannot cast org.mozilla.javascript.scriptable i don't know how cast object. maybe there better way want. thanks jsoup not sui

c# - Install SQL Server compact database .Exe file automatcally when I install WPF application -

i had developed wpf application, , backend sql server ce .sdf file. in setup , deployment project added .sdf file in it the issue is: access , records .sdf file require additional software. please find below link https://www.microsoft.com/en-in/download/details.aspx?id=17876 it has 2 exe files 64 bit 86/32 bit visual studio directly installs software when install vs on client system, didn't find these files unable access .sdf file , records it i need copy these files in application folder , automatically install if above software not present in pc now manually installing these software(exe ) in each pc you're mistaken - deploy sql server ce 4.0 based application, do not need deploy and/or install additional software client system - suffices include necessary, relevant sql server ce 4.0 dll's application (into bin or lib folder or something), , ship files application. that's all need - no server-side or client-side install needed !

Python correct encoding of Website (Beautiful Soup) -

i trying load html-page , output text, though getting webpage correctly, beautifulsoup destroys somehow encoding. source: # -*- coding: utf-8 -*- import requests beautifulsoup import beautifulsoup url = "http://www.columbia.edu/~fdc/utf8/" r = requests.get(url) encodedtext = r.text.encode("utf-8") soup = beautifulsoup(encodedtext) text = str(soup.findall(text=true)) print text.decode("utf-8") excerpt output: ...odenw\xc3\xa4lderisch... this should odenwälderisch you making 2 mistakes; mis-handling encoding, , treating result list can safely converted string without loss of information. first of all, don't use response.text ! not beautifulsoup @ fault here, re-encoding mojibake . requests library default latin-1 encoding text/* content types when server doesn't explicitly specify encoding, because http standard states that default. see encoding section of advanced documentation : the time requests not if no ex

swift - Array list item count and number of element in an array mismatch while using swiftyjson? -

import uikit import alamofire import swiftyjson class recentadded: uiviewcontroller ,uitableviewdatasource,uitableviewdelegate{ @iboutlet var tableview: uitableview! var list:json! var sendurl:string! override func viewdidload() { super.viewdidload() alamofire.request(.get, "http://api.dirble.com/v2/stations/recent", parameters: ["token": "260674ecb51572a8faa4e77199"]) .responsejson { response in if let json = response.result.value { self.list = json(data: response.data!) print(self.list) /// showing less element if element more 25 self.tableview.datasource = self self.tableview.delegate = self self.tableview.reloaddata() print(self.list.arrayvalue.capacity) // printing actual capacity } } // additional setup after loading view. } func tableview(tableview: uitable

c# - Best Practice Unity, to create different scripts or use switch-cases? -

i'm developing game on unity. there units, different functionalities somehow same attributes. what should do? create different script each kind or make single switch-cases , functions accordingly ? what best practice do? thanks in advance :) for example: have angry guy , calm guy, have 1 basic inheritance of person class, inherited same class unit, in have different switch cases determine angry , happy , calm , etc. should make different classes each of right way ? how using inheritance? https://msdn.microsoft.com/en-us/library/ms173149.aspx public abstract class baseunit{ public void virtual dosomething(){ // default code } } public class myunittype : baseunit{ public override void dosomething(){ // custom code if no want default logic } }

php - jQuery $.ajax post method not sending email in joomla -

after going through hundreds of questions, none of solutions offered have solved problem. issue simple, have joomla module sending emails. while creating module on live server joomla 3.5.1, when installed in live joomla website in different server, not end email. whats weird other functions in script works apart $.ajax({ responsible sending data server. had thought error occurring in server side upon sending email without jquery, works perfectly. code below. <script type="text/javascript"> jquery(document).ready(function ($) { $('#dock_send').click(function (e) { //first validation, $("#dock_sending").removeclass("hide"); alerts = ''; if ($("input[name=dock_skibzy_names]").val() == '') { alerts += "1"; $("#dock_error_name").addclass("error"); } if ($("input[n

javascript - JQuery dynamic update div content, jump by scroll position -

i have problem im not able solve in past days. writing simple chat based on php + jquery. have div chat content: <div class="conversation-message-list" onclick="hideemoticons()"> <div id="note">new message</div> <div class="conversation-content"> <div class="row"> message </div> </div> </div> with jquery call function refreshchat. selects new messages mysql , appends conversation-content this: $(".conversation-content").append(data.chat); chat window scrolling when there many messages. need is: when chat window scrolled @ bottom (user view last message), new message appends , automatic scrolled last message. if user scrolled , new message append, show message (in code id="note") not scroll last message. in summary, need same function on fb chat - if scrolled up, warning of new message shown in chat window. if chattin

ios - How to handle multiple touch gesture at a time? -

i have perform gesture on imageview @ time, means user can move imageview on single tap @ time on double tap zooming , rotation possible.now found methods perform multiple gesture unable perform zoom , roation. - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event; - (void)touchesmoved:(nsset *)touches withevent:(uievent *)event; - (void)touchesended:(nsset *)touches withevent:(uievent *)event; - (void)touchescancelled:(nsset *)touches withevent:(uievent *)event before applied uipinchgesturerecognizer , uirotationgesturerecognizer , uipangesturerecognizer handle 1 gesture @ time.please me solve or give me other better option if possible. uipinchgesturerecognizer *pinchgesture = ... //initialize pinchgesture.delegate = self; //same rotation gesture //and implement delegate method - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldrecognizesimultaneouslywithgesturerecognizer:(uigesturerecognizer *)othergesturerecognizer

jquery - Need to call dojo widget function from normal javascript -

i opening child window dojo widget, on close of child window need call parent window dojo widget function. is possible call dojo widget function normal javascript. if possible please share code snippet. it possible use registry call specific dijit widget in rest of application. you can use requiring module dijit/registry ( more info here ). the .byid() function reference widget registry. after can call function on widget object. a pseudo-code example below: require(['dijit/registry'], function(registry){ var widget = registry.byid('yourwidget'); widget.callyourfunction(); }) please consider adding minimum test case in question, can post more specific answer.

Github- repository is on remote but not found when pushing -

i'm trying push github , i'm getting error; robbies-macbook-pro:assn-6-huffman-mac user$ git push -u origin master fatal: repository 'https://github.com/bitmechanic/stanford-cs106b/huffman.git/' not found then when check this; robbies-macbook-pro:assn-6-huffman-mac user$ git remote add origin https://github.com/bitmechanic/stanford-cs106b/huffman fatal: remote origin exists. robbies-macbook-pro:assn-6-huffman-mac user$ git remote -v origin https://github.com/bitmechanic/stanford-cs106b/huffman.git (fetch) origin https://github.com/bitmechanic/stanford-cs106b/huffman.git (push) anyone know i'm doing wrong? the proper url use (for cloning , pushing through origin) is https://github.com/bitmechanic/stanford-cs106b.git not: https://github.com/bitmechanic/stanford-cs106b/huffman.git stanford-cs106b repo, listed in bitmechanic's repo page of d . stanford-cs106b/huffman not. to fix this, see git remote commands : git remote r

entity framework - Autofac using Constructor -

i use unit of work pattern entityframework code first. want use autofac register unitofwork, repositories , dbcontext. this unitofwork code: public class unitofwork : iunitofwork { private readonly dbcontext _context; public unitofwork(dbcontext context) { _context = context; contact = new contractrepository(context); } public void dispose() { _context.dispose(); gc.suppressfinalize(_context); } public icontactrepository contact { get; private set; } public int complete() { return _context.savechanges(); } } and repository: public class repository<entity> : irepository<entity> entity : class { protected readonly dbcontext _notebookcontext; public repository(dbcontext notebookcontext) { _notebookcontext = notebookcontext; } public void add(entity entity) { _notebookcontext.set<entity>().add(entity); } } and 1 of repositori

android - Unity3D - Get smooth speed and acceleration with GPS data -

i'm using unity3d , created simple distance, speed , acceleration calculator using latitude , longitude of last position. i'm calculating last distance, speed , acceleration in each gps update (approximately once per second). (2-3 second interval) latitude , longitude values changes rapidly (in clear weather , no obstacles). that's why speed , acceleration values gets unreal results. example, @ stable 40 km/h speed, speed value becomes 60 km/h , returns 40 km/h within 2-3 second. i'm here ask how can avoid inaccurate , rapid gps data changes? i'm using nexus 5 device there code: using unityengine; using system.collections; using unityengine.ui; using unityengine.scenemanagement; public class manager : monobehaviour { public text longitude, latitude, lonatext, latatext, lonbtext, latbtext; public text result, overallresult, speedtext, lasttimetext, timertext, accelerationtext, speed0text; float lona, lonb, lata, latb, overalldistance, lastdistance, timer