Posts

Showing posts from January, 2013

Asp.net's LoggedInTemplate never displays, only AnonymousTemplate -

i'm using microsoft visual studio 2013 build website. want master page different depending on whether 1 logged in or not. end use <loggedintemplate> , <anonymoustemplate> . unanswered question @ loggedintemplate not displayed , however, latter displayed, regardless of whether or not i'm logged in. code @ master page follows: <asp:loginview id="loginview2" runat="server"> <loggedintemplate> <ul id="loggedin"> <li><asp:loginname id="loginname1" runat="server"/>user page</li> <li><asp:loginstatus id="loginstatus1" runat="server" /><a href="logout.aspx">log out</a></li> </ul> </loggedintemplate> <anonymoustemplate> <ul> <li><a href="registration.aspx">register&

javascript - Access to module data from diff module -

i've node module , need parse data , want share parsed properties in different modules.the first module call responsible pass data , other modules doesn't need send data since store parseddata(in cacheobj) , can use of property,the problem when access 1 module , provide data , try access diff module,the cache object not contain data "store",any idea how right? "use strict"; var parser = require('myparser'), _ = require('lodash'); function myparser(data) { if (!(this instanceof myparser)) return new myparser(data); if (!_.isempty(this.cacheobj)) { this.parseddata = this.cacheobj; } else { this.parseddata = parser.parse(data); this.cacheobj = this.parseddata; } } myparser.prototype = { cacheobj: {}, getpropone: function () { return this.parseddata.propone; }, getproptwo: function () { return this.parseddata.proptwo; } }; module.exports = myparser; the

c - MapViewOfFile offset - how to use it -

developing game ("jogo" in pt), server can host 5 simultaneous games, client access via mapped memory. so here's have: server: #define max_jogos 5 typedef struct{ ... } sjogo; typedef struct{ sjogo * ps; } sglobals; sjogo jogo[max_jogos]; //global sglobals globals[max_jogos]; //global handle hmapfile; //global int _tmain(int argc, lptstr argv[]) { ... hmapfile = createfilemapping(invalid_handle_value, null, page_readwrite, 0, sizeof(sjogo)*max_jogos, szname); //create map games .... } //called when new game created void createview(int index){ //create view 1 game , store pointer //### need apply offset here ### globals.ps[index] = (sjogo * )mapviewoffile(hmapfile, file_map_all_access, 0, 0, sizeof(sjogo); } //called thread on event set void copyjogo(int index){ //use stored pointer update jogo copymemory((pvoid)globals[index].ps, &jogo[index], sizeof(sjogo)); } client: handle hmapfile; //global sjogo * ps; //global

python - Sleep() stops threads -

