Posts

Showing posts from May, 2013

Simple Android app Can't get a blank activity to use non AppCompat theme -

i've been going through android training tutorials , can't seem simple blank activity apply theme theme.holo.light. this i've done far: set minsdkversion 11 in gradle script , synced project. applied theme in androidmanifest.xml setting: android:theme="@android:style/theme.holo.light" tried applying @ application/activity level , creating custom theme , setting parent. when running app in emulator crashes error: java.lang.runtimeexception: unable start activity componentinfo{com.example.test.themetest3/com.example.test.themetest3.mainactivity}: java.lang.illegalstateexception: need use theme.appcompat theme (or descendant) activity. according documentation default theme 11+ api levels theme.holo can't work , i'm missing something. activity insists on using appcompat themes only. need extend other class within activity? this activity code (generated creating blank activity). package com.example.test.themetest3; import android.os.b

Error in Xcode 7: None of the input catalogs contained a matching launch image set -

Image
i have launchimage asset proper type (launch image), , has required sizes purpose of app. when building archive before submission app store, following error message: /the/path/to/media.xcassets: none of input catalogs contained matching launch image set named "launchimage". it working in xcode 6 , not working anymore in xcode 7, though have not changed anything. it appears in 'red' in build settings, if asset missing, in assets, see screenshot. when click on red name, option 'not use assets'. select image asset, open file inspector on right side, go target membership , deselect check marks , enable target app have added icons.

c++ - Mex for Opencv's groupRectangles -

i using mexopencv matlab, have noticed grouprectangles matlab wrapper there supports 3 input arguments while source has 3 different versions. i don't know c++ tried follow guidelines , written code not able compile it; gives peculiar error. i appreciate if can this, need return scores of final bounding boxes project. so ! have found similar question & answer online: in cascadedetect.cpp in opencv, there several variants of grouprectangles function: void grouprectangles(std::vector& rectlist, int groupthreshold, double eps); void grouprectangles(std::vector& rectlist, std::vector& weights, int groupthreshold, double eps); void grouprectangles(std::vector& rectlist, std::vector& rejectlevels, std::vector& levelweights, int groupthreshold, double eps); in opencv document, first variant documented clearly, second variant mentioned weights argument not explained. third isn't mentioned. we want scores of grouped rectangles, documented variant

sublimetext3 - sublime symlink disappeared after upgrading to El Capitan -

i have upgraded os x el capitan , subl . command stopped working zsh: command not found: subl error message. i have run following command suggested in other posts: sudo ln -s /applications/sublime\ text.app/contents/sharedsupport/bin/subl /usr/local/bin/subl result: ln: /usr/local/bin/subl: file exists in ".bash_profile" ".zsh_profile" have following lines saved: export path=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$path export editor='subl -w' also tried: sudo ln -s /applications/sublime\ text.app/contents/sharedsupport/bin/subl /usr/bin/subl result: ln: /usr/bin/subl: operation not permitted update: seemed work after running following command: alias subl="'/applications/sublime text.app/contents/sharedsupport/bin/subl'" but restart terminal, subl . command stops working. update2: after pasting following line: alias subl="'/applications/sublime text.app/contents/sharedsupport/bin/subl

flask - Dynamic routing from form data -

i new flask having issue creating dynamic url form data. value of selectfield of wtforms. code follows my form looks this from flask_wtf import form wtforms import selectfield wtforms.fields.html5 import datefield class selecteventform(form): sports = selectfield(u'select sport') start_after_date = datefield('starts after date') start_before_date = datefield('starts before date') my controller has following code @app.route('/event', methods=['get', 'post']) def event(): form = selecteventform(request.form) sports = betfair_client.call_rest_api('listeventtypes/', {"filter": {}}) form.sports.choices = [] sport in sports: key in sport: form.sports.choices.append((key, sport[key])) return render_template('events.html', form=form) @app.route('/event/<sports>', methods=['get', 'post']) def event_select(sports): #print req

python - How to convert string series into integer -

