Posts

Showing posts from May, 2015

raspberry pi2 - Python 2.7 - Cannot Import GPIOZERO -

i new raspberrypi, debian , python. i have configured raspberry pi 2 model b v1.1 recommendations available many many helpfull websites , people. however, when want start basic project based using gpiozero control buttons , led's not able use the: "from gpiozero import led, button" command. output reports following: > traceback (most recent call last): > file "", line 1, in > file "/usr/lib/python2.7/dist-packages/gpiozero/init.py", line 57, in > .devices import ( > file "/usr/lib/python2.7/dist-packages/gpiozero/devices.py", line 38, in > .pins.rpigpio import rpigpiopin > file "/usr/lib/python2.7/dist-packages/gpiozero/pins/rpigpio.py", line 27, in > class rpigpiopin(pin): > > ***file "/usr/lib/python2.7/dist-packages/gpiozero/pins/rpigpio.py", line 55, > in rpigpiopin 'i2c': gpio.i2c, > > attributeerror: 'module' object has no attribute 'i2c'*

How to include all src/test/resources/** AND src/main/java/**/*.html in the test sourceset in gradle? -

i have following , thought 'adding' sourceset modified it.. sourcesets { test { resources { srcdirs = ["src/main/java"] includes = ["**/*.html"] } } } what want both src/test/resources/** , above well. don't want exclude files src/test/resources though , above including html directories put there. thanks, dean the following illustrate technique using main (so can verified): apply plugin: 'java' sourcesets { myextra { resources { srcdirs "src/main/java" includes = ["**/*.html"] } } main { resources { source myextra.resources } } } proof of concept via command-line: bash$ ls src/main/java abc.html xyz.txt bash$ ls src/main/resources/ def.html ijk.txt bash$ gradle clean jar bash$ jar tf build/libs/myexample.jar meta-inf/ meta-inf/manifest.mf abc.html def.html ijk.txt i

ruby on rails - Google Oauth2 automatially renew token -

i'm adding oauth2 via google rails app using omniauth-google-oauth2 gem. have set according gem's readme. when click authorize button in app, directed google authorize app. once i'm sent redirect path, hash of data includes token , refresh_token , , expires_at (not expires_in ), expires_at equal time.now.to_i . hash looks this: => auth.credentials => { token: 'token', refresh_token: 'refresh_token', expires_at: 1468603958 expires: true } what programmatically renew user's token every time log app, without forcing them go through initial authorization process. have similar token renewal flow set facebook, can't figure out how make work google, since token expires_at time now. my question two-part: shouldn't value of expires_at in future (e.g. 1 hour now, or 30 days now)? how can programmatically refresh token using refresh_token got when first authorized app? can't seem find single example in

java - I have 2 classes in Bluej and want to make a field in one of the classes be of type of the other class. How would I do this? -

i have made 2 classes in project in bluej , have link them making new field in main class of type of second class. what syntax this? i may interpreting question wrong but, assuming classes class1 , class2, can have class1 take in instance of class2 so: public class class1{ class2 otherclass; public class1(class2 otherclass){ this.otherclass = otherclass; } } now class1 has instance of class2 can play with. you may have class1 create class2 object instead of passing 1 so: public class class1{ class2 otherclass; public class1(){ otherclass = new class2(); } }

String array splitting in C# -

i have 2 string/text files : "1.dll" , "1a.dll" - 1.dll contains "order id" , "cartid"(separated enter '/n') - 1a.dll database witdh "id" , "name" (separated enter '/n') i splitting strings string array. i'm separating each array string in 2 strings. 1 number position , other odd number position. after splitting both files, have 4 array strings i'm displaying 4 listboxes. - 2 arrays 1.dll displying should - 2 arrays 1a.dll missing values. here screenshot problem //load , split "1.dll" > create 2 array strings. orderid=odd # position , cartid=even # position string = file.readalltext(@"order/1.dll"); string[] aa = a.split('\n'); aa = aa.select(s => (s ?? "").trim()).toarray(); string[] orderid = new string[aa.length]; string[] cartid = new string[aa.length]; int dial1 = 0; int dial2 = 0;

