Posts

Showing posts from March, 2010

r - Making a list of zeros and ones from a large list -

i have large list looks this: 1 2 3 3 and need create list looks this: |------|------|------|------| | 1 | 1 | 0 | 0 | |------|------|------|------| | 2 | 0 | 1 | 0 | |------|------|------|------| | 3 | 0 | 0 | 1 | |------|------|------|------| | 3 | 0 | 0 | 1 | |------|------|------|------| i have tried using loops, , method detailed here: create mutually exclusive dummy variables categorical variable in r but because dataset large, run memory constraints. am thinking of using split, apply, combine technique, not able desired result. help appreciated! here ways: 1) outer gives matrix result: x <- c(1, 2, 3, 3) outer(x, unique(x), "==") + 0 giving: [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 [4,] 0 0 1 2) model.matrix gives matrix result. fx <- factor(x) model.matrix(~ fx + 0) giving: fx1 fx2 fx3 1 1 0 0 2 ...

html - Pure CSS accordion not working within CSS tabs -

i have pure css accordion using checkbox input+label trick. source code can found here: accordion: https://codepen.io/raubaca/pen/pzzpve tabs: https://css-tricks.com/css3-tabs/ accordion works outside of tabs. challenge making accordion work within tabs, not expanding , contracting. adjusted position, z-index, height, etc.. have had no success. how can make accordion work inside tabs? https://jsfiddle.net/lance_bitner/z5odxw88/ .tab > input:checked ~ .tab-content { max-height: 100%; } .tab > label::after { position: absolute; left: -20px; top: -9px; display: block; width: 3em; height: 3em; line-height: 3em; text-align: center; -webkit-transition: .35s; -o-transition: .35s; transition: .35s; } .tab > input[type=checkbox] + label::after { content: " + "; font-size: 18px; font-weight: 900; } .tab > input[type=radio] + label::after { content: " \25bc "; } .tab > input[type=checkbox]:checked + label::after { transform...

Why is C++ behaving weirdly when I add leading 0's to an int? -

why cout << 0110 << endl; printing out 72? i didnt' think adding leading 0's int make difference, shouldn't '0110' same '110'? note 0110 octal-literal : octal-literal digit 0 (0) followed 0 or more octal digits (0, 1, 2, 3, 4, 5, 6, 7) that's why you're getting 72 when printing out it, it's not same 110 .

shell - how to check ssh exit command executed? -

i want check exit command executed success in ssh session. my first attempt using command exit && echo $? || echo $? .the echo $? || echo $? ,it should print 0 if exit successful. problem echo never execute if exit execute success because connection disconnected , later command lost. my second attempt splitting command 2 command, this: $ exit $ echo $? echo $? should 0 if exit execute successful. problem echo $? maybe swallowed because send arrived remote ssh host before exit executed. so, how ensure exit executed @ remote host before send next command? update using stage execute shell command @ program language , send message ssh pipe stream.so, don't know exit command executed time.if exit command not completed, follow commands swallowed because send exiting host. why i'm care exit command executed. if main concern knowing local machine, define variable earlier in script known on local machine before ssh. after exiting test e...

unit testing - Mock patch decorators python -

hi mock decorator since don't want calling/executing function. can't seem find solution below code # decorator located in project # located in custom.mydecorators.decorator_file.custom_decorator base = declarative_base() def custom_decorator(func): @wraps(func) def wrapper(*args, **kwargs): print("this message still printed when try patch function") try: #code here my_var = coolclass() retval = func(*args, **kwargs) except exception e: #rollback code here raise e return retval return wrapper now i'm trying patch using code patch('custom.mydecorators.decorator_file.custom_decorator', lambda x: x).start() class testmockdecoratorscallingclass(unittest.testcase): def test_should_return_success_if_decorators_are_mocked(self): # code here my decorators work in non unittest file. if mock decorator fails saying local variable 'my_var' referenced before assignment note: my_...

Running Custom Android ROM on Emulator -

