Posts

Showing posts from July, 2011

ios - Modifying SwipeViewController Pod to run in a ContainerView -

Image
so im using pod 'swipeviewcontroller' ( https://github.com/fortmarek/swipeviewcontroller ) gives me effect want problem runs main navigation controller , want work in container view because want use social app in profile menu twitter "my tweets", "likes", "repost"... so example need this... https://camo.githubusercontent.com/f4eb2a8ba0a11e672d02a1ef600e62b5272a7843/687474703a2f2f696d6775722e636f6d2f5344496b6634622e676966 to work in here: so explanation, make pod work need add line of code appdelegate let pagecontroller = uipageviewcontroller(transitionstyle: .scroll, navigationorientation: .horizontal, options: nil) let navigationcontroller = yourviewcontrollername(rootviewcontroller: pagecontroller) self.window?.rootviewcontroller = navigationcontroller self.window?.makekeyandvisible() wich creates new window swipecontroller, need way make work in view controller. i did similar last night using tutorial here: https://co

vue.js - VueJS use v-for variable as attribute value -

i have iterative loop using v-for on array of objects renders html li item <li class="block" v-for="(section, key) in sectiondetails"> <a href="#" tabindex="{{ key }}">item {{ key }}</a> </li> the problem here key in tabindex attribute not being rendered, being rendered {{ key }} . how can value of key used tabindex ? i've tried, :tabindex gives me javascript error. interpolation within attributes not valid in vue v2. you need bind tabindex attribute key so: <a href="#" :tabindex="key">item {{ key }}</a> here's working fiddle.

c - Difference between MPI_Wtime and actual wall time -

i implemented mimd genetic algorithm using c , openmpi each process takes care of independent subpopulation (island model). so, population of size 200, 1-process run operates on whole population while 2 processes evolve populations of size 100. so, measuring execution time mpi_wtime , i'm getting expected execution time running on 2-core machine ubuntu. however, disagrees both ubuntu's time command , perception alone: it's noticeable running 2 processes takes longer reason. $time mpirun -n 1 genalg execution time: 0.570039 s (mpi_wtime) real 0m0.618s user 0m0.584s sys 0m0.024s $time mpirun -n 2 genalg execution time: 0.309784 s (mpi_wtime) real 0m1.352s user 0m0.604s sys 0m0.064s for larger population (4000), following: $time mpirun -n 1 genalg execution time: 11.645675 s (mpi_wtime) real 0m11.751s user 0m11.292s sys 0m0.392s $time mpirun -n 2 genalg execution time: 5.872798 s (mpi_wtime) real 0m8.047s user 0m11.472s s

c# - DevExpress TabbedDocumentUIService.DocumentPanelStyle -> CloseCommand Property doesn't work after binding -

at below code don't know why close command not work after binding although work via button command <setter property="closecommand" value="bindingpath=content.datacontext.closedocumentcommand, relativesource=relativesource self}}" /> full code docklayoutmanager <dxdo:docklayoutmanager allowcustomization="true"> <dxdo:layoutgroup orientation="horizontal" allowminimize="false"> <dxmvvm:interaction.behaviors> <dxdo:tabbeddocumentuiservice documentgroup="{binding elementname=documnetgroup}"> <dxdo:tabbeddocumentuiservice.documentpanelstyle> <style targettype="dxdo:documentpanel"> <setter property="caption" value="{bindin

python - Passing modified list to each node of binary tree -

i writing function grow tree: def collect_append(collect,split): collect.append(split) return collect def tree(string,passwords,collect): #collect list , passwords list matching_list = [] match = 0 if len(string)==0: print(collect) return 0 j in passwords: in range(min(len(j),len(string))): if string[i]!=j[i]: break else : matching_list.append(j) match = match + 1 if match == 0: return 1 else: split in matching_list: x =tree(string.strip(split),passwords,collect_append(collect,split)) return x my question is, each split in matching_list(say two), want add different strings existing list @ point (i.e. want 2 versions of list). in case collect_append function use modifying list in first iteration of for loop , using same further iterations. want modify collect list parameter , without permanently changing it. there way this? i see 2 serious errors in code. first, else clause never executed: for j in passwords

reporting services - SSRS displays bad space in right-aligned cells when doing word wrap -

i have ssrs report in dynamics ax 2012 in languages particular header no longer fits column width. no problem right? word wrap take care of that... ssrs being silly , displays header this: | hello | | world| how can make ssrs display cell sensibly? | hello| | world| keep in mind has work several texts in several languages number of words , order can change...

java - Call method when Key pressed -

i working opencv , video capture want call method takes frame based on key press. not sure doing wrong when run program when press space key image isn't being captured. here code: public class videocap implements keylistener{ getcontours takeframe = new getcontours(); static{ system.loadlibrary(core.native_library_name); } videocapture cap; mat2image mat2img = new mat2image(); mat copy = new mat(); videocap(){ cap = new videocapture(); cap.open(0); } int frames = 0; /*int savedcount = 0; //keep track of saved frames string[] photos = {"first.png","second.png","third.png","forth.png", "fifth.png","sixth.png","seventh.png","eigth.png","ninth.png"}; */ boolean captured = false; bufferedimage getoneframe() { frames++; cap.read(mat2img.mat); mat2img.mat = takeframe.captureframe(mat2img.mat); if(captured == true){ mat2img.mat = takeframe.captureframe

ADS SQL- Aggregate functions and subqueries -

currently using advantage sql database , wanting produce "summary" report. lets have people referred in month , either started on programme or didn't. i query return total number of customers referred month column stating how many of these started us. below gives me last column want (a count how many started). "started" field in trainee table. select f.name, cast(year(j.refdate) sql_varchar(4)) + '-' + cast(month(j.refdate) sql_char(2)), count(t.ident) trainee t join pcfndorg f on f.fundorg = t.fundorg join pcptwepi j on j.ident = t.ident j.ponum not null group f.name, cast(year(j.refdate) sql_varchar(4)) + '-' + cast(month(j.refdate) sql_char(2))

Grails - Open MySQL and Apache Server from Project without Xampp\Wamp -

Image
i building grails project uses mysql manipulating database entries , execute crud examples. for mysql server active, use xampp control panel , must have apache , mysql opened in xampp control panel in order establish connection between grails , mysql database. the grails project starts tomcat server everytime run project, , dont know how can achieve apache , mysql, wont have use xampp panel every time. when war created, should able create connection within project, without need of server panel xampp or wamp. i find way start apache , mysql server inside grails project. ideas?

php - How can I validate json data in laravel? -

my code validate data : public function register(request $request) { //echo '<pre>';print_r($request->all());echo '</pre>';die(); $this->validate($request, [ 'email'=>'required', 'password'=>'required', 'data_cache.datacache.id'=>'required|numeric' 'data_cache.datacache.quantity'=>'required|numeric' ]); } the result of echo '<pre>';print_r($request->all());echo '</pre>';die(); : array ( [data_cache] => {"datacache":{"id":112,"quantity":1,"information":"stamford bridge","request_date":"15-08-2017 02:30:00"},"expired":"2017-08-14t16:30:26.272z"} [email] => chelsea@gmail.com [password] => 87654321 ) the data_cache json data on view blade, add display message validation : @if ($erro

git submodule update vs git submodule sync -

the git documentation doesn't make @ clear difference between git submodule update , git submodule sync is. i'm not finding out on web. can me out difference here? update update registered submodules match superproject expects cloning missing submodules , updating working tree of submodules. "updating" can done in several ways depending on command line options , value of submodule.<name>.update configuration variable. - sync synchronizes submodules' remote url configuration setting value specified in .gitmodules. affect submodules have url entry in .git/config (that case when initialized or freshly added). useful when submodule urls change upstream , need update local repositories accordingly. for reference, i'm using git client version 2.11.0 update doing git pull in each submodule (except without branch, since main repo specifies commit directly

java - Can't access functions in another class -

****edit** saying call functiontesttest.numbercheck(usernumber); i have tried numerous times before posting on here didnt work. people downvote question cant answer, great... on project im working on couldn't call functions class. been trying fix day. decided throw a few lines of code & try call function class make sure didn't have unnoticed syntax error in main project. can see problem here? returning error: cannot find symbol symbol: class functiontesttest location: class functiontest ... public class functiontest{ public static void main(string[] args){ scanner input = new scanner(system.in); int usernumber = 0; system.out.println("please enter number between 1 - 10"); usernumber = input.nextint(); functiontesttest ft = new functiontesttest(); functiontesttest.numbercheck(usernumber); } } and.. public class functiontesttest{ public static void main(string[] args){ } public static vo

react-native-crypto freezes android app for ~10sec when signing content -

i'm using react-native-jwt generate jwt google pubsub. library uses react-native-crypto inside signing data. that works great in debug mode (when calculations performed in packager), leads app freeze in release mode on android device. here line causes freeze: crypto.createsign(method).update(input).sign(key, 'base64'); where crypto react-native-crypto , method rsa-sha256 . any thoughts cause of problem?

java - Copy JTextArea as "text/html" DataFlavor -

i have jtextarea , using highlighter apply syntax highlighting of text per sscce below: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; public class sscce extends jframe { public sscce() { final jtextarea amain = new jtextarea(); amain.setfont(new font("consolas", font.plain, 11)); amain.setmargin(new insets(5, 5, 5, 5)); amain.seteditable(false); add(amain); amain.settext("the quick brown fox jumped on lazy dog."); highlighter h = amain.gethighlighter(); try { h.addhighlight(10, 15, new defaulthighlighter.defaulthighlightpainter(new color(0xffc800))); } catch (badlocationexception e) { e.printstacktrace(); } amain.getactionmap().put("copy", new abstractaction() { public void actionperformed(actionevent e) { amain.copy(); } }); amain.getinputmap().put(keystroke.getkeystroke(keyevent.vk_c, toolkit.getdefaulttool

javascript - How does Vue.js select `v-on:click` selector? -

i'm trying replicate vue.js learning purposes. in basic terms can this: <button v-on-click="reversemessage">reverse message</button> var element = document.queryselectorall('[v-on-click]')[0] but, i'm interested know how select v-on:click . when try document.queryselectorall('[v-on:click]') error: uncaught domexception: failed execute 'queryselectorall' on 'document': '[v-on:click]' not valid selector. looking @ repository on github vue , looks first of attributes element. test regex const onre = /^@|^v-on:/ against each attribute, , if matches, remove v-on: or @ prefix attribute name (via name.replace(onre, '') ) leaving name of event handle. handle event. here's simplified example of method: const vonreg = /^@|^v-on:/; let attributes = document.getelementbyid("foo").attributes; let names = []; (let = 0; < attributes.length; i++) { names.push(

reactjs - Using react-snapshot with redux-persist rehydration -

static markup not being generated react-snapshot when use redux-persist . my main app container not render until redux store rehydrated redux-persist. so: render () { if (!this.state.rehydrated) { return <loading /> } return ( <div> <app /> </div> ) } } how can generate html markup post using react-snapshot after redux-persist re-hydration.

In android the first fragment is not working properly -

i have 2 fragments, first fragment calling methods app starts , second fragment's visibility off when user focusing on second fragment methods of second fragment getting called. if user comes first fragment , there change in data in first fragment, methods first fragment not called , hence change not reflected. how solve problem? the 2 fragments code are:` public class tab1fragment extends fragment { private static final string tag = "tab1fragment"; context c; string user_name,password; materialsearchview materialsearchview; string url = null; recyclerview rv1; tablelayout tablayout; @nullable @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container, @nullable bundle savedinstancestate) { view view = inflater.inflate(r.layout.tab1_fragment,container,false); tablayout=(tablelayout) view.findviewbyid(r.id.tablelayout); final tablelayout tablayout1=(tablelayout)view.findviewbyid(r.id.tablelayout1); final tablelayo

python - Weird Error in OpenCV -

i'm writing program in python using opencv detects edges (canny edge detector) footage webcam records. i'm using 2 track-bars in order control threshold values (in order understand how these values change output of edge detector). the code wrote following: import cv2 import numpy np def nothing(x): pass img = np.zeros((300,512,3), np.uint8) cv2.namedwindow('cannyedge') cv2.createtrackbar("minval", "cannyedge", 0,100, nothing) cv2.createtrackbar("maxval", "cannyedge", 100,200,nothing) cap = cv2.videocapture(0) while(true): minval = cv2.gettrackbarpos("minval", "cannyedge") maxval = cv2.gettrackbarpos("maxval", "cannyedge") #capture frame frame ret, frame = cap.read() cv2.imshow('frame', frame) edge = cv2.canny(frame,minval,maxval) #display resulting frame cv2.imshow('frame', edge) if cv2.waitkey(1) & 0xff == ord(

python - "Least Astonishment" and the Mutable Default Argument -

anyone tinkering python long enough has been bitten (or torn pieces) following issue: def foo(a=[]): a.append(5) return python novices expect function return list 1 element: [5] . result instead different, , astonishing (for novice): >>> foo() [5] >>> foo() [5, 5] >>> foo() [5, 5, 5] >>> foo() [5, 5, 5, 5] >>> foo() a manager of mine once had first encounter feature, , called "a dramatic design flaw" of language. replied behavior had underlying explanation, , indeed puzzling , unexpected if don't understand internals. however, not able answer (to myself) following question: reason binding default argument @ function definition, , not @ function execution? doubt experienced behavior has practical use (who used static variables in c, without breeding bugs?) edit : baczek made interesting example. of comments , utaal's in particular, elaborated further: >>> def a(): ... print("a exec

python - Cannot write to shared MPI file with mpi4py -

i tried make file handler uses shared file mpi4py logging module. can't make write. program: from mpi4py import mpi import io class mpilogfile(object): def __init__(self, comm, filename, mode): self.file_handle = mpi.file.open(comm, filename, mode) self.file_handle.set_atomicity(true) self.buffer = io.stringio() def write(self, msg): print("msg type:", type(msg)) self.buffer.write(msg) self.file_handle.write_shared(self.buffer) def close(self): self.file_handle.sync() self.file_handle.close() comm = mpi.comm_world logfile = mpilogfile( comm, "test.log", mpi.mode_wronly | mpi.mode_create | mpi.mode_append ) logfile.write("hello") error: traceback (most recent call last): file "test_mpi.py", line 21, in <module> logfile.write("hello") file "test_mpi.py", line 13, in write self.file_handle.write_shared(self

android - output of my json response is displaying last item in the database -

i trying display content of database in tablelayout, have fetch data database, , set displayed in android app, when data displays, overwrite data fetch earlier , show last item. this except form code think got code wrong @override protected void onpostexecute(string result) { /* textview textview= (textview)findviewbyid(r.id.textview); textview.settext(result);*/ json_string = result; try { jsonobject = new jsonobject(json_string); jsonarray = jsonobject.getjsonarray("server_response"); int count = 0; string id, inv_id, refnumber, description, details, qty, unit_price, amount; double subtotal = 00.00; int sn = 1; double damount; while (count < jsonarray.length()) { jsonobject jo = jsonarray.getjsonobject(count); description = jo.getstring("description"); qty = jo.

c# - MVC Razor view: Minify text with three dots and show full text with tooltip -

i have following code display dots @ end of string if longer limit. want display tooltip full text on hover. not sure how implement razor view element. @(item.data.title.length > 10 ? item.data.title.substring(0, 10) + "..." : item.data.title) you can implement tooltip via jquery , bootstrap following. jsfiddle example : https://jsfiddle.net/z4upto60/ cshtml: <div> <a data-toggle="tooltip" title="@item.data.title"> @(item.data.title.length > 10 ? item.data.title.substring(0, 10) + "..." : item.data.title) </a> </div> jquery: if('@item.data.title.length' > 10) { $('a[data-toggle="tooltip"]').tooltip({ animated: 'fade', placement: 'bottom', }); }

Could not resolve library project after upgrade to Android 3.0 beta 2 -

i trying upgrade latest beta2 , encounter following issues app , lib modules. in app build.gradle have 2 flavors flavordimensions "default" productflavors { stage { applicationid "com.mycompany.hello.stage" resvalue "string", "app_name", "stage" } production { applicationid "com.mycompany.hello.stage.production" resvalue "string", "app_name", "live" } } and specify app talk specific type of lib following: stagecompile project(path: ':lib', configuration: 'debug') productioncompile project(path: ':lib', configuration: 'release') lib build.gradle file have build types , no flavor block publishnondefault true buildtypes { debug { versionnamesuffix ".debug" } release { versionnamesuffix ".

python - How does [...,::-1] work in slice notation? -

opencv uses bgr encoding, , img[...,::-1] swaps red , blue axes of img when image needs in more common rgb. i've been using several months still don't understand how works. the slice operator works 3 params. start(inclusive), end(exclusive) , step. if start not specified gets start of array, same end last element. if step not specified default 1. this way, if [1, 2, 3, 4][0:2] return [1, 2] if [1, 2, 3, 4][1:] return [2, 3, 4] if [1, 2, 3, 4][1::2] return [2, 4] for negative indexes, means iterate backwards [1, 2, 3, 4][::-1] says, starting element until last element iterate list backwards 1 element @ time, returning [4, 3, 2, 1] . as question not entirely clear hope clears functioning , make answer.

python - How Can I Access The Primary Key (from the database) In A Template? -

in project, want display category page, lists of products in specific category. each of listings on category page link visitor specific product. the product view working properly. products accessed url: /prod/999 999 django created record number. for category page, have data , i'm working on template. can access product name, description etc.. in template in creating link product detail page, need product record. unfortunately, doesn't seem passed template. how pass record number "pk" template? here's view code: from get_data.models import shareasale_data, categorysummed class categoryview(generic.listview): model = shareasale_data template_name = 'summary_page/category.html' context_object_name="the_records" paginate_by = 10 def get_queryset(self, **kwargs): # first actual category category db. cat_summed = categorysummed.objects.get(category_url = self.kwargs['s_cat']) # use category previous line fetch

maven - java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create -

error: java.lang.nosuchmethoderror: org.glassfish.hk2.api.servicelocatorfactory.create(ljava/lang/string;lorg/glassfish/hk2/api/servicelocator;lorg/glassfish/hk2/extension/servicelocatorgenerator;lorg/glassfish/hk2/api/servicelocatorfactory$createpolicy;)lorg/glassfish/hk2/api/servicelocator; org.glassfish.jersey.internal.inject.injections._createlocator(injections.java:138) pom.xml <dependency> <groupid>org.glassfish.jersey.containers</groupid> <artifactid>jersey-container-servlet</artifactid> <version>2.22.1</version> </dependency> web.xml <servlet> <servlet-name>jersey-serlvet</servlet-name> <servlet-class> org.glassfish.jersey.servlet.servletcontainer </servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>...</param-value> </init-param> <load-on-sta

c# - How do I properly set up a REST API page with ASP.NET WebPages? -

i'm pretty new server-side programming, decided i'd test of out small website , database. far, working asp.net , cshtml has been absolute breeze, i'm getting actual web api part (making pages can get/post $.ajax real-time results) , i'm having little bit of trouble finding adequate resources on internet. lot of information find extremely vague, not right version of asp.net, or not specific question. here's run-down of website: i plan use website medium game development. game developed on ugc gaming platform, , i'd able connect website in-game use various features such player ranking, messaging boards, developer blog, , developer inbox. have design of website planned out, i'm starting work on actual server-side code. there's database contains profiles , profile information of people play game. if wanted to, example, retrieve list of users play game (for leaderboard), i'd send post request /api/pgiprofiledata.cshtml specific headers , it&

javascript - Downloaded files in Angularjs doesn't saves properly -

Image
my web api method either returns single file or zip file having multiple files. web api implementation. public httpresponsemessage download([fromuri] list<string> filenames) { try { httpresponsemessage result = new httpresponsemessage(httpstatuscode.ok); if (filenames.count > 1) { list<string> filepaths = new list<string>(); memorystream memorystreamoffile = new memorystream(); using (zipfile zip = new zipfile()) { foreach (var filename in filenames) { zip.addfile(httpruntime.appdomainapppath + @"\uploaded\" + filename); } zip.save(memorystreamoffile); memorystreamoffile.seek(0, seekorigin.begin)

postgresql - Calculative cumulative returns using SQL -

i generate user's "monthly_return" between 2 months using code below. how turn "monthly_return" cumulative "linked" return similar stackoverflow question linked below? similar question: running cumulative return in sql i tried: exp(sum(log(1 + cumulative_return) on (order date)) - 1) but error: pg::wrongobjecttype: error: on specified, log not window function nor aggregate function line 3: exp(sum(log(1 + cumulative_return) on (order date)) - 1... ^ : select portfolio_id, exp(sum(log(1 + cumulative_return) on (order date)) - 1) (select date, portfolio_id, (value_cents * 0.01 - cash_flow_cents * 0.01) / (lag(value_cents * 0.01, 1) on ( order portfolio_id, date)) - 1 cumulative_return portfolio_balances portfolio_id = 16 order portfolio_id, date) return_data; the input data be: 1/1/2017: $100 value, $100 cash flow 1/2/2017: $100 value, $0 cash flow 1/3/2017: $100 value, $0 cash flow 1/4/2017: $200 value, $100 cash flow the output be:

recursion - Generating All Subsets of a Set Using Recursive Backtracking (Python) -

i'm trying understand backtracking i'm stuck in problem, here's prompt: given set of distinct integers, return possible subsets. example input: [1,2,3] example output: [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]] here's code: def subsets(nums): res = [] backtrack(res, [], nums, 0) return res def backtrack(res, temp, nums, start): # print(temp) res.append(temp) in range(start, len(nums)): temp.append(nums[i]) backtrack(res, temp, nums, + 1) temp.pop() # backtrack when return res list of empty lists of size 2^(len(nums)) , right size numbers aren't there. printing temp before res.append(temp) shows temp carrying right output. e.g. res = [[], [], [], [], [], [], [], []] print statements: [] [1] [1, 2] [1, 2, 3] [1, 3] [2] [2, 3] [3] why changes not carrying on res list? edit 1: this solution works, what's difference? def subsets(nums): res = [] backtrack(res, [],

loops - Iteratively concatenating and labelling data frames in R -

i'm trying write loop in r reads in list of filenames directory, turns them data frames, , concatenates them 1 large data frame, while adding on identifier each data frame know file generated data came while plotting. far, have loop runs on function appends each data frame empty data frame initialise on, looks this: filenames <- list.files(path="reads/metrics", pattern="*.txt", all.files=t, recursive=false, full.names = true) n= 0 pesto = data.frame(size=character(), fcount= character(),rcount=character(), total = character(), identifier= character()) concat = function(filename, n){ dat = read.table(filename, header=true, na.strings="empty") dat_i = transform(dat, identifier = rep((paste("time", n, sep="")), nrow((dat)))) pesto <<- rbind(dat_i) } (f in filenames) { n = n+1 concat(f, n) } so 2 examples data frames, after being read in: > df1 (from file of time = 1) size fcount rcou