one of columns of pandas data frame contains values such 0, 'a', 'b'. column parsed string. want convert integer 0, 1, 2. how can this? here's initial data: df = pd.dataframe({'col': [0, 'a', 'b', 'a']}) >>> df col 0 0 1 2 b 3 you can create dictionary of items you'd replace: d = {'a': 1, 'b': 2} then, apply get column, returning original value if not in dictionary: df['col'] = df.col.apply(lambda x: d.get(x, x)) >>> df df col 0 0 1 1 2 2 3 1 @edchum if of unique items contained in series in dictionary keys, .map(d) more 5 times fast. however, missing value appears nan . using lambda function get on dictionary appears have virtually identical performance. %%timeit df = pd.dataframe({'col': [0, 'a', 'b', 'a'] * 100000}) df['col'] = df.col.map(d) 10 loops, best of 3: 33.3 ms per loop >>

R Conditional summing -

i've started adventure programming in r. need create program summing numbers divisible 3 , 5 in range of 1 1000, using '%%' operator. came idea create 2 matrices numbers 1 1000 in 1 column , remainders in second one. however, don't know how sum proper elements (kind of "sum if" function in excel). attach i've done below. in advance help! s1<-1:1000 in<-s1%%3 m1<-matrix(c(s1,in), 1000, 2, byrow=false) s2<-1:1000 in2<-s2%%5 m2<-matrix(c(s2,in2),1000,2,byrow=false) mathematically, best way find least common multiple of 2 numbers , check remainder vs that: # borrowed roland rau # http://r.789695.n4.nabble.com/greatest-common-divisor-of-two-numbers-td823047.html gcd <- function(a,b) if (b==0) else gcd(b, %% b) lcm <- function(a,b) abs(a*b)/gcd(a,b) s <- seq(1000) s[ (s %% lcm(3,5)) == 0 ] # [1] 15 30 45 60 75 90 105 120 135 150 165 180 195 210 # [15] 225 240 255 270 285 300 315 330 345 360 375 390 405 420 # [

c++ - Passing a graph (list of lists) as parameter by reference, I want to add elements to each list to be used inside this function only -