i built custom rom based out of aosp (7.0 nexus 6) , use rom sdk emulator. lunch combo build 'aosp_x86_64-eng' believe should work on sdk emulator. however, don't see option in avd manager specify custom system image. allows me use listed roms google. i tried copying custom rom's system.img on stock nexus 6 avd emulator doesn't launch after that. note emulator gets generated during build works fine. build happens on server, , want use generated rom on development machine sdk's avd manager. found out can done using following steps. create compatible avd using stock avd system images. in case, used system image nexus 6 running nougat on x86_64 abi. go ~/.android/avd folder , locate folder avd created above (ex. ~/.android/avd/test.avd). copy custom system.img file folder. run emulator! when tried first time didn't work me because have chosen wrong base image (nougat x86 instead of x86_64). catch make sure stock system image compatibl...

coding style - Why 'window.onload' but simply 'document' instead of 'window.document' in conventional JavaScript code? -

in javascript come across, see programmers write window.onload instead of writing onload . but when comes accessing document object, write document instead of window.document . is there specific reason inconsistency in coding convention? the document available in scope, unless it's overwritten, doesn't happen. that means 1 can do var obj = { key : function() { return document.getelementbyid('test'); // still document } } console.log( obj.key() ); <div id="test"></div> this beacuse document in global special variable available, window on other hand, elements have onload function, of time 1 isn't dealing window.onload if writing onload . not that, being property of object, depends on this being window, in global scope. create other scope, , onload other window.onload var obj = { key : function() { onload = function() { // not window.onload cons...

how to auth the JWT in android -

im new in android . have http headers: "authorization": "jwteyjhbgcioijiuzi1niisinr5cci6ikpxvcj9.eyjpzci6mjcsimvtywlsijoiz2xvcmlhnjhaag90bwfpbc5jb20ilcjpyxqioje1mdmwotg3mzesimv4cci6mtuwmzcwmzuzmx0.zm7snotuvhgvxqsewzosixa1jifrrvgzbw0jfnsnwkk" something above saved in message1 the question how auth these values in code having result need i leave code have been testing public class fragmenttab_datospersonales extends fragment { textview txtprueba, txtid; button btnprueba; string url = "http://10.8.0.1:8080/api/jugador/"; requestqueue requestqueue; string url1 = variablesglobales.urlid; public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view = inflater.inflate(r.layout.lyt_fragmenttab_datospersonales, container, false); requestqueue = volley.newrequestqueue(getactivity().getapplicationcontext()); txtpru...

java ee - Preview File in Browser is not working in IntelliJ IDEA 2017.2.1 -

Image
working in intellij idea 2017.2.1 , using glassfish server javaee web application, preview file in browser option not working. not single browser opening display results. have restart glassfish server again , again view changes. i found problem. had servlet mapping code inside web.xml file. after removing code servlet mapping , defining urlpattern inside servlet java class, ide working properly.

javascript - onClick Function "this" Returns Window Object -

i've come across head scratching issue javascript application. if write element this: <li onclick="alert(this.tagname)"></li> i "li." however if this: <li onclick="foo()"></li> where "foo()" is: function foo(){ alert(this.tagname); } i "undefined." i away how "this" supposed work in regards attached functions. but, baffled because "this" not picking element, apparently defaulting "window." can't figure out why happening. does have explanation? that's because aren't passing reference this in javascript function call. this in javascript function doesn't refer same object in onclick example. try instead: <li onclick="foo(this)"></li> function foo(item){ alert(item.tagname); }

vba - which one is faster to lookup value in Excel? -

an article said using vlookup quite slow , can use double vlookup increase speed. single vlookup (unsorted data fine) =vlookup(look_value,a1:b100,2,false) double vlookup (need sorted data) =if(vlookup(look_value,a1:a100,1,true)=look_value,vlookup(look_value,a1:b100,2,true),na()) the article said having 10,000 rows, double-vlookup 28 times faster , 3600 times faster if there 1,000,000 rows. i not sure conclusion above. and confused 1 of below functions faster? double-vlookup(sorted data) single-vlookup lookup(sorted data) combine index , match

ios - App downgrading automatically , distributed outside of appStore for Diawi from Xcode8.2.1? -

i stuck in weird scenario , created build in xcode 8.2.1 selecting distribute outside appstore uploaded ipa file diawi.com . using link installed build in device running when opened app again in old version of same app. don't understand how happened, removed old version of app device before installing new version. don't think certificates or provisioning profile. please me if has encountered same issue this. thank you. try changing build version while creating build , make sure export ipa using correct build archive utility.and sign out diawi , create link.so none of old builds interfered.

twitter - all the tweets in a specific period of time with Java -

this question has answer here: is possible more 100 tweets? 6 answers how retrieve more 100 results using twitter4j 4 answers i'm trying extract , save tweets in specific period of time specific hashtag #obama twitter in java using twitter4j . time = 2017-01-01 2017-03-01 hashtag = #obama i need of tweets in period of time gives me 100 tweets. query.setuntil("2017-03-01"); doesn't work public class main5 { private final static string consumerkey = "********************"; private final static string consumersecret = "****************************************"; private final static string accesstoken = "****************************************"; private final static string accesstokensecret = ...

tensorflow - Best loss function for very small numbers -

what appropriate loss function neural network inwhich outputs include small , (large) numbers? e.g. consider following inputs , outputs: nn_inputs = [-1e-7, -2, 2e3] nn_outputs = [-2e-5, 200] just want show variation of inputs (which cause problem in normalization) , outputs. when use mse loss function ( in tensorflow: loss = tf.reduce_mean(tf.squared_difference(nn_outputs, targets) , loss have small value.

JQuery/JavaScript addClass doesn't work -

i have div contains elements. when click on 1 element action occur. during action time want make div colors change black & white , after action reset color. so create simple css3 class : gray { background-color:red; -moz-filter: grayscale(100%); -webkit-filter: grayscale(100%); filter: grayscale(100%); } and in script have 2 functions : function enablewaitstate( ) { $($("#chart")).addclass( "gray"); } function disablewaitstate( ) { $($("#chart")).removeclass( "gray"); } in javascript code write method called when clicking on button: function back() { enablewaitstate( ); // here doing javascript code disablewaitstate( ); } } unfortunately doesn't work. if make ajax call between enablewaitstate() , disablewaitstate(), works! any ideas? you need remve additional $() selector. function enablewaitstate( ) { $("#chart").addclass( "gray"); } functio...

intellij idea - Flutter: how to load file for testing -

file can read directory relative dart script file, var file = new file('./fixture/contacts.json') . however file cannot read flutter test running inside ide. loading resource (it not, since not want bundle test data file in app) not work in test. what way read file in flutter (for both command line test , ide test)? running flutter test fast. testing inside intellij ide ver slow, can set debug breakpoint , step , view variables. both testing useful.

Import book information through API into Google Sheet -

i want put book collection spreadsheet. there way of having columns autofill (e.g. isbn/ dewey decimal info) using api? i have managed things wordnik's api before , wondered if similar thing possible. so if put in title/ author, next cell autofill rest? or whole book's info entering isbn? edit: can access api behind worldcat , webpage: http://classify.oclc.org/classify2/classify?title=outsider&author=camus&maxrecs=1 however, can't seem cell in google sheets coerce 'author' , 'title' of book cleanly.

html - How do I remove the grey background around my picture? -

how remove grey background around picture? here's how page looks right now: http://imgur.com/w52pfhn .header { text-align: center; font-size: 50px; font-family: sans-serif; font-style: bold; color: white; background-color: white; background-image: url("https://dummyimage.com/vga"); padding: 10%; margin: 0%; border: 0%; } body { background-color: grey; } <div class="header"> <h1>hello</h1> </div> by default body has margin, so: body { margin: 0; }

flutter - Viewing a greeting screen for a specific period of time -

Image
i have been trying find information creating widget disappears after period of time. trying create greeting page appears once app runs , disappears after couple of seconds; navigating home page afterwards. what correct direction in order done? i understand how use showdialog buttons, want greetings view first view when app starts, how correctly use showdialog? void main() { runapp( new materialapp( home: new signin(),//how integrate showdialog flow )) } the full code of transition between 'greeting page' , home using pageroutebuilder , navigatorstate.pushreplacement : import 'dart:async'; import 'package:flutter/material.dart'; void main() { runapp(new materialapp( home: new greeting(), )); } class greeting extends statefulwidget { @override _greetingstate createstate() => new _greetingstate(); } class _greetingstate extends state<greeting> { @override initstate() { super.initstate(); new timer(cons...

How to connect a mySQL DB to Vultr - VPS and then to my C# application -

so, made mysql db login screen in c# application. worked pc, since db on system, but, plan give application few people in future, so, wanna know how - 1. put mysql database onto vultr(i'm being specific because couldn't answer) 2. how make connection in c# code db i've looked around , i've found lot of answers local host, nothing this, appreciate , help!

windows - Getting started with C and Visual Studio code: how to compile and start a program? -

i decided learn things start have better , stronger knowledge in computer science, i'm following cs50 course harvard available on edx. started learn c. propose online ide compiling program typing on terminal. clang nameofthefile or clang -o... or also make nameofthefile which think linux commands (tell me if i'm wrong please). have ubuntu on laptop, i'm using windows. use visual studio code web development, , never learned c before. know how can compile , start program visual studio? tried these commands on terminal of visual studio powershell , cmd these not working. also, can tell me if, since use visual studio code on ubuntu, use cmd , powershell integrated terminal? or use ubuntu terminal? commands different compiling c? if can me explaining me step step windows , ubuntu please great, install eclipse cdt. have need on both systems. not use microsoft compiler specific implementation

How print first largest value Selenium with Java -

my code: list<webelement> mylist=driver.findelements(by.xpath("//div[@id='legends']//span[4]")); //to store web elements list list<string> all_elements_text=new arraylist<string>(); for(int i=0;i<mylist.size();i++) { all_elements_text.add(mylist.get(i). gettext()); system.out.println(mylist.get(i).gettext()); } object obj = collections.max(all_elements_text); system.out.println("the highest value :"+ obj); } my output 35.6% 22.6% 15.8% 13.8% 7.4% 4.2% 0.7% highest value :7.4% it's wrong. want print first largest value. you need write custom comparator compareto method of string class perform text based comparison , hence, 7.4 compared higher 35 (because of 7 being higher 3). here's java 8 example, e.g.: list<string> all_elements_text = new arraylist<>(); all_el...

javascript - How to call rest service for responseType = "arraybuffer" using (.net) HttpWebRequest object? -

how can call rest service in .net responsetype = "arraybuffer" . i able response in javascript using below code. var req = new xmlhttprequest(); req.open("get",url, true); req.setrequestheader("accept", "application/json; odata=verbose"); req.onreadystatechange = function () { if (this.readystate === 4) { debugger; this.onreadystatechange = null; if (this.status === 200) { var blob = new blob([this.response], {type: "octet/stream"}); var reader = new window.filereader(); reader.readasdataurl(blob); reader.onloadend = function() { base64data = reader.result; console.log(base64data); } var filename = "sample.pdf"; savebytearray(blob, filename); } } }; req.responsetype = "arraybuffer"; req.send(); same call want call .net ( httpwebrequest ) application. note:...

c# - InvalidComObjectException when using GeckoWebBrowser -

i using geckowebbrowser geckofx45 extract source of webpage after loaded. when running code once works fine, when run multiple times invalidcomobjectexception is thrown: system.runtime.interopservices.invalidcomobjectexception: 'com object has been separated underlying rcw cannot used.' code: public static async task<string> loaddomsourceasync(string url, cancellationtoken cancellationtoken) { using (var apartment = new messageloopapartment()) return await apartment.run(async () => { using (var wb = new geckowebbrowser()) { var tcs = new taskcompletionsource<string>(); try { wb.documentcompleted += (s, a) => tcs.trysetresult(((geckohtmlhtmlelement)wb.document.documentelement).outerhtml); wb.navigationerror += (s, a) => tcs.trysetexception(new geckonetworkexception()); wb.navigate(url); return await t...

Drop down list in python selenium -

Image
how download drop down list files in python selenium. example https://www.wikipedia.org/ in link contain language select drop down . how select 1 one drop down option , search using python selenium ? i don't understand question , want achieve driver.get('https://www.wikipedia.org/') select = driver.find_element_by_id("searchlanguage") options = select.find_elements_by_tag_name("option") option in options: print(option.text) output: العربية azərbaycanca Български bân-lâm-gú / hō-ló-oē Беларуская (Акадэмічная) català Čeština dansk deutsch eesti Ελληνικά english español esperanto euskara فارسی français galego 한국어 Հայերեն हिन्दी hrvatski bahasa indonesia italiano עברית ქართული latina lietuvių magyar bahasa melayu bahaso minangkabau nederlands 日本語 norsk (bokmål) norsk (nynorsk) Нохчийн oʻzbekcha / Ўзбекча polski português Қазақша / qazaqşa / قازاقشا română Русский simple english sinugboanong binisaya slovenčina slovenščina Српски / sr...

java - I am trying to send sms through my app on internet -

try { // construct post data string data = urlencoder.encode("user", "utf-8") + "=" + urlencoder.encode(user, "utf-8"); data += "&" + urlencoder.encode("pass", "utf-8") + "=" + urlencoder.encode("somne", "utf-8"); data += "&" + urlencoder.encode("sender", "utf-8") + "=" + urlencoder.encode(msisdn, "utf-8"); data += "&" + urlencoder.encode("phone", "utf-8") + "=" + urlencoder.encode(phone, "utf-8"); data += "&" + urlencoder.encode("text", "utf-8") + "=" + urlencoder.encode(msg, "utf-8"); data += "&" + urlencoder.encode("priority", "utf-8") + "=" + urlencoder.encode(priority, "utf-8"); ...

nginx - How to remove all .html from the URL | Nignx -

i'm new nginx, need remove *.html extensions appear in url, e.g. http://mywebsite.com/events.html/beauty-must-haves.html i've tried lots of solutions fix this, not able fix, can kindly me fix this. these no hard coded pages, generates @ runtime following link doesn't fix it. how serve html files in nginx without showing extension in alias setup i need seo friendly e.g. http://mywebsite.com/events/beauty-must-haves thanx in advance. the following code got me looking for, doesn't remove .html extension inside url, removes ending extension: rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent; rewrite ^/(.*)/$ /$1 permanent; try_files $uri/index.html $uri.html $uri/ $uri =404; any please ... ?

How to clear python recursion? -

i'm pretty new python , have few question recursion error: "runtimeerror: maximum recursion depth exceeded". know error in python avoid stack overflow. have made example code here: import sys def print1(): print("1") return print2() def print2(): print("2") return print3() ------------- def print3() - def print7() <- (wrote here save place) ------------- def print8(): print("8") return print9() def print9(): print("9") def main(): sys.setrecursionlimit(11) print sys.getrecursionlimit() print1() if __name__ == "__main__": main() now if have set recursion limit 11, code run, there no errors. output: 11 1 2 3 4 5 6 7 8 9 if set recursion limit 10, there error: 10 1 2 3 4 5 6 7 8 traceback (most recent call last): file "nimetu1.py", line 44, in <module> main() file "nimetu1.py", line 41, in main print1() file "nimetu...

Sharepoint 2013 Rest API call to extract Excel specific cells -

this should pretty straight forward, haven't been able find documentation, unsure if possible, , if - how. i'm calling sharepoint 2013 rest api, excel rest services (excelrest.aspx), fetch values specific cells in excel workbook. i've had success following 2 types of calls: fetch 1 specific cell (e5): http://somesharepointsite.com/testsite/_vti_bin/excelrest.aspx/shared%20documents/excelfile.xlsx/model/ranges ('''front%20page''!e5')?$format=html fetch range (e5-f20): http://somesharepointsite.com/testsite/_vti_bin/excelrest.aspx/shared%20documents/excelfile.xlsx/model/ranges ('''front%20page''!e5|f20')?$format=html however able fetch multiple specific cells e.g: e5, e7, f15, f18. this due how information placed in spreadsheet, isn't convenient automated extration. instead of counting rows/columns find relevant cells when extracting range, easier if cells of relevance indicated directly. i know make bunc...

firmware - binwalk doesn't show anything for its input binary file -

the below image i've received when try use binwalk on binary file of firmware. please guide me why doesn't show me anything. i've tried on other firmware binary file , it's ok. image

java - MessageBodyProviderNotFoundException while running jar from command line -

i using java jersey framework(with maven), , use intellij ide. have encountered runtime exception happens when try run code command line (using maven compile , java -jar ) not when running within intellij, strange. i have java code try make http on remote url , try read returned json lombok pojo : string targeturl = "some valid url"; webtarget webtarget = client.target(targeturl); response response = webtarget.request(mediatype.application_json_type).get(); parseresponse parseresponse = response.readentity(parseresponse.class); i not sure why, when hits last line "readentity()" method, error below: org.glassfish.jersey.message.internal.messagebodyprovidernotfoundexception: messagebodyreader not found media type=text/json; charset=utf-8 this strange, because have jersey-media-json-jackson dependency specified in pom.xml : <dependency> <groupid>org.glassfish.jersey.media</groupid> <artifactid>jersey-media-json...

java - duplicated column while copying data -

hi guys copying data oracle postgresql database.there n issue raised while copying because of duplicated primary keys , want continue copying data , , log duplicated key .here did , issue got in french <?xml version="1.0" encoding="utf-8"?><!doctype etl system "http://scriptella.javaforge.com/dtd/etl.dtd"> <etl> <description> test script pour table article </description> <connection id="in" driver="oracle" url="jdbc:oracle:thin:@localhost:1521:xe" user="iptech" password="iptech" /> <connection id="out" driver="postgresql" url="jdbc:postgresql://localhost:5432/gemodb" user="postgres" password="maher" /> <connection id="janino" driver="janino" /> <connection id="log" driver="text" /> <query conne...

c++ - Why are libraries not found, even though they are clearly on the -L path? -

i have following linking command (sorry it's length, tried leave original possible, except shortening paths): cc cmakefiles/main.dir/main.cpp.o -o main -l/me/libs/cgal/lib -l/me/libs/tbb/tbb-2017_u7/build/linux_intel64_gcc_cc5.3.0_libc2.19_kernel3.12.61_release -rdynamic -lmpfr -lgmp /me/libs/cgal/lib/libcgal_imageio.a /me/libs/cgal/lib/libcgal.a -lboost_thread -lboost_system -lz /me/libs/cgal/lib/libcgal_imageio.a /me/libs/cgal/lib/libcgal.a -lboost_thread -lboost_system -lz -ltbb -ltbbmalloc -wl,-rpath,/me/libs/cgal/lib:/me/libs/tbb/tbb-2017_u7/build/linux_intel64_gcc_cc5.3.0_libc2.19_kernel3.12.61_release it tell me: /usr/bin/ld: cannot find -ltbb /usr/bin/ld: cannot find -ltbbmalloc most relevant problem have -l/me/libs/tbb/tbb-2017_u7/build/linux_intel64_gcc_cc5.3.0_libc2.19_kernel3.12.61_release , -ltbb - ltbbmalloc . in -l directory, there libtbb.so , libtbbmalloc.so . but why libraries not found linker, though exist in directory gi...

TypeError: firebase.storage(...).ref(...).once is not a function during retrive the images from Firebase in AngularJS? -

Image
i have retirive image firebase firebase in angularjs got error? //get images firebase $scope.getimages = function() { firebase.storage().ref('user/image').once('value').then(function(snapshot) { var value = snapshot.val(); }) } <div class="pull-right"> <input type="submit" name="sumbit" value="submit" ng-click="getimages()"> </div>

javascript - Calling OnClientClick from Code behind in Asp.net VB -

i have code : <asp:linkbutton runat="server" id="hl_konfirmasipemesanan" class="button-primary button-shadow" causesvalidation="false" validationgroup="validasidata" onclientclick="return getconfirmation(this);" ></asp:linkbutton> then want call onclientclick="return getconfirmation(this);" in code behind, tried: hl_konfirmasipemesanan.attributes.add("onclientclick", "return getconfirmation(this);") but doesn't work, how can that? you can this: dim script string = "<script>var btn = document.queryselector('.button-primary'); getconfirmation(btn);</script>" clientscript.registerstartupscript(me.gettype(), "click_btn", script)

objective c - iCloud Drive - Read & Write (NSData) -

Image
trying save custom objects nsdata upload icloud drive any direction? tried key-value method, limited 1mb :/ is correct way? if yes, how can read icloud path? +(void)icloudwrite:(nsdata*)data { nsurl* ubiq = [[nsfilemanager defaultmanager]urlforubiquitycontaineridentifier:nil]; nsurl *ubiquitouspackage = [[ubiq urlbyappendingpathcomponent:@"documents"] urlbyappendingpathcomponent:@"icloudhistory.zip"]; mydocument *mydoc = [[mydocument alloc] initwithfileurl:ubiquitouspackage]; mydoc.datacontent = data; [mydoc savetourl:[mydoc fileurl] forsaveoperation:uidocumentsaveforoverwriting completionhandler:^(bool success) { if (success) { nslog(@"synced icloud"); } else nslog(@"syncing failed icloud"); }]; } edited: // 1. file can uploaded icloud container of size (yes should having of space in icloud) lets take example sampledata.zip //...

php - Cordova image upload -

i'm trying find out how upload files php server using cordova plugins shown in url below https://www.youtube.com/watch?v=jc8djihwy_k i know cordova-plugin-intent has functionality receiving image selecting "share via/open with" option , url of file function deviceready() { console.log("device ready"); window.plugins.webintent.geturi(function(url) { if(url !== "") { // url url intent launched document.queryselector("#test").innerhtml = "url "+url; } }); } and cordova-plugin-file-transfer has functionality transfer selected file server. function uploadphoto(imageuri) { var options = new fileuploadoptions(); options.filekey="file"; options.filename=imageuri.substr(imageuri.lastindexof('/')+1); options.mimetype="image/jpeg"; } the problem cordova-plugin-file-transfer have select file via file opener/file dialog, need know how combine cordova-plugin-intent image , send file using cordova-plugin-f...

asp.net mvc - Is there any way to access and change session data of other sessions with InProc sessions? -

i have auth related data stored in session. refresh data logged in @ time data changed in database. (note: logged in user makes changes can different user affected) is there way access , change session data of other sessions inproc sessions?

Query mongoDB find() -

this question has answer here: mongodb query 'or' condition 4 answers how find document either 1 or field matches value? 1 answer i'm new mongodb, want grab "posts" fits createdby or to. router.get('/getpublicprofileposts/:username',(req,res)=>{ if(!req.params.username){ res.json({success:false,message:"no username provided"}); } else{ user.findone({username:req.params.username},(err,user)=>{ if(err){ res.json({success:false,message:'something went wrong '+err}); } else{ if (!user) { res.json({success:false,message:'user not found'}); } else{ post.fi...

python - Importing a custom module from a different directory within the same project -

i'm trying import custom module reason can't work , i'm getting importerror . my directory structure so: myproject - myproject - bin scraper.py - myproject __init__.py custommodule.py - web index.html - venv i'm attempting import custommodule.py scraper.py . ideally without having set environment variables, or using sys.path . this i've tried: import custommodule myproject import custommodule ..myproject import custommodule is possible? taking jean-françois fabre 's comment account, if no solution without sys.path provided, consider using: import sys import os sys.path.append(os.path.join(os.path.dirname(__file__),'..','myproject')) import custommodule

php - Inheritance: how to properly set global vars in OOP architecture without using $GLOBALS -

i'm building mvc framework scratch fun , learning purpose. what i'd have conf file configuration params (host, default language, current language, etc.) , have params available in every script of framework without using $globals. it's couple of month i'm oop so, make simpler, idea has been create class private properties, create protected function env() subclasses can retrieve properties , put class @ top level in hierarchy letting other class extending or other subclasses. class environment { private $full_url = "https://www.example.com"; private $relative_url = "test"; private $default_lang = "en"; private $current_lang; private $admin_area = "admin"; private $user_area = "user"; function __construct() { $this->setcurrentlang(); } private function setcurrentlang() { $this->current_lang = "it"; } protected function...

c++11 - C++ Functor template for class member functions -

there small functor class wrote should able call class member functions hiding static wrapper function , void pointer object. example below not compile due error when setting wrapper function. want class member pointer template argument. know wrong there? i think there problem in static function when calling member function. not know how template syntax. minimal example compiles c++11 enabled gcc. #include <iostream> template<class treturn, class... tparameter> struct functor { treturn (*ptr)(void*, tparameter...); void *object; template<class tobject, class tmemberfunction> static treturn membercaller(void *obj, tparameter... params) { tobject *c = static_cast<tobject*>(obj); return (c->*(tobject::tmemberfunction))(params...); } treturn operator()(tparameter... params) { return ptr(object, params...); } }; class test { public: void func(int a) { std::cout << << std::...

azure - How to use Kubernetes Statefulset to load existing PersistentVolumes? -

it seems of examples of statefulsets show persistentvolumes (pvs) being dynamically created on startup. keeps pvs around after stop statefulste. that's also. that's great, periodically want stop kubernetes cluster , take of nodes offline. it's great way save money. stopping kubernetes delete remaining persistentvolumeclaims (pvcs). @ point, pvs released , reclaimed. can avoided if change pvs reclaimpolicy 'retain' after created. great. but when restart cluster , create statefulset once again, reuse same underlying storage still alive in cloud provider (azure). happen, not need pvs recreated (which i'm willing manually), need individual nodes pair correct pv. instance, once pv hold master mysql database data. other pv hold slave mysql database data. i don't see how possible within statefulset definition in persistentvolumeclaimtemplate. am approaching wrong way? possible? initial startup (no data), use statefulset? should subsequent...

python - Django form fields not loading in template -

i can't seem model form load in template. models.py from django.db import models class event(models.model): name = models.charfield(max_length=60) start_datetime = models.datetimefield() end_datetime = models.datetimefield() description = models.textfield() forms.py from django import forms .models import event class eventform(forms.modelform): class meta: model = event fields = ['name'] views.py from django.shortcuts import render .forms import eventform def index(request): if request.method == 'post': form = eventform(request.post) if form.is_valid(): form.save() else: form = eventform() return render(request, 'index.html') index.html <form method="post" action=""> {% csrf_token %} {{ form.as_p }} </form> <button type="submit">save</button> i can form print console on load when adding print(...

wordpress - Call main theme function with plugin -

we created plugin new template , want hook main theme function , return main plugin function. we tried with: add_filter( "page_template", "test" ); function test( $template ) { if( 'plugin_name.php' == basename( $template ) ) $template = wp_plugin_dir . '/plugin_folder/plugin_name.php'; return $template; } and changed page template in theme functions main function of plugin runs template inside plugin: add_filter( "page_template", "main_plugin_function" ); is page_template right filter change theme template? thanks help! i think should use template_include filter, filter hook executed before wordpress includes predetermined template file. can used override wordpress's default template behavior. for example add_filter( 'template_include', 'portfolio_page_template', 99 ); function portfolio_page_template( $template ) { if ( is_page( 'portfolio' ) ) { ...

parsing - PHP Parse/Syntax Errors; and How to solve them? -

Image
everyone runs syntax errors. experienced programmers make typos. newcomers it's part of learning process. however, it's easy interpret error messages such as: php parse error: syntax error, unexpected '{' in index.php on line 20 the unexpected symbol isn't real culprit. line number gives rough idea start looking. always @ code context . syntax mistake hides in mentioned or in previous code lines . compare code against syntax examples manual. while not every case matches other. yet there general steps solve syntax mistakes . references summarized common pitfalls: unexpected t_string unexpected t_variable unexpected '$varname' (t_variable) unexpected t_constant_encapsed_string unexpected t_encapsed_and_whitespace unexpected $end unexpected t_function … unexpected { unexpected } unexpected ( unexpected ) unexpected [ unexpected ] unexpected t_if unexpected t_foreach unexpected t_for unexpected t_while unexpected t_do ...