i trying run script spawns couple of threads using root.after(). sleep() seems lock script. never sees flag being set second root.after(). from time import sleep tkinter import * global flag flag = false def settimer(): global flag while(flag==false): sleep(.1) print('flag set') return def setflag(): global flag flag=true return root=tk() print('start') root.after(1,settimer()) root.after(100,setflag()) print('done') after not start new thread, runs method inside event-loop of tk. while-loop block program. if use after method must non-blocking operations, checking flag. if have background processes, use real threads. notice: must not alter gui inside these threads! import tkinter tk time import sleep threading import thread, event flag = event() def worker(): while not flag.is_set(): sleep(.1) print('flag set') def set_flag(): flag.set() root = tk.tk() print('sta

multithreading - Signal from QThread doesn't get emitted -

i tried following solution laid out in this question , nothing seems happen once signal supposed emitted. this isn't of code, should enough demonstrate i'm trying do: class startqt5(qmainwindow): def __init__(self): super().__init__() [...] self.getfileproperties(path, batch) def getfileproperties(self, path, batch): self.thread = qthread() self.w = probethread(self) self.w.movetothread(self.thread) self.w.finished[dict].connect(self.setprobeoutput) self.thread.started.connect(self.w.run) self.thread.start() @pyqtslot(dict) def setprobeoutput(self, data): print("gotoutput") self.probeoutput = data print(data) class probethread(qobject): finished = pyqtsignal(dict) def __init__(self, parent): super().__init__() self.parent = parent self.output = {} def run(self): self.output = json.loads(sub

swift - Multiple buttons for one action without IB -

in view controller, have 10 buttons. each button has tag , buttons call same action (separate switch (sender.tag), case 0 -> case 9 differentiate button selected). made ib, connected buttons ( @iboutlet ) same @ibaction , good. want programmatically, without ib. so removed @iboutlet 's , @ibaction create new buttons ( let mybutton1 = uibutton() ) , new action ( func newaction(sender: uibutton) ). tried addtarget: same selector new buttons, app crashes. anyone has idea fix please ? this should work: func newaction(sender: uibutton) { ... } ... mybutton1.addtarget(self, action: "newaction:", forcontrolevents: .touchupinside) mybutton2.addtarget(self, action: "newaction:", forcontrolevents: .touchupinside) mybutton3.addtarget(self, action: "newaction:", forcontrolevents: .touchupinside)

PHP Get random element out of array 1, show, and move to array 2 -

i'm trying make page when press button randomly returns element out of array1, saves (so can show on page), , moves array2 element doesn't returned second time, have no idea start. here's source array: $subject = array ( array("title1","comment1"), array("title2","comment2"), array("title3","comment3"), array("title4","comment4"), ); try these codes: <?php shuffle( $array1 ); array_push( $array2 , array_pop($array1) ); ?>

cordova - Meteorjs app - only accessable through appstore/playstore? -

i deployed first ever production application meteor. made client wanted android/iphone application. meteor great this, since saved me hazzle of developing 1 platform @ time, , since i'm working alone. i however, bit.. confused 2 things. what prevents people building own app against server outputting meteor run android-device --mobile-server=https://example.com ? how make phone application accessable through appstores native applications done? for making app accessible through cordova can use neat package meteor add gwendall:iron-router-cordova-only link or wrap routing in incordova block if want code manually. as using mobile server running similar app, (assuming deployed using meteor deploy on .meteor subdomain) have been asked meteor.com password first time deployed on machine. linking resource not made account shows error. note: unless wrap website cordova only, can still view app in browser.

objective c - Custom delegate does not working in iOS -

my custom delegate not work. used custom delegate time it's not working. want pass data ( uislider value after change) uiviewcontroller class subclass of uiview . here code. please me out. - ratingviewcontroller.h - #import <uikit/uikit.h> @class starratingview; //define class, protocol can see class @protocol delegateforslider <nsobject> //define delegate protocol - (void) getvalue:(cgfloat) value; //define delegate method implemented within class @end @interface ratingviewcontroller : uiviewcontroller @property (nonatomic, weak) id <delegateforslider> delegate; //define delegateforslider delegate @property (weak, nonatomic) iboutlet uiview *ratingview; - (ibaction)slidervaluechange:(id)sender; @property (weak, nonatomic) iboutlet uislider *slider; @end ratingviewcontroller.m - #import "ratingviewcontroller.h" #import "starratingview.h" @interface ratingviewcontroller () @end @implementation ratingviewcontroller -

javascript - Controlling the display of things typed in text input (with JS)? -

is there way change display of text input js? for example: input in text field input: "help please" and want displayed directly typed (within text input as: "help ******" so second word changed "*****", has keep value when submitted try utilizing input event , .replace() var text = "", res = ""; document.queryselector("input").oninput = function() { this.value = this.value.replace(/p(?=l)|l(?=e)|e(?=a|s)|a|s|e\s/, function(m) { text += m return "*" }); if (this.value.length > 10 && this.value.slice(-2) === "*e") { text += this.value.slice(-1); this.value = this.value.replace(/e$/, "*"); res = this.value.slice(0, 5).concat(text); // stuff `res` document.queryselector("label").innerhtml = res; text = res = ""; } } <input type="text" /><label><

android - How to change fragments within activity and save state -

i have activity have fragments dynamically added using method below. fragmenttransaction transaction=getsupportfragmentmanager().begintransaction(); fragmenta fragmenta = new fragmenta(); transaction.add(r.id.fragment_container, fragmenta, "fragmenta"); transaction.addtobackstack("fragmenta"); transaction.commit(); fragmenta has textview. have navigation drawer on activity , want switch between fragments (for example fragmenta, fragmentb, , fragmentc) depending on item clicked in navigation drawer. how save state of fragments when changing fragment. i've implemented onsavedinstance(bundle outstate) , onactivitycreated(bundle savedinstancestate) savedinstancestate null. want able save fields of fragmenta when changing fragmentb , changing fragmenta fragmentb. i cannot save state when pressing backstack. seems fields not being saved. what correct ways this? you can use shareprefrences save data in fragmenta , read when called again.

delphi - Query a SQL Database & Edit the found data set -

i know question has been asked before can't manage mine going. set sql have 2 tables in instance using 1 called 'book'. has various columns ones want work called 'wr', 'customer', 'contact', 'model', 'sn', 'status', 'tech', 'wdone' , 'in'. i want enter text editbox called edtwr , want button btnsearch search 'wr' column until has match (all of entries different). once has must write 'customer', 'contact', 'model', 'sn', 'status' labels, lets call them lblcustomer lblcontact lblmodel lblsn & lblstatus . once person has verified that 'wr' want must enter text edit boxes , 1 memo called edttech , mmowdone , edtin , click on btnupdate . should update record. i have 3 ado connections on called dtbout thats adoconnection1, tableout thats adotable , dataout thats adodataset. dataout's command text select * book if helps.

ios - View Controller Loads Twice - How Do I Fix It? -

Image
the problem cause when added new swift class file ios project, decided indecisive , renamed it, deleted it, , created new file. think indecisive renamed few times. the problem now viewcontroller loads twice. can literally see transition happen twice and, during testing, can see viewdidload run twice in console. common fix i know first solution check duplicate segues / segue calls. check document outline see if there's more 1 segue. in case, not segue problem in storyboard or viewcontroller. my uncommon situation i found had same load-twice problem , because of rename: they said renaming did @ root of problem , not easy fix because duplication in xml file. xml file , how edit erase original instance of class? have no idea. so how solve loads-twice issue? want viewcontroller have normal segue! resolved issue! if messed around class's name (or it's file name) , have same "loads twice" issue having, might having hard time solving it

android - How to get the default Equalizer to work with my current Audio Session ID -

i want make users default equalizer work app, can't seem app audio session connect equalizer though passing audio session id etc. here code: intent = new intent(audioeffect.action_display_audio_effect_control_panel); i.putextra(audioeffect.extra_audio_session, musicplayerservice.getmpsessionid()); startactivityforresult(i, 11113); i using code above launch user's default equalizer. @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (resultcode == result_ok) { system.out.println("result_ok"); equalizer equalizer = new equalizer(0,musicplayerservice.getmpsessionid()); equalizer.setenabled(true); return; } } and using code above apply enable , apply it. doing wrong here? have few apps on phone use stock equalizer , work fine. if me out, highly appreciated, thanks.

How to append file extensions .js to typescript? -

in typescript write path without extension - import someclass './some-class'; how make after compilation, these paths contain extension .js ? builds project using gulp-typescript. these paths contain extension .js you don't need to . runtime systems (e.g. node, requirejs, systemjs) automatically assume .js extension if require js file.

ios - Xcode (swift) vs Unity for isometric 2d mobile-apps - Performace, Package Size -

let's assume want develop isometric 2d mobile-game such clash of clans example. main target ios of course android nice, (but not must-have). have decide either program apples xcode (therefore swift language, pretty familiar with), or develop game unity3d (and therefore c# language, pretty familiar with). personally, don't prefer 1 on other. so set-up. as don't have preferences, i'd choose 1 offers benefits 2.5d game me. the questions: is there difference in getting approval app-store if program in swift, or use unity; c#? how big difference of published package-size of app between unity , xcode? does unity-written app run smoothly xcode-written app? i hope me that. if missed points there, feel free criticize me , give me opinions on it. greetings chriz is there difference in getting approval app-store if program in swift, or use unity; c#? no, given general comparison - there should nothing here favoring or disallowing 1 on other.

In swift, why can I set a computed property of a polymorphic variable via optional chaining, but not on an unwrapped optional? -

i ran think strange error in may app. @ bottom of question complete code reproduces seeing in app, here quick demonstration. i create 2 instances of same class, 1 declared optional conforming protocol other optional of concrete class for both can set computed property via option chaining ie: anoptionalinstance?.somecomputedproperty = .... for concrete version can set property unwrapping optional if let aninstance = anoptionalinstance { aninstance.somecomputedproperty = .... } for polymorphic version, error message says can't set property on instance. below complete file reproduces issue seeing. can explain happening here? struct mystruct { var somemember: string } protocol myprotocol { var myvar: mystruct { set } } class mytype: myprotocol { var myvar: mystruct { { return mystruct(somemember: "some string") } set { println(newvalue) } } } class usingclass { var aninstanceofmytype: myprotocol? var a

c++ - Are nested structs the same size as flattened structs? -

#include <iostream> #include <string> struct { int x; }; struct b { a; char y; }; struct c { b b; double z; }; struct d { c c; void *alpha; }; struct e { d d; float beta; }; struct f { int x; char y; double z; void *alpha; float beta; }; int main() { static_assert(sizeof(e) == sizeof(f), "whoops!"); } the above works , gives me same sizes. i'd prefer guarantee true. it? no, need not same. sizes of 2 alternatives need not different either, depend on situation, joachim mentions in comments padding play role. focusing on simpler types, standard-layout (and in example pod, more restrictive): struct { int a; }; // 4 aligned, size 4 struct b { a; char ch; }; // 4 aligned, size 8 struct c { b b; char ch2; }; // 4 aligned, size 12 the reason that, provide right alignment int member in b , compiler (not mandated, compilers aim have natural alignment) injects 3 bytes of padding after ch member. when b used inside c , requires

How to change Wordpress Media Strings with media_view_strings filter -

hi want change strings in media popup found can filter $strings variable width media_view_strings filter , how can ? i want change here wp-includes/media.php file $strings = array( // generic 'url' => __( 'url' ), 'addmedia' => __( 'add media' ), 'search' => __( 'search' ), 'select' => __( 'select' ), 'cancel' => __( 'cancel' ), 'update' => __( 'update' ), 'replace' => __( 'replace' ), 'remove' => __( 'remove' ), 'back' => __( 'back' ), /* translators: would-be plural string used in media manager. if there not word can use in language avoid issues lack of plural support here, turn "selected: %d" translate it. */ 'selected' => __( '%d selected' ), 'draginf

Ruby Fuzzily relation "trigrams" does not exist -

i'm trying use ruby gem fuzzily in rails application, getting error relation "trigrams" not exist i followed instructions https://github.com/mezis/fuzzily here's code trigram.rb class trigram < activerecord::base include url::model include fuzzily::model end url.rb class url < activerecord::base fuzzily_searchable :short_url end add_trigram_mode.rb class addtrigramsmodel < activerecord::migration extend url::migration extend fuzzily::migration trigrams_owner_id_column_type = :uuid end i did rake db:migrate. when execute in rails console, get: url.find_by_fuzzy_short_url('sojdgl') url load (1.4ms) select "urls".* "urls" order "urls"."id" asc limit 100 pg::undefinedtable: error: relation "trigrams" not exist line 5: a.attrelid = '"trigrams"'::regclass ^ : select a.

fix date with JavaScript date() -

i writing blog, , want use time each blog post created time posted. how can use javascript date(), , keep date same after period of time? this done server-side, not client side. javascript date() function done on client/browser. so, if changes time on machine, date() function returns different date. if date wrong on machine, date() function returns wrong date. so, normally, blog posts, dates stored on database. if use wordpress or other cms systems, implementation details covered, so, don't have worry implementation details

Rails 4.2 engine reference column migration fails PG::UndefinedTable: ERROR: in postgresql -

in engine have built , have 3 classes: books, categories , authors. migrations each of classes below. there 1 many relationship between authors , books , between categories , books. engine namespaces each of classes book_store . when using same migrations on postgresql (instead of sqlite) error 1 of classes not exist pg::undefinedtable: error: relation "authors" not exist i'm not sure why error occurring. should namespace in reference well? e.g, this: t.references :author, index: true, foreign_key: true t.references :category, index: true, foreign_key: true to this: t.references :book_store_author, index: true, foreign_key: true t.references :book_store_category, index: true, foreign_key: true this seems not work because there attribute in bookstore::books named book_store_author , book_store_category resulting in bookstore::books.book_store_author not scoped engine properly. is possible need change migration code reflect namespace of engine

batch code reads file names and runs them -

how can batch read file names , run them in loop. i have file file names , run them within batch. file names be. user1 user2 user3 and location be c:\user\desktop\user1.exe c:\user\desktop\user2.exe c:\user\desktop\user3.exe if can done without input file better. the code use without list file is: for %%i in ("%userprofile%\desktop\*.exe") "%%~fi" the code use list file is: for /f "usebackq delims=" %%i in ("file file names.txt") "%userprofile%\desktop\%%i.exe" the path can whatever wanted. here specified desktop folder of current user. for understanding used command for , how works, open command prompt window, execute there following commands , read entirely pages displayed command carefully. for /? you might interested in this answer explaining 4 methods start or call application.

Coloring an image in matlab -

Image
i know how color rectangle created in matlab following code: rectangle = 255*ones(100,100); line1 = zeros(1,70); line2 = zeros(1,40); rectangle(1,1:70) = line1; rectangle(40,1:70) = line1; rectangle(1:40,1) = line2; rectangle(1:40,70) = line2; figure(1) imshow(rectangle); thanks help! i'd suggest looking matlabs built in graphics objects rather making them scratch; save significant time. different method though - not manipulating matrices, using built in objects matlab has specified. can here more info, here's example might relevant: figure; hold all; xlim([0,1]); ylim([0,1]); set(gca,'visible','off'); rectangle('position',[0,0,.5,.5],'facecolor',[1,0,0]); rectangle('position',[.5,.5,.2,.2],'facecolor',[0,0,1],'edgecolor',[0,0,0],'linewidth',4,'linestyle','--'); resulting picture:

entity framework - ASP.NET MVC 5 EF 6 - Just buiness logic classes vs repository and unit of work UPDATED -

over past few months i've been learning mvc5 ef6. it's been love/hate affair, not framework itself, microsoft's online tutorials. not all, majority of tutorials seem end final season of television series. viewers @ home scratching heads trying figure out rest of story, or reason why started watching in first place. anyway, latest stumbling block whether or not should implement repository pattern , unit of work ef6? reason interested in sort of additional layer reduce amount of logic code in controllers. before considering repository, had simple public class in models folder called productservice.cs allowed me pass product model controller perform data manipulation , return view saved. worked flawlessly point of view, calling additional dbcontext in service class seemed incorrect, think. after research online, started implement repository allow me perform same data manipulation in productservice.cs, seemed follow established pattern , allow context passed controlle

javascript - ArangoDB Query for consecutive matches to an array -

in arangodb need search number of consecutive matches array within document integer matrix. example document (all int[5][5]) : nums: 25, 32, 26, 27, 29 01, 22, 15, 17, 99 12, 14, 17, 19, 88 16, 14, 12, 17, 19 02, 08, 09, 18, 19 and in java have int[5] example.: 22, 23, 24, 25, 26 i need return documents in of following true: at least 4 numbers java array match @ least 4 consecutive numbers in matrix row. eg. if matrix row has 22, 23, **29**, 24, 25 not match because no set of 4 numbers array next eachother (it doesn't matter, however, if order matches of array). however, if 22, 26, 23, 24 match because there @ least 4 consecutive numbers array. eg: **22**, 32, 26, 27, 29 **26**, 22, 15, 17, 99 **23**, 14, 17, 19, 88 **24**, 14, 12, 17, 19 02, 08, 09, 18, 19 the same above in matrix column instead of row 20, 01, 02, 03, 08 01,*22,*23*,*25*,*24* 12, 14, 17, 19, 88 16, 14, 12, 17, 19 02, 08, 09, 18, 19 the same last 2 diagonally, instead of in row or co

osx - libgthread not up-to-date when running qemu emulator -

i'm trying run pebble emulator first time 1 of pebble apps, , i'm getting following message: $ pebble install --emulator aplite couldn't launch emulator: dyld: library not loaded: /usr/local/lib/libgthread-2.0.0.dylib referenced from: /users/sarbogast/pebble-dev/pebblesdk-3.3/pebble/common/qemu/qemu-system-arm_darwin_x86_64 reason: incompatible library version: qemu-system-arm_darwin_x86_64 requires version 4401.0.0 or later, libgthread-2.0.0.dylib provides version 4201.0.0 so seems libgthread old. how should upgrade it? this command solved problem: brew update && brew upgrade glib

svn - Revert a specific revision and commit to a new one -

i use tortoise svn client. i need update few files old revision, take changes update creates , commit new revision. wanna revert revision in repository. i know can creating new working copy, using compare-merge tool to apply working copy's changes main one, commiting. i'd rather unique working copy. better if use command svn move make change diretly in subversion. i think trying reverse-merge . for example if latest code state revision 42 , can this: svn merge -r head:42 . and commit in usual way.

SSIS - how to split rows (not columns) -

Image
i have file 100 rows , 20 columns, first 2 rows text , 98 others numbers. there no headers - need combine row1 , row2 have header. i want split row 1 one output , row 2 output combine col1 row1 , row2, combine col2 row1 , row2, combine col3 row1 , row2 etc 20 columns create new headers. after combining, use union write new output file have 99 rows: row 1 text new headers , remaining 99 numbers. does ssis allow me that? know can conditional split column values there way split values based on row or row number? can conditional split work rows? thx i can think of 2 solutions. you create script component of type "source" reading file, way can control row outputs, reading on them. removes use/benefits of connection manager/flat file component, not recommend first choice. you create short script component of type transformation, , alter first few rows (assuming reading proper line order). for #2, how (you can filter out rowindex 0): within script comp

javascript - csv to json for hierarchy tree d3.js -

can me figure out why json file isn't being produced. used small subset of data , worked. when use full set either , empty array, first 2 lines worked, or cyclic error. here first few lines of csv.... parent,name,nsize,lsize,type,level,nfill nr2f2,nnmt,20,3.035224474,black,red,blue nr2f2,cdh6,20,2.497522953,black,red,blue nr2f2,lox,20,2.882828876,black,red,blue nr2f2,afap1l2,20,3.250988851,black,red,blue nr2f2,kcng1,20,1.871023523,black,red,blue nr2f2,thbs2,20,3.556420832,black,red,blue nr2f2,rhou,20,4.892457573,black,red,blue nr2f2,itih5,20,1.579040121,black,red,blue and here script i've copied generate (multilevel) flare.json data format flat json //load csv , copy global variable d3.csv("../jsfiles/nr2f2tbx5hey2json.csv", function(csv_data) { var nested_data = d3.nest() .entries(csv_data); var datamap = {}; var datamap = nested_data.reduce(function(map, node) { map[node.name] = node; return map; }, {}); // create tree array var

android - Do I need to make use of Offline Access in Google Sign-in to retrieve and save user info (name etc) on the backend? -

background: i building android app required user sign-in/register service if wish contribute. the service need basic info of user (name, gender etc) on backend in order register them. the app providing google sign-in well. my understanding: sending id-token backend give me email of user ( check json tokeninfo endpoint returns). in order retreive additional user info on backend irrespective of whether user signed-in or not need offline access permission (more intimidating) user, access- , refresh-token, , info. another option retreive these info on app , send them backend along id-token verification , registration. question(s): can pull additional info on user while user still online (using app) through id-token, on serverside/backend? or should request additional permission offline access in order them? or, mentioned in previous section, pull required info on app-side , send on backend along id-token? if want information once in opinion better additional

The operator > is undefined for the argument type(s) java.util.Random, java.util.Random -

i trying create horse race betting game. i'm having trouble comparing values of horses each other see 1 wins. in if statement try compare value of horse1 value of horse2 , horse3. error of: operator > undefined argument type(s) java.util.random, java.util.random import java.util.scanner; import java.util.random; public class runhorsegame { public static void main(string[] args) { // todo auto-generated method stub //variables string name; float bal; float bet; boolean nextrace; int racechoice; int startrace; random horse1 = new random(100); random horse2 = new random(100); random horse3 = new random(100); random horse4 = new random(100); random horse5 = new random(100); random horse6 = new random(100); random horse7 = new random(100); scanner input = new scanner(system.in); //welcome screen system.out.println("welcome horse racing!"); system.out.println("please enter name:")

ios - Sorting array gives me error -

i have array of structs . in struct have 2 nsdate objects: prop1 , prop2 . i'm trying sort prop1 newest oldest date/time. , want prop2 ordered based on prop1 . (i want vice versa.) struct item { let prop1 : nsdate let prop2 : nsdate } var myitem = [item]() myitem.insert(item(prop1: mydatesecond, prop2: anotherdatesecond), atindex: 0) myitem.insert(item(prop1: mydatethird, prop2: anotherdatethird), atindex: 0) myitem.insert(item(prop1: mydatefirst, prop2: anotherdatefirst), atindex: 0) myitem.sort { $0.prop1 < $1.prop1 } at last line of code, following error: cannot invoke 'sort' argument list of type '((_, _) -> _)' what doing wrong, , how can fix it? when comparing 2 dates have use nsdate method compare : struct item { let prop1 : nsdate let prop2 : nsdate } var myitem = [item]() myitem.insert(item(prop1: mydatesecond, prop2: anotherdatesecond), atindex: 0) myitem.insert(item(prop1: mydatethird, prop2: an

Gradle build is executing infinetly in Android studio -

Image
i installed android studio 1.3.2.but android studio gradle build running infinitely. followed steps setting gradle build offline, , http proxy in android studio no proxy. followed link stack overflow link android studio gradle as seen in picture executing infinitely . suggestions required. couldn't able work android apps. help appreciated. thank you. you should reinstall android studio. if you're using windows. go users -> [your username] -> delete folder .gradle , .androidstudio1.3 -> run androidstudio , androidstudio automatically re-config , download required

jodatime - Joda DateTime output unexpected difference from gmt -

my code: val pattern = "mm-dd-yy" val t = datetime.parse("07-01-86", datetimeformat.forpattern(pattern)).todatetime(datetimezone.forid("gmt")) val z = t.getmillis.asinstanceof[long] println("ms= "+z) // expected output: 520560000000 actual output: 520578000000 several online gmt date converters give different millis output datetime. know why? in solution local time zone implicitly used when parsing date time. should use val t = datetime.parse("07-01-86", datetimeformat.forpattern(pattern).withzoneutc()) to force datetime created in utc zone. then, millis 520560000000 . no need execute todatetime(datetimezone) on more. otherwise, construction val t = datetime.parse("07-01-86", datetimeformat.forpattern(pattern)).todatetime(datetimezone.forid("gmt")) the datetime first created in local tz (ie. midnight of 07-01-86 in your tz) , "cast" utc, preserving timestamp (ie. s

jquery javascript set values as float before adding -

Image
my app has textbox on webpage value looked , added or subtracted value. it seems subtract well, when adding, interprets value in textbox text, , adds on other float text well: here's source code of thing changing: $('#mymoney').val($('#mymoney').val() + $prevevent.close); //...or when subtracting:...// $('#mymoney').val($('#mymoney').val() - $prevevent.close); how tell mymoney interpreted float instead of string? this because .val() reading value string , concatinating. can parse integer parseint() : $('#mymoney').val( parseint($('#mymoney').val()) + $prevevent.close); for float values use parsefloat() : $('#mymoney').val( parsefloat($('#mymoney').val()) + $prevevent.close);

ios8 - swift label only border left -

Image
good morning together, i have tableview this: example: in cell 1 have got red text label on right side. left include image grey line. with code can set complete green border: cell.label.layer.borderwidth = 0.5 cell.label.layer.bordercolor = uicolor.greencolor().cgcolor can set border on left side text label? use swift ios8 - so, need swift solution here extension can add project: extension calayer { func addborder(edge: uirectedge, color: uicolor, thickness: cgfloat) { var border = calayer() switch edge { case uirectedge.top: border.frame = cgrectmake(0, 0, cgrectgetheight(self.frame), thickness) break case uirectedge.bottom: border.frame = cgrectmake(0, cgrectgetheight(self.frame) - thickness, uiscreen.mainscreen().bounds.width, thickness) break case uirectedge.left: border.frame = cgrectmake(0, 0, thickness, cgrectgetheight(self.frame))

android - How to prevent reverse engineering apk to get server login? -

i'm trying find way make android app secure before releasing it. i'm using https/ssl server communication, hidden password protected directories on server app talks to. in directories app interfaces php scripts handle communication server data. biggest vulnerability see use of literal strings in apk file access server password protected directories php scripts are. these literal strings detected binary inspection or possibly attaching debugger. i've read far it's not possible obfuscate literal string. my question is, how can prevent discovery of passwords hidden directories operating php scripts are? alternately, other approach should taking keep server logins secure , reduce chance of server attacks? i think best approach verify app's signing certificate @ run time. don't need hard-code credentials in app. facebook sdk using it. please @ following. https://www.airpair.com/android/posts/adding-tampering-detection-to-your-android-app https://

rails devise separate form login for different roles -

i have 2 role: admin user i want user each role can login using own form, eg: user admin role can login using url : /admin i can't find documentation this. there solution?. thanks you may want take @ article "customize devise support multitenancy authentication" http://climber2002.github.io/blog/2015/03/29/customize-devise-to-support-subdomain-authentication/

php - 404 error due to .htaccess -

i copied our live project sub directory. when trying run it, it's showing 404 error. did required changes in .htaccess file, still showing /publish/index.php page not found. i checked file , folder exist , have 755 permissions. don't know why showing 404 error. here .htaccess file code. rewriteengine on rewritebase /var/www/site/serp/httpdocs/ rewriterule ^robots.txt /robots-development.txt rewriterule ^robots.txt /robots-development.txt rewriterule ^index.htm([^/]+)/$ /publish/index.php?lang_value=$1 [nc] rewriterule ^index.php$ /publish/index.php [nc] rewriterule ^index.htm$ /publish/index.php [nc] note:- cant restart apache server. can't add in apache conf files. your rewritebase seems wrong should relative path documentroot : rewriteengine on rewriterule ^robots\.txt$ robots-development.txt [l,nc] rewriterule ^index\.htm([^/]+)/$ publish/index.php?lang_value=$1 [nc,l,qsa] rewriterule ^index\.php$ publish/index.php [nc,l]

How to merge a branch into another branch in Git while maintaing the old lines? -

when use merge command, conflicting lines marked , can go , choose master or merged version editing file in editor , 'git add '. what want merge , have comment (similar comment when 2 files conflict), this: <<<<<<< head old line in old file in master branch ======= new line in merged branch >>>>>>> i want above comment if there no conflict. helps me manually start editing , decide merged , discarded. basically need have control on merge line line after merged branch. i need have control on merge line line after merged branch. you try , have control during merge, not after. after, is diff , in order check has been merged. (that op ehsan mentions in comments : i solved problem merging first , using diff tool see changes against older version ) if there conflicts, have opportunity decide merged (merge markers) but if there no conflicts, "comments" result of merge (the line added/

java - Thrift Async Client will not stop -

i wonder why without code remarked 1 , result not null , application keeps running , never stop, , code remarked 2 doesn't print expected result. but code remarked 1 , application finishes when result not null ,and prints code remarked 2 . asyncmethodcallback private object response=null; public object getresponse() { return response; } @override public void oncomplete(object response) { this.response=response; } @override public void onerror(exception exception) { exception.printstacktrace(); } async server public static void main(string[] args) { try { tnonblockingserversocket serversocket=new tnonblockingserversocket(10005); hello.processor<hello.iface> processor=new hello.processor<>(new helloserviceimpl()); tnonblockingserver.args serverargs=new tnonblockingserver.args(serversocket); tprotocolfactory factory=new tbinaryprotocol.factory(); serverargs.transportfactory(new tframedtransport.facto

How to get the outlook calendar dynamically in android application -

i developing android application based on business users,hence have synchronize user outlook calendar application calendar.hence how can function,is there link refer,or there sdk available synchronize. please me,thanks in advance. take @ outlook sdk android: https://github.com/officedev/outlook-sdk-android

How to create files to a specific folder in android application? -

in application, want create text file in cache folder , first create folder in cache directory. file mydir = new file(getcachedir(), "mysecretfolder"); mydir.mkdir(); then want create text file in created folder using following code doesn't seem make there. instead, code below creates text file in "files" folder in same directory "cache" folder. fileoutputstream fout = null; try { fout = openfileoutput("secret.txt",mode_private); } catch (filenotfoundexception e) { e.printstacktrace(); } string str = "data"; try { fout.write(str.getbytes()); } catch (ioexception e) { e.printstacktrace(); } try { fout.close(); } catch (ioexception e) { e.printstacktrace(); } so question is, how designate "mysecretfolder&q

linux - Low priority FIFO process running along with High priority FIFO process -

i'm working on linux kernel , required change process' scheduling policy fifo. changed processes' default scheduling policy fifo through source code. policy's actual behavior says higher priority (99) process won't preempt, lower priority (1) processes running along it. after research, i've changed sysctl_sched_rt_runtime -1, still high priority processes getting preempted. can tell me way run 1 fifo process @ time , disabling lower priority fifo process preempt higher priority fifo process. need increase cpu usage of user process manually ? or related cgroups or prevention in kernel need bypass? please !! ubuntu version - 16.04 lts kernel- 4.9.y

php - Warning: mysql_num_rows() -

this question has answer here: mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 33 answers what wrong in code .... when run show message ... warning: mysql_num_rows() expects parameter 1 resource, boolean given in $startindex = 1 ; $finalindex = 3; $select_order = "select orders.orderid,orders.orederdate,customer.firstname,customer.lastname,orders.shippingaddress,shopping_cart.grandtotal,orders.status orders " . "inner join customer on orders.customerid = customer.customerid" . "inner join shopping_cart on shopping_cart.orderid = orders.orderid limit $startindex,$finalindex"; $result = mysql_query($select_order); $jsonorder = array(); if (mysql_num_rows($result) > 0) { // output data of each row