i have function receives directed graph represented list of lists needs this: int algo::test(const vector<vector<int> > &graph) { ... // add few edges graph // calculations based on graph } i may or may not use const . for function work, need add few other edges graph (need make sure there [w,v] every edge [v,w]). i'll never remove anything, add, , not reorder edges, every new edge should appended @ end of respective list. @ end of function, graph should left in initial state. i thought of 2 obvious ways this: (1) use const , copy graph: vector<vector<int> > graph2(graph); // work on graph2 (2) not use const , save current size of each list in original graph, modify , in end erase added elements: vector<unsigned> origsizes(graph.size()); (unsigned = 0; < graph.size(); i++) origsizes[i] = graph[i].size(); // create edges , calculations (unsigned = 0; < graph.size(); i++) graph[i].erase(graph[i].begi

Phonegap build default icon vs Cordova cli build default icon -

i want write config.xml such can used both phonegap build , phonegap cli. for default icon, phonegap build requires icon placed under app/www/icon.png, , config.xml declared as <icon src="icon.png" /> but in phonegap cli, seems unable recognize path above. , throw error while building. i have tried <icon src="www/icon.png" /> but not work in phonegap build. app icon displayed on webpage, app downloaded not have icon. does know best way resolve issue? <!-- cordova build icon definitions --> <icon src="www/icon.png" /> <!-- phonegap build icon definitions --> <icon src="icon.png" gap:platform="ios" /> <icon src="icon.png" gap:platform="android" /> resolved issue above confix.xml

c - Optmization for quicksort in x86 32-bit assembly -

i'm trying learn basic x86 32-bit assembly programming. in pursuing decided implement quicksort in assembly (sorting integers). first made c-version of sorting function , made assembly version. however, when comparing assembly version c-version (compiled gcc on debian), c-version performs more 10 times faster on array of 10000 integers. so question if can give feedback on obvious optimizations can made on quick sort assembly routine. it's purely educational purposes , i'm not expecting beat compiler makers in terms of producing high speed code i'm interested in knowing if i'm making obvious mistakes hampers speed. the c-version: void myqsort(int* elems, int sidx, int eidx) { if (sidx < eidx) { int pivot = elems[eidx]; int = sidx; (int j = sidx; j < eidx; j++) { if (elems[j] <= pivot) { swap(&elems[i], &elems[j]); = + 1; }

html - How to make inset box shadow show over child links, but still have them be clickable? -

i have div inset box shadow , there links in div want shadow display over, still have links clickable. here's example: https://jsfiddle.net/5rsbn927/ <div id="navigation" role="navigation"> <div id="navbar" role="navigation"> <!-- div has shadow --> <a href="#" id="link1">link</a><a href="#" id="link2">link</a><a href="#" id="link3">link</a><a href="#" id="link4">link</a><a href="#" id="link5">link</a><a href="#" id="link6">link</a> </div> </div> the #navbar div has shadow , links inline-blocks. i can't seem work. z-index (with positioning), pointer-events, :before, none of has worked far. time i've managed shadow show above links, aren't clickable. for record here's how it's supposed lo

html - CSS Slide Show not working for IE -

i implementing css slide show on site. used codepen guide: http://codepen.io/antoniskamamis/pen/hjbre i first experienced issue slide show not working correctly in safari. able address issue adding animation-delay properties browsers. tested on browsers except ie until now, , reason slide show not work in ie. can see demo (code pen) in fact work in ie. would additional css added handle animations in safari have caused ie break? if has idea, extremely appreciated! .slider { margin: 10px auto; width: 500px; height: 320px; overflow: hidden; position: relative; } .photo { position: absolute; -webkit-animation: round 16s infinite; -moz-animation: round 16s infinite; -ms-animation: round 16s infinite; -o-animation: round 16s infinite; animation: round 16s infinite; -ms-filter: "progid:dximagetransform.microsoft.alpha(opacity=0)"; filter: alpha(opacity=0); opacity: 0; } @keyframes "round" {

square of character inside square of another character in java -

i want print square of character in format basad on the number of lines example : number of lines : 4 output : b b b b number of lines : 5 output : a b b b b c b b b b a but didn't know how result , code import java.util.scanner; public class test { public static void main ( string arugs [] ) { scanner read= new scanner(system.in) ; system.out.println ( " please inter number of line : " ) ; int size = read.nextint(); int []array = new int[size ]; int c = 97; for(int = 0; < size; ++i) { for(int j = 0; j < size; ++j){ array[i]= c; system.out.print( (char)array [i]);} system.out.println(); } } } } a funny way : public static void main(string arugs[]) { scanner sc = new scanner(system.in); system.ou

jquery - UnCaught TypeError $(...).kendoGrid is not a function -

earlier on , many days before today, have never gotten error, getting data returned, won't show data because of error uncaught typeerror $(...).kendogrid not function my grid this.. function showadministratorsgrid(administratordata) { $("#admingrid").kendogrid({ datasource: { data: administratordata }, columns: [{ field: "administratorid", title: "administratorid", hidden: true }, { field: "administratorname", title: "administratorname" }, { field: "datecreated", title: "datecreated" }, { field: "createdby", title: "createdby" }], scrollable: true, sortable: true, pageable: false, selectable: "row", change: function (e) {

javascript - How can I pass information into perl script from web? -

i want call perl script using java script, , pass java script variable? script written else. want script on text output results on website. problem script requires file input. the perl script has following usage latexindent.pl [options] [file][.tex] i want pass in text box when call script, , return commands printed console javascript function. function ajax_info() { $.ajax({ url: "latexindent.pl", cache: false, datatype: "text", data: { mode: 'this text!' }, success: function(result) { ajax_info_result(result); } }); } function ajax_info_result(result) { var text = "the server says: <b>" + result + "</b>"; $('#info').html(text); } you mentioned cgi tag assume aren't using node.js in case @ somthing along lines of var exec = require('child_process').exec; var cmd = 'prince -v builds/pdf/book.html -o bui

arrays - np.around and np.round not actually rounding -

i'm writing simple code in python 2.7 change couple long files have text files can scroll through them in text reader. however, found out numpy.array in file has long floats end in unneeded scientific notation. try , use numpy.around or numpy.round change these have 2 places after decimal doesn't change anything. here code: import h5py import sys tkinter import tk tkfiledialog import askopenfilename import numpy np sys.stdout.write( 'please pick file window\n') filename = askopenfilename() # show "open" dialog box , return path selected file sys.stdout.write(filename) f = h5py.file(filename, 'r') dataset = f['/dcoor'][:] newname = raw_input('new file name ') print type(dataset[0][0]) dataset = np.asarray(dataset) dataset = dataset.astype(float) print type(dataset[0][0]) print '\ndataset before rounding: \n', dataset dataset = np.around(dataset, decimals = 2) print '\ndataset after rounding: \n', dataset np

associations - Rails - counting instances where boolean is true -

i trying make app rails 4. i have project model , project invitations model. projects has many project invitations project invitations belong projects in project show, im trying count how many invitations have been sent , how many have been accepted. the first part works fine. acceptances, have attribute in project_invitation table called :student_accepted. if true, want count record. <%= @project.project_invitations.size %> <% if @project.project_invitations.student_accepted == true %> <%= @project.project_invitations.size %> <% else %> 'no' <% end %> it gives error: undefined method `student_accepted' #<activerecord::associations::collectionproxy []> i have tried: <% if project.project_invitations.student_accepted == true %> <%= project.project_invitations.size %> it gives error: undefined local variable or method `project'

c# - App.Config cannot access appSettings key/value pairs. The collection is always null -

i have app.config trying values out of , in solution executable. have compared output config.exe , visible. when try set these values, not show in collection. <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.5" /> </startup> <appsettings> <add key="a" value="b"/> </appsettings> </configuration> i have tried can think of , have never had problem before. part of larger solution cannot show real values, have tested them in console project created , show fine. not sure why wouldn't show in particular solution. third party tools effect this? i trying access them this: using system.configuration; private readonly string stringtoset; public theconstructor() { stringtoset = configurationmanager.appsettings[key]; } update figured out reason, class library somehow hij

java - Thread safe list that only needs to support random access and appends -

i want have list of objects satisfies few basic requirements. needs support fast random access , needs safe use multiple threads. reads dominate far , ideally should fast normal arraylist access, i.e. no locking. there no need insert elements in middle, delete, or change value @ index: mutation required able append new element end of list. more caller specify index @ element should placed, , index expected few more length of list, i.e. list dense. there no need iteration. is there supports in java? can in third party library. if not thinking implement own class. there'll internal array of arrays, each twice big last. lookups index little more maths figure out array has right element , index in array is. appends similar unless go beyond available space, in case new array allocated. creation of new array require lock acquired. does sound sensible approach? this doesn't sound particularly novel data structure. have name? reads dominate far , ideally should

ruby on rails - FFmpeg buildpack for Heroku does not support ogg. Unknown encoder 'libvorbis' -

after work, able buildpack installed on heroku. ran error: stream #0:0: audio: pcm_u8 ([1][0][0][0] / 0x0001), 22050 hz, mono, u8, 176 kb/s 2015-10-03t01:15:59.635036+00:00 app[web.1]: -t not input option, keeping next output; consider fixing command line. 2015-10-03t01:15:59.635055+00:00 app[web.1]: please use -q:a or -q:v, -qscale ambiguous 2015-10-03t01:15:59.635479+00:00 app[web.1]: unknown encoder 'libvorbis' my code is: ffmpeg -t 15 -i #{current_path} -acodec libvorbis -qscale 1 #{temp_path} the -t option supposed seconds , libvorbis ogg conversion. ffmpeg -version returns this: ffmpeg version git-2013-06-02-5711e4f built on jun 2 2013 07:38:40 gcc 4.4.3 (ubuntu 4.4.3-4ubuntu5.1) configuration: --enable-shared --disable-asm --prefix=/app/vendor/ffmpeg libavutil 52. 34.100 / 52. 34.100 libavcodec 55. 13.100 / 55. 13.100 libavformat 55. 8.102 / 55. 8.102 libavdevice 55. 2.100 / 55. 2.100 libavfilter 3. 74.101 / 3. 74.101 libswscale 2. 3.100 / 2. 3.1

java - Can I start a HTML element in one jsp page, close it in another? -

i want know if can put start tag of html element inside "include" in jsp, , close html element outside include file, or in include file. example, have website: <%@ page language="java" pageencoding="utf-8" %> <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <mytags:scriptloader /> <mytags:cssloader /> </head> <body> <div id="bodycontainer" class="container-fluid"> <div class="row"> <div class="col-lg-10 col-md-10 col-sm-9"> <jsp:include page="/web-inf/views/sidebar.jsp" /> <div class="container-fluid"> <h2>welcome</h2&

javascript - Angular.js making repeated requests and never loading -

i'm in process of learning angular.js, have simple node app serving basic angular web page , writing simple log data stdout. until now, has worked fine, now, no known reason, every time try load page, page doesn't load (and crashes) , until forced memory issues kill it, happens in node app: my-imac:learning angular.js me$ node node-app.js incoming request /libs/bootstrap/js/bootstrap.min.js?_=1443846525840 loaded page /libs/bootstrap/js/bootstrap.min.js?_=1443846525840 incoming request /libs/angular.min.js?_=1443846526063 loaded page /libs/angular.min.js?_=1443846526063 incoming request /libs/angular-route.min.js?_=1443846526340 loaded page /libs/angular-route.min.js?_=1443846526340 incoming request /js/3.js?_=1443846526389 loaded page /js/3.js?_=1443846526389 incoming request /libs/jquery.min.js?_=1443846526398 loaded page /libs/jquery.min.js?_=1443846526398 incoming request /libs/bootstrap/js/bootstrap.min.js?_=1443846526637 loaded page /libs/bootstrap/js/bootstrap.min.

distributed - given a zookeeper server ip:port, how to get the zookeeper structure? -

given zookeeper server ip:port, how zookeeper structure? example told zookeper service server 192.1.2.17:2181 i can use zkcli.sh login , basic stuff. can use without problem. want know how many nodes in zookeeper setup? nodes?? status? how achieve this? thanks you might find of these commands useful: http://zookeeper.apache.org/doc/trunk/zookeeperadmin.html#the+four+letter+words you can run them against server ip:port given, e.g.: echo mntr | nc 192.1.2.17 2181 if have access host, check configuration under <zoo install>/conf/zoo.cfg .

How to properly access the value of a capture group in C# regex? -

i have following code: using system; using system.text.regularexpressions; public class test { public static void main() { var r = new regex(@"_(\d+)$"); string new_name = "asdf_1"; new_name = r.replace(new_name, match => { console.writeline(match.value); return match.value; //return (convert.touint32(match.value) + 1).tostring(); }); //console.writeline(new_name); } } i expect match.value 1 , printing _1 . doing wrong? you're getting value of whole match - want single group (group 1) can access via groups property , groupcollection indexer : console.writeline(match.groups[1]);

c - Writing string to pipe -

i trying send string pipe in unix. when go through line-by-line debugging process, call mkfifo() creates file in same directory source code. however, when reach open() call, debugger no longer able proceed. i'm not sure why unable access pipe file. here's code in question: #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> int main() { int fd; char * myfifo = "myfifo"; /* create fifo (named pipe) */ mkfifo(myfifo, 0666); /* write "hi" fifo */ fd = open(myfifo, o_wronly); write(fd, "hi", sizeof("hi")); close(fd); /* remove fifo */ unlink(myfifo); return 0; } any suggestions appreciated. thank you. normally fifo has open @ both ends simultaneously before either side can proceed. since didn't mention reader, answer haven't got one, or haven't set yet. once do, open allowed proceed.

sqlite - In ANDROID how delete data from LISTVIEW by Button click? -

in application listview populated data sqlite database. use button delete items. , modify table in sqlite db . sql db class protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_table); tv = (textview) findviewbyid(r.id.txt_rates); // checkout = (button) findviewbyid(r.id.submit_btn); listcart = (listview) findviewbyid(r.id.list_item); pdialog = new progressdialog(this); ctx = this; cartdata = table.this.openorcreatedatabase("shopping_cart", mode_private, null); cartdata.execsql("create table if not exists cart_items(product_id varchar, name varchar, price varchar, quantity integer, model varchar, image varchar, manufacturer varchar )"); arraylist<cartproducts> mylist = new arraylist<cartproducts>(); cursor crsr = cartdata.rawquery("select * cart_items", null); final string[] productid = new string[crsr.getcount()];

javascript - How to detect current iframe url? -

i wrote html code initializes iframe site. my domain example: www.mydomain.com/index.html in there's <iframe src = "www.anotherdomain.com/pages/firstpage.html"/> i want detect complete new src url whenever iframe gets new one. iframe text consists links other pages within initialised page. possible , legal done ? thanks. appreciated. i guess goes cross origin issues there work around ? update i tried answer document.getelementbyid("myiframeid").src at frame load event. keeps showing src initialised. not showing updated src. document.getelementbyid("myiframeid").contentwindow.location.href gives security error http frame trying access https in iframe. protocols mismatched. i made localhost ssl , used https request got blocked. don't know why. i don't agree answers suggest should use "src" detect current url of iframe. doesn't give current url - url started with. the domain has same