linux - Unable to stop suspect process even after reboot -

edit: user gene mentioned tried following commands: root@localhost:~# ps -axj | grep demo warning: bad ps syntax, perhaps bogus '-'? see http://gitorious.org/procps/procps/blobs/master/documentation/faq i tried without "-". after freezes. tried ps -aux | grep demo it freezes , nothing happens. tried root@localhost:~# ps aux user pid %cpu %mem vsz rss tty stat start time command root 1 0.0 0.0 10664 1532 ? ss 21:37 0:00 init [2] root 2 0.0 0.0 0 0 ? s 21:37 0:00 [kthreadd] root 3 1.1 0.0 0 0 ? s 21:37 0:15 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? s< 21:37 0:00 [kworker/0:0h] root 7 0.3 0.0 0 0 ? s 21:37 0:04 [rcu_sched] root 8 0.0 0.0 0 0 ? s 21:37 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? s 21:37 0:00 [migration/0] root 10 0.0 0.0

ruby on rails - Generation of table and accessing elements of a Array of Hashes -

i have following array of hashes in rails application: a = ["{\"row1\"=>{\"correct\"=>{\"h\"=>\"10\", \"m\"=>\"11\", \"l\"=> \"12\"}, \"wrong\"=>{\"h\"=>\"2\", \"m\"=>\"2\", \"l\"=>\"4\"}, \"blank \"=>{\"h\"=>\"2\", \"m\"=>\"4\", \"l\"=>\"3\"}}, \"row2\"=>{\"correct \"=>{\"h\"=>\"2\", \"m\"=>\"4\", \"l\"=>\"4\"}, \"wrong\"=>{\"h \"=>\"4\", \"m\"=>\"6\", \"l\"=>\"6\"}, \"blank\"=>{\"h\"=>\"7\", \"m\"=>\"5\", \"l\"=>\"6\"}}, \"row3\"=>{\"correct\&quo

why PHP casting MySQL BIT(1) value b'0' to boolean 'true' -

i have table in mysql structure followed: +-------+------------------+------+-----+---------+----------------+ | field | type | null | key | default | | +-------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | no | pri | null | auto_increment | | name | varchar(32) | yes | | null | | | bit | bit(1) | no | | b'0' | | +-------+------------------+------+-----+---------+----------------+ i insert record followed: +----+-------------+-----+ | id | name | bit | +----+-------------+-----+ | 1 | john | | +----+-------------+-----+ then use php script select , script followed: $pdo = new pdo("mysql:host=127.0.0.1;port=3306;dbname=test", "username","password"); $sql = "select * `for_test` `name` = :name"; $stmt = $pdo->prepare($sql); $stmt->execute([':name'

include - Difference between .h files and .inc files in c -

i have been looking @ various open source projects, , have bunch of files written in c have .inc file extension. far can tell, used header files. i thought standard convention use .h files header files , .c source files. so, there standard convention on when header file should .inc file rather being .h file, or these decided @ per project basis? (or looking @ weird projects use .inc ?) the standard convention use .h header files contain macro definitions , other declarations , .c c source files contain code , data definitions. in projects, code fragments stored in separate files , included in c source files macro tricks expand in different files or circumstances. sometimes, these files included multiple times in same source file. underscore special semantics attached such files, giving them different extension may useful hint. these files may have been generated part of build process: naming them may prevent confusion actual source files. look @ files came a

php - Codeigniter - URI Routes not working -

what current uri looks like: localhost/home/saved , localhost/home/view what want like: localhost/saved , localhost/view . what home controller looks like: class home extends ci_controller { public function index() { //stuff } public function saved() { //stuff } public function view() { //stuff } } i want rid of home url user can visit localhost/saved , , other functions in home without typing home in url. i tried putting these in routes.php file no luck. $route['home/(:any)'] = "$1"; //that didn't work tried putting this: $route['home/(:any)'] = "/$1"; //that didn't work either. any highly appreciated. thanks! try this $route['saved'] = 'home/saved'; $route['view'] = 'home/view'; output - www.example.com/saved , www.example.com/view

Android Contacts content provider not getting updated when a contact is added in background -

i'm developing application displays list of contacts fetching them android contacts content provider. in onresume method of fragment restart loader fetches contacts contacts content provider , works fine. if background app, use default android contacts app add contact , bring app background don't see new contact added list though onresume called , loader being restarted. i've debugged code , seems new contact not being returned contacts content provider. if terminate app (swipe recent menu) , re-open it, i'll see new contact in list. do know issue be? thanks, ido

android - scrolling marquee with updating text -

i have textview text updated runnable every 10 sec. after adding marquee effect got problem. when text updates blinks , appears in other position. how can make change letters? textview onetext = (textview) findviewbyid(r.id.onetext); onetext.setselected(true); handler = new handler(); final runnable r = new runnable() { public void run() { try { string bigstring = "some text here"; onetext.settext(bigstring); handler.postdelayed(this, 20 * 1000); } catch (exception e) { log.e(log_tag, e.getmessage()); } } }; <textview android:id="@+id/onetext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleline="true" android:ellipsize="marquee" android:marqueerepeatl

.net - How to invoke one controller method from another given only the uri -

for simplicity consider person resource such as {"name":"fred flintston", "worksat": {"href":"api/sites?cn=slate%20rock%20and%20gravel%20company"} } when receive on post peoplecontroller need site resource worksat.href. what invoke correct on sitescontroller leveraging routing engine knows how parse uri , invoke correct method. i have seen 1 suggestion here seems rather heavy handed, , i'm not @ sure how allow authorization has happened carry through. you can try following, if describe in detail want achieve, might able find better solution. mvc based, should work web api too. var baseurl = string.format("{0}://{1}{2}", request.url.scheme, request.url.authority, url.content("~")); var requesturl = new uri(baseurl + "home/index?i=42"); //get method info var httpcontext = new httpcontextwrapper(new httpcontext(new httprequest("/", requesturl.absoluteuri, ""

IOS/PHP: Capture success message in app after writing to server database -

after app inserts record in mysql database, capture id of new record , send app synching purposes. the question how efficiently capture , send app. here code posts server. -(void) posttoserver: (nsstring *) jsonstring { nsurl *url = [nsurl urlwithstring:@"http://www.~.com/services/new.php"]; nsmutableurlrequest *rq = [nsmutableurlrequest requestwithurl:url]; [rq sethttpmethod:@"post"]; nsdata *jsondata = [jsonstring datausingencoding:nsutf8stringencoding]; // nsdata *jsondata = [@"{ \"item\": \"hat\" }" datausingencoding:nsutf8stringencoding]; [rq sethttpbody:jsondata]; [rq setvalue:@"application/json" forhttpheaderfield:@"content-type"]; [rq setvalue:[nsstring stringwithformat:@"%ld", (long)[jsondata length]] forhttpheaderfield:@"content-length"]; [nsurlconnection sendasynchronousrequest:rq queue:[nsoperationqueue mainqueue] completionhandler:^(nsurl

r - Error running neural net -

library(nnet) set.seed(9850) train1<- sample(1:155,110) test1 <- setdiff(1:110,train1) ideal <- class.ind(hepatitis$class) hepatitisann = nnet(hepatitis[train1,-20], ideal[train1,], size=10, softmax=true) j <- predict(hepatitisann, hepatitis[test1,-20], type="class") hepatitis[test1,]$class table(predict(hepatitisann, hepatitis[test1,-20], type="class"),hepatitis[test1,]$class) confusionmatrix(hepatitis[test1,]$class, j) error: error in nnet.default(hepatitis[train1, -20], ideal[train1, ], size = 10, : na/nan/inf in foreign function call (arg 2) in addition: warning message: in nnet.default(hepatitis[train1, -20], ideal[train1, ], size = 10, : nas introduced coercion hepatitis variable consists of hepatitis dataset available on uci. this error message because have character values in data. try reading hepatitis dataset na.strings = "?". defined in description of dataset on uci page. headers <- c("class"

ggplot2 - New R user having problems installing and running plotly package -

a few months ago created shiny app using plotly. laptop @ time crashed, , have had download r , rstudio on new computer. having issues running plotly library on new computer, isn't allowing shiny app run @ all. library(plotly) loading required package: ggplot2 error in loadnamespace(i, c(lib.loc, .libpaths()), versioncheck = vi[[i]]) : there no package called ‘colorspace’ error: package ‘ggplot2’ not loaded i have searched other topics related ggplot2 errors this, , none of them has worked. installing colorspace , restarting r seemed have fixed this problem, formerly working shiny app glitchy. seems topic different question though.

Cannot access zxing jar in android studio -

i've added zxing core prebuilt jar android studio project. however, unable access of classes. if com.google.zxing doesn't recognize import nor other package. error receive cannot resolve symbol zxing . did add dependency project, i'm not sure going on. zxing core added module. the first time tried this, imported core files javadoc. i'm not sure if problem. tried again importing core jar, except time without javadocs. able access classes now.

python - ipcluster on Sun Grid Engine has only ranks 0 -

i set ipython parallel ipcluster use sun grid engine , things seem work fine: ipcluster start -n 100 --profile=sge 2016-07-15 14:47:09.749 [ipclusterstart] starting ipcluster [daemon=false] 2016-07-15 14:47:09.751 [ipclusterstart] creating pid file: /home/username/.ipython/profile_sge/pid/ipcluster.pid 2016-07-15 14:47:09.751 [ipclusterstart] starting controller sgecontrollerlauncher 2016-07-15 14:47:09.789 [ipclusterstart] job submitted job id: u'6354583' 2016-07-15 14:47:10.790 [ipclusterstart] starting 100 engines sgeenginesetlauncher 2016-07-15 14:47:10.826 [ipclusterstart] job submitted job id: u'6354584' 2016-07-15 14:47:40.856 [ipclusterstart] engines appear have started then connect notebook using rc = ipp.client(profile='sge') but when use parallel magic %%px mpi4py import mpi comm = mpi.comm_world nprocs = comm.get_size() rank = comm.get_rank() print('i #{} of {} , run on {}'.format(rank,nprocs,mpi.get_processor_name())) i

swift - Parallel search with dispatch_async -

i'm trying implement parallel-search algorithm. concept this: start candidate & test if desired value if not, generate more candidates , add them queue. repeat until reaching desired value as simplified example: want run random number generator in range 0..<n until gives me 0. want decrease n each iteration success guaranteed. code far: let queue = dispatch_get_global_queue(qos_class_background, 0) let work : dispatch_function_t = { arg in let upper = unsafemutablepointer<uint32>(arg).memory let random = arc4random_uniform(upper) if random == 0 { // things } else { dispatch_async_f(queue, &(upper - 1), work) // error: variable used within own initial value } } dispatch_async_f(queue, &1000, work) // error: '&' used non inout argument of type 'unsafemutablepointer<void>' i got 2 erros: variable used within own initial value '&' used noninout argument of type &#

osx - Get file's block from inode on Mac -

in terminal, i'm able particular file's inode using stat command: >> stat /some/file.txt 41307547 but can't figure out how information file's data blocks (like address) this. not sure if there's way native commands, did have luck using sleuthkit . once installed... load disk image , partition actual files: >> mls diskimage.dd slot start end length description 000: meta 0000000000 0000000000 0000000001 primary table (#0) 001: ------- 0000000000 0000000001 0000000002 unallocated 002: 000:000 0000000002 0003913663 0003913662 win95 fat32 (0x0b) the number 0000000002 offset files. using offset, can read list of files , inode values, if necessary: >> fls -o 2 diskimage.dd r/r 5: ._.trashes d/d * 6: _rashe~1.nrv d/d 8: .trashes d/d 10: .fseventsd d/d 13: .spotlight-v100 r/r 16: somefile.txt finally, our partition offset , inode number, use i

jquery - Can I use SAP UI5 mockserver without having a oData model -

backend : jersey backend frontend : sapui5 application json model i use jquery.ajax() calls make requests backend. mock these requests , load mock data quick poc. the mockserver provided sapui5 seems work odata model. can used json models? https://sapui5.netweaver.ondemand.com/#docs/guide/bae9d90d2e9c4206889368f04edab508.html thanks in advance. for json models don't need mockserver actually. in component.js try load json model below var omodel = new jsonmodel(uritojson); this.setmodel(omodel); uritojson link mock file ivan

scala - How to exclude transitive dependency in Sbt ( in context of assembly plugin )? -

i have 2 sbt projects, my-commons , my-service . my-commons with dependencies librarydependencies ++= seq( "nz.ac.waikato.cms.weka" % "attributeselectionsearchmethods" % "1.0.7", "de.bwaldvogel" % "liblinear" % "1.95" "io.dropwizard.metrics" % "metrics-graphite" % "3.1.2", "com.github.nscala-time" %% "nscala-time" % "2.2.0", "org.apache.hive" % "hive-jdbc" % "1.1.0-cdh5.4.5", "org.apache.hadoop" % "hadoop-common" % "2.6.0-cdh5.4.5", "org.apache.hadoop" % "hadoop-hdfs" % "2.6.0-cdh5.4.5" ) my-service: with dependencies librarydependencies ++= { seq( "ch.qos.logback" % "logback-classic" % "1.0.13", "io.spray" %% "spray-httpx" % "1.3.3", "io.spray" %% "spray-json&q

Byte separator for MOV command in assembly (masm) -

what if in mov command want write bytes separate numbers, 1 each byte, instead of 1 single number? separator use between bytes? also, byte separator can used in macro calls, comma occupied parameter separator? as example, following looking for, if ; used separator: mov ax, 25h;'d' in above example, first byte written hexadecimal number, second 1 written string. mov edx, 25h;'a';254;'l' in above example, first byte written hexadecimal number, second , fourth 1 string, , third hexadecimal number. you don't need separator between bytes. write both numbers (byte) in hexadecimal form. first number 23 = 17h second number 51 = 33h then use single mov use both bytes together: mov ax, 3317h edit change mov edx, 25h;'a';254;'l' into mov edx, 25h + ('a' << 8) + (254 << 16) + ('l' << 24)

java - How to make a more flexible search query using parse.com -

i've got database full of users , information , use parse.com search through them. now, make searching bit better, , make flexible uppercase, accents , like, have column called search_helper gets filled when user registers or updates info, this: string fullnamenormalized = normalizer.normalize(inputfirstname.gettext() + " " + inputfirstsurname.gettext() + " " + inputsecondsurname.gettext(), normalizer.form.nfd); fullnamenormalized = fullnamenormalized.replaceall("[^\\p{ascii}]", ""); fullnamenormalized = fullnamenormalized.tolowercase(); string searchhelper = fullnamenormalized + " " + email + " " + phone; so it's longer string contains of user's information in lowercase, when make query, looks this: string searchparams = searchtext.gettext().tostring().tolowercase().trim(); parsequery<parseuser> newsearch = parseuser.getqu

r - Does anyone know how to download TRMM 3B42 time series data? -

i'm trying download trmm 3b42 3-hour binary data given time span nasa ftp server . there excellent code made florian detsch download daily product (here link: https://github.com/environmentalinformatics-marburg/rsenal/blob/master/r/downloadtrmm.r ) included in github-only rsenal package. unfortunately not working 3-hour data. i changed code: downloadtrmm <- function(begin, end, dsn = ".", format = "%y-%m-%d.%h") { ## transform 'begin' , 'end' 'date' object if necessary if (!class(begin) == "date") begin <- as.date(begin, format = format) if (!class(end) == "date") end <- as.date(end, format = format) ## trmm ftp server ch_url <-"ftp://disc2.nascom.nasa.gov/data/trmm/gridded/3b42_v7/" ## loop on daily sequence ls_fls_out <- lapply(seq(begin, end, 1), function(i) { # year , julian day (name of corresponding folder) tmp_ch_yr <- strftime(i, format =

lua - Find all upper/lower/mixed combinations of a string -

i need game server using lua.. i able save combinations of name string can used with: if exists (string) example: abc_-123 abc_-123 abc_-123 abc_-123 abc_-123 etc in game numbers, letters , _ - . can used names. (a_b-c, a-b.c, ab_8 ... etc) i understand logic don't know how code it:d 0-lower 1-upper then 000 001 etc you can use recursive generator. first parameter contains left part of string generated far, , second parameter remaining right part of original string. function combinations(s1, s2) if s2:len() > 0 local c = s2:sub(1, 1) local l = c:lower() local u = c:upper() if l == u combinations(s1 .. c, s2:sub(2)) else combinations(s1 .. l, s2:sub(2)) combinations(s1 .. u, s2:sub(2)) end else print(s1) end end

Google Map Places javascript text search : can't get radius to work -

i need google places results (javascript, not places api) display list of places based on text search. everything working fine excepts radius parameter can see on jsfiddle . map = new google.maps.map(document.getelementbyid('map'), { center: pyrmont, zoom: 15 }); var request = { location: pyrmont, radius: '5000', query: cat_search }; service = new google.maps.places.placesservice(map); service.textsearch(request, callback); if click on "restaurant" ok, if click on "peintre" results on 5000 radius , if click on "fastfood et snack" results going crazy, results 70000 m radius returned. note: removed google map key script url on jsfiddle. results same key. key not revelant google map javascript api ? see the documentation , location , radius used bias results, not restrict them. if don't want display results outside of radius, can remove them output displayed. the documentation states: bounds

Android AsyncTask blocks UI thread -

i have asynctask performing database operations. problem when execute asynctask on threadpoolexecutor ui thread getting blocked. here code: private class addtoqueue extends asynctask<string, void, string> { int qlength = 0; protected string doinbackground(string... params) { if (db == null) return null; db.delete(dbhelper.queuetable, null, null); contentvalues cv = new contentvalues(); (int = 0; < qlength; i++) { cv.put(dbhelper.index, i); cv.put(dbhelper.path, items.get(i).getpath()); cv.put(dbhelper.title, items.get(i).gettitle()); try { db.insert(dbhelper.queuetable, null, cv); } catch (exception e) { e.printstacktrace(); } cv.clear(); } return "executed"; } @override protected void onposte

eclipse - How to install Android Wear Companion App on Android Phone Emulator -

i'm developing android app can push notifications android wear device (watch in case). i've no phone running android 4.0.3 or above , 've no watch either. want develop app on emulator can push notifications watch on emulator. i've followed , have created emulators same specs in tutorial: https://kennethmascarenhas.wordpress.com/2014/08/19/developing-for-android-wear-with-emulators/ however, i'm stuck on step says: "next, have install android wear companion app on phone emulator." there's no google play app on emulator. i've attempted download couple of apk's web (etc. http://www.apkmirror.com/apk/google-inc/android-wear/android-wear-1-0-5-1630507-apk/ ), never installs. can't figure out. kindly help.

encryption - C# - How to retrieve a connectionString from an App.config, Encrypting config sections -

i have configuration file looks super simple this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionstrings> <add name="sqlserverconnectionstring" connectionstring="connection1"/> <add name ="oracleserverconnectionstring" connectionstring="connection2"/> </connectionstrings> </configuration> it couldn't easier that. trying encrypt "connectionstrings" section. i've tried , tried following many online turotrials have not been able work. think have possibly found root of issue. when this: string conectionstring = configurationmanager.connectionstrings["sqlserverconnectionstring"].connectionstring; i am able expected result of "connection1". however, when this: var appconfigdir = @"c:\users\me\desktop\myproject\app.config"; system.configuration.configuration config = configurationmanager.openexecon

sql - Select empty column if regexp_match fails -

i'm trying select entities, if they're not match expression, 1 returns 'true' values. select entity_id, regexp_matches(error_params, '"select_flight"') not null mytable group 1 is there way solve such issue inside select statement or in case should use left join table regexp_matches result? if i'm understanding question correctly, can use count case : select entity_id, count(case when error_params '%select flight%' 1 end) cnt mytable group 1

javascript - how to write custom callback function in js -

i want set message callback after callback of reading file this: exp.getserverhandler=function (request,response){ if(request.url.startswith("/static/")){ //passing custom callback function input param filereadhandler(request,response,function callback(message){ console.log(message); }); } }; function filereadhandler(request,response,callback){ fs.readfile(request.url.substr(1), function(err,data) { if(err){ response.end("bad request"); response.statuscode=400; //here want set message callback param callback("failed"); }else{ response.end(data); //here want set message callback param callback("successful"); } } ); } but console didn't log message of callback! problem? correct way of doing this? edit: this code works

php - Remove tags from product page in Woocommerce -

sorry super-beginner question, want remove/hide below product description in woocommerce, says category. mean this: https://i.snag.gy/xczfot.jpg i have been searching how , apparentely easy adding this: .product_meta { display: none; } however, have tried pasting everywhere , nothing changed: i have tried on custom css box theme has in options i have tried woocommerce editor (plugings - editor) i have tried in stylesheet of theme in appearance - editor and nothing work could someome please explain me add it? or if code not way of doing this? please, keep in mind beginner. need step step like: go appearance - editor - xxx - in dropdown menu chose xx - xx - paste - save changes otherwise not know how follow instructions. thanks! you should use woocommerce action remove categories. please add code below functions.php add_action( 'after_setup_theme', 'my_after_setup_theme' ); function my_after_setup_theme() { remove_action( 'wooc

php - How to arrange the_content() in Wordpress post page? -

i'm trying format single post page template has custom types. i'm using the_content() displays post contents altogether, how can call individual content fields can arrange them in template? functions.php function stories_init() { $args = array( 'label' => 'stories', 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => 'stories'), 'query_var' => true, 'menu_icon' => 'dashicons-video-alt', 'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail',) ); register_post_type( 'stories', $args ); } single-post.html <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> &l

php - Laravel strange query doesn't want to work -

i'm trying username of table comments , doesn't work good. first of all, when execute query select `comments`.`username` `comments` inner join `threads` on `comments`.`tid` = `threads`.`tid` `comments`.`deleted_at` null , `threads`.`cid` = 4 order `comments`.`posted_at` desc limit 1 it return value needs return. remind, number 4 in query stands int(); now tried many things work propperly in laravel, doesn't... so have foreach loop in view , needs display username comments.username . how can this. every time try array sting, or else. the id cid called $categorie->id . this code: @foreach($categories $categorie) @if($categorie->fid == $forum->fid) <td class="topic-marker-forum"> <i class="fa fa-comments fa-3x"></i> </td> <td class="col-md-6 col-sm-6"> <div><a href="categorie-{{

Catch event click on button inside a modal created by jquery -

this question has answer here: event binding on dynamically created elements? 19 answers im trying add more feature in zabuto calendar. modal appear after click on date, allow add or remove event day. can't catch event click on button in modal. here code. function createmodal() { // create modal //... var $modalfooterbuttonsave = $('<button id="btnsave">save</button>'); var $modalfooterbuttondelete = $('<button id="btndelete">delete</button>'); //... //return modal } function mydatefunction() { //add modal html page $("#mymodal").html(createmodal()); //show modal $('#adjustmodal').modal('show'); return true; } $(document).ready(function () { // zabuto event click on date $("#my-calendar").zabuto_calendar({ action: function () { return m

sql - MYSQL: Select sum values from one column into multiple columns grouped by values selected from second table -

i have 2 tables table 'earning': id | amount | date | currency_id ----------------------------- 0 | 100000 | 01-01-2015 | 0 1 | 200000 | 01-01-2015 | 1 2 | 300000 | 01-01-2015 | 0 3 | 400000 | 02-01-2015 | 1 4 | 500000 | 02-01-2015 | 1 table 'currencies': id | code --------- 0 | usd 1 | eur so have possibility add new currency @ time. is possible select both tables following result? date | earned_usd | earned_eur ------------------------------------- 01-01-2015 | 400000 | 200000 02-01-2015 | 0 | 900000 thank lot!

Newton’s method pth root- MATLAB -

newton’s method can used calculate p-th root of positive real number. write matlab function myrootp.m calculates a^(1/p) a> 0 , positive integer p. function should stop when abs((xk^(p)/a)-1)<10^(-15). i used following code cannot find error: function root1 = root1( a,x0,p) xk=x0; fd= p*xk^(p-1); f=(xk^p)-a; if a<0 disp('error:a must positive , real') else k=1:p if abs(xk^p/a-1)<10^(-15) return disp('error'); else xk1=xk-f/fd; xk=xk1; fd= p*xk^(p-1); f=(xk^p)-a; end end end root1 = xk; return end i'd point out unfamiliar algorithm finding nth root of number using newton's method . back problem, there 2 errors: there no such keyword then in matlab. rid of it. you'll want iterate until error specified. looping many times there power p , , it's highly possible algorithm can converge before then, or worst case require more iterations p

java - HIBERNATE4 org.hibernate.MappingException: Unknown entity -

i'm learnig hibernate4 , have encountered problem while trying xml hibernate mapping. i'm using eclipse , mysql. the error when try insert object in db table: org.hibernate.mappingexception: unknown entity: com.hibernate.gestionproductos.modelo.proveedores hibernate.cfg.xml: <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory name="sfbdhibernate"> <property name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/bdhibernate</property> <pr

node.js - can I create a route that could be use both for serving HTML and REST API? -

okay here's scenario, knowledge there 3 ways create web application traditional way: render html page server not sure: create api , let user's browser download javascript application (angular, react, ember) highly interactive application the future: isomorphic web app, render html client-side technologies (angular, react, ember) server. i'm planning use third way, due faster load page, problem right if create mobile application. my stack: node.js + react let if i'm planning go mobile, need duplicate same route , logic ? current problem app.get('/users', function(req, res) { res.render('index', { message: "hey im jack" }); }); app.get('/api/users', function(req, res) { res.json({ message: "hey im jack" }) }); is there way use 1 route serve both html , rest? you can send either html or json (in case of rest). the /api/xxx route syntax makes clearer path serves json. but can depend on clie

azure - What ip address do you use to connect to a VM from a Web App through point-to-site VNET Integration? -

i have .net web api deployed web app , trying connect mysql db on vm in virtual network, it's responding 500 internal server error. my vnet consists of 1 vm no dns or site-to-site configuration. the preview portal says vnet integration connected, certificates in sync , gateway online. i gave vm static ip address i'm using in web.config connection string, thinking requests routed through gateway vm, according general mysql log aren't connection attempts mysql server. the address gave vm within range of addresses being routed vnet, , setup endpoint on vm port i'm trying connect mysql on access rule allows connections, i'm not sure why connection doesn't appear getting through gateway vm. you may check link provides instructions on how connect azure app service - web app azure virtual network, can use resources visible within network itself: https://azure.microsoft.com/en-us/documentation/articles/web-sites-integrate-with-vnet/

numpy - Python equivalent of ArrayPlot from Mathematica? -

after googling, decided should ask question. i following functionality, can't figure out how @ all. https://reference.wolfram.com/language/ref/arrayplot.html basically, want generate grid map color of each pixel specified me. thank you! in matplotlib package, there function imshow .

Avoid writing carriage return when writing line feed with Python -

if taken consideration carriage return = \r , line feed = \n python 3.5.1 (v3.5.1:37a07cee5969, dec 6 2015, 01:38:48) [msc v.1900 32 bit (intel)] on win32 type "help", "copyright", "credits" or "license" more information. >>> '{:02x}'.format(ord('\n')) '0a' >>> '{:02x}'.format(ord('\r')) '0d' how avoid writing carriage return when using open('filename','w').write('text\n') ? in interactive mode can this: >>> open('filename','w').write('text\n') 5 >>> c in open('filename','r').read(): ... print('{:02x}'.format(ord(c))) ... 74 65 78 74 0a this indicate line feed has been written, should 5 bytes long. -rw-r--r-- 1 djuric 197121 6 jul 15 21:00 filename ^ it 6 bytes long. can "windows thing", when open file in notepad++ exa