Posts

Showing posts from July, 2013

java - JimFS: what is the purpose of /work directory -

i started use google jimfs , doing ls found there work directory in root of fs. purpose of folder? it's arbitrary directory working directory (the directory relative paths resolved against) isn't root directory, since typically isn't in real situations. can change working directory whatever want (including root) customizing configuration . here's example of setting working directory root (in case /work directory won't created): configuration config = configuration.unix().tobuilder() .setworkingdirectory("/") .build();

javascript - Fisher Yates shuffle 1 number shown -

i using fisher yates shuffle , gone through little tutorial, can see can randomize order such 4,1,3,2,6,7,5 etc... want find out how have 1 number shown. there submit button , when press submit random number between 1 7 shown. number put aside when hit submit again there 100% chance wont see number again. can press submit 7 times , 8th time nothing happen. javascript using: <script> array.prototype.shuffle = function(){ var = this.length, j, temp; while(--i > 0) { j = math.floor(math.random() * (i+1)); temp = this[j]; this[j] = this[i]; this[i] = temp; } return this; } var arr = ['a','b','c','d','e','f','g','h']; var result = arr.shuffle(); document.write(result); </script> i have googled no success, many thanks. here implementation of have used. function fisheryates ( myarray,stop_count ) { var = myarray.length; if ( == 0 ) return false; var c = 0; w...

c# - Namespace '<global namespace>' contains a definition conflicting with alias 'PersianDate' -

i'm developing winform application in c# , fine. of sudden weird error when tried run application. namespace '' contains definition conflicting alias 'persiandate' this line throws error. private persiandate _quotationdate; all done before getting error add form_load event. private void frmadddragsource_load(object sender, eventargs e) { this.text = "source"; } does knows why happens , how can fix it? update usings: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.data.sqlserverce; using system.drawing; using system.linq; using system.text; using system.windows.forms; using fishtablighpro.utility; using persiandate = freecontrols.persiandate; since defined persiandate alias freecontrols.persiandate namespace. compiler can't tell whether persiandate refer namespace alias created, or persiandate type defined in it. try point directly persiandate t...

proof - Idris rewrite tactic doesn't work as expected -

i have example o : type hom : o -> o -> type id : (a : o) -> hom a comp : hom b -> hom b c -> hom c idright : (f : hom b) -> comp f (id b) = f idleft : (f : hom b) -> comp (id a) f = f assoc : (f : hom b) -> (g : hom b c) -> (h : hom c d) -> comp f (comp g h) = comp (comp f g) h eqid : (f : hom b) -> (g : hom b a) -> (h : hom b a) -> comp f g = id -> comp h f = id b -> g = h eqid = ?eqidproof and try use tactics in order make proof 1. intro a, b, f, g, h, fg, hf 2. rewrite idleft g 3. rewrite hf 4. rewrite assoc h f g so 4 step nothing. nothing sym . i'm doing wrong? possible there bug in idris itself? your file contains type declarations. need fill in body definitions if want this. example o : type , type declaration o , , won't usable until write like o : type o = bool in order use rewrite, need supply proof of form a = b . m...

click a data toggle button using Jquery -

i have form has 4 data toggle tabs , submit button @ 4th tab. when click submit button, showing popup alert on filed not correct. should navigate 1st tab. how can click data toggle button using jquery ? tried many methods .click , .trigger , show , hide etc. not working.. of try.. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> function triger() { $('#trigered').trigger('click'); } function trigered () { $('#vamsi').show(); alert('hello. clicked'); } <script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css"> <button onclick=...

node.js - Can't start mongodb on AWS instance -

i have worked on mongodb database. have installed in server & worked on this. facing problem. mongodb database not responding. when giving command : mongo mongodb shell version: 2.6.10 connecting to: test 2015-07-02t06:22:11.363+0000 warning: failed connect 127.0.0.1:27017, reason: errno:111 connection refused 2015-07-02t06:22:11.364+0000 error: couldn't connect server 127.0.0.1:27017 (127.0.0.1), connection attempt failed @ src/mongo/shell/mongo.js:146 exception: connect failed i have delete lock file, repair mongodb restart mongodb. cant solve problem. here mongodb.log file: 2015-07-02t06:30:48.789+0000 [initandlisten] mongodb starting : pid=5551 port=27017 dbpath=/var/lib/mongodb 64-bit host=ip-172-31-5-213 2015-07-02t06:30:48.789+0000 [initandlisten] db version v2.6.10 2015-07-02t06:30:48.789+0000 [initandlisten] git version: 5901dbfb49d16eaef6f2c2c50fba534d23ac7f6c 2015-07-02t06:30:48.789+0000 [initandlisten] build info: linux build18.nj1.10gen.cc 2.6.32-431....

java - XSD FOR XML element multiple occurrences -

i'm new xsd , want generate xml below studentrecord occurring multiple times. i'm using jaxb generate classes on xsd <studentdetail> <studentinformation> <studentrecord> <name>abc</name> <class>4</class> <major>science</major> <grade>a</grade> </studentrecord> <studentrecord> <name>def</name> <class>4</class> <major>science</major> <grade>b</grade> </studentrecord> </studentinformation> my current xsd generates studentrecord once. <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns="http://webservice.com/ws" targetnamespace="http://webservice.com/ws" elementformdefault="qualified" attributeformdefault="unqualified"> <x...

comparison - How do I match "|" in a regular expression in PowerShell? -

i want use regular expression filter out if string contains 1 of "&" or "|" or "=". tried: $compareregex = [string]::join("|", @("&","|", "=")); "mydfa" -match $comparestr powershell prints "true". not wanted, , seems "|" has confused powershell matching. how fix it? @kayasax answer in case (thus +1), wanted suggest more general solution. first of all: not using pattern you've created. suspect $comparestr $null , match anything. to point: if want create pattern match characters/strings , can't predict if of them be/contain special character or not, use [regex]::escape() item want match against: $patternlist = "&","|", "=" | foreach-object { [regex]::escape($_) } $compareregex = $patternlist -join '|' "mydfa" -match $compareregex in such case input can dynamic, , won't end pattern matches an...

how to convert this C# code snippet to Javascript -

this question has answer here: repeat string - javascript 29 answers i need understand how javascript handles new string object in c# code below var upperbound = 14; (int = 0; < upperbound; i++) { console.writeline(new string('*', i)); } console.readline(); this how did in javascript: var upperbound = 14; for(var i=0;i<upperbound;i++){ console.log(new string("*", i)); } am newbie in programming , started off javascript if appear dumb asking question pls pardon , assist me explaining.. thanks there no equivalent new string("*", i) in js. need repetition yourself. a handy hack array(i + 1).join("*") , not efficient don't think, needs construct array. best way loop , concatenate.

python - Matplotlib Mollweide/Hammer projection: region of interest only -

Image
i wondering if there's way show region of interest plot based on mollweide/hammer projection in basemap (matplotlib). i trying set plot-bounds pacific plate, in link below. however, set_xlim , set_ylim functions not seem have effect. in advance guidance. http://geology.gsapubs.org/content/29/8/695/f1.large.jpg from documentation, both hammer , mollweide projections don't allow print out entire world maps. here's code using polyconic projection, bounded straight lines. trick here define corner longitude , latitudes on creation. from mpl_toolkits.basemap import basemap import matplotlib.pyplot plt import numpy np my_map = basemap(projection='poly', lat_0=0, lon_0=-160, resolution = 'h', area_thresh = 0.1, llcrnrlon=140, llcrnrlat=-60, urcrnrlon=-100, urcrnrlat=60) plt.figure(figsize=(16,12)) my_map.drawcoastlines() my_map.drawcountries() my_map.fillcontinents(color='coral', lake_color='aqua') my_map.drawmapb...

parse.com - How to connect my app to parse in android studio -

i unzip sdk named parse-1.9.2 , dragged files libs folder present in app folder. added following code in build.gradle(module: app) dependencies { compile 'com.parse.bolts:bolts-android:1.+' compile filetree(dir: 'libs', include: 'parse-*.jar') } after don't how proceed. if not new android development, easy set parse sdk android project using steps provided in parse.com website. if new android development, follow 1 of these, https://guides.codepath.com/android/building-data-driven-apps-with-parse http://www.androidbegin.com/tutorial/android-parse-com-simple-login-and-signup-tutorial/

how to join various bits of string and data together using python -

python newbie here. i've been working way through code create string includes date. have bits of code working data want, need formatting string tie in data together. this have far: def get_rectype_count(filename, rectype): return int(subprocess.check_output('''zcat %s | ''' '''awk 'begin {fs=";"};{print $6}' | ''' '''grep -i %r | wc -l''' % (filename, rectype), shell=true)) str = "my values (" rectypes = 'click', 'bounce' myfilename in glob.iglob('*.gz'): #print (rectypes) print str.join(rectypes) print (timestr) print([get_rectype_count(myfilename, rectype) rectype in rectypes]) my output looks this: clickmy values (bounce '2015-07-01' [222, 0] i'm tr...

How can i change default toast message color and background color in android? -

i want create toast message background color white , message color black. how can create it? my toast message is: toast.maketext(logpage.this, "please give feedback...", 3000).show(); i wanted create in method not in oncreate(). you can create custom toast message below : toast toast = new toast(context); toast.setduration(toast.length_long); layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service); view view = inflater.inflate(r.layout.your_custom_layout, null); toast.setview(view); toast.show(); one textview can put inside layout file , give background , textcolor want. also can following won't need custom layout file : toast toast = toast.maketext(context, r.string.string_message_id, toast.length_long); view view = toast.getview(); view.setbackgroundresource(r.drawable.custom_backgrround); textview text = (textview) view.findviewbyid(android.r.id.message); /*here can above textview text.settextc...

checkbox - Django - Iterating Checkboxes from ManyToManyField then adding in Views -

i'm making program let users create lists out of of contacts have available. i'd have entire list iterate checkboxes, in views, add checked boxes contact list's contacts list in 1 go. i know how iterate checkboxes, don't know how tell views check boxes see ones checked, add associated user list. in models.py: class organization(models.model): users = models.manytomanyfield(user, related_name='organizations') class contact(models.model): unique_id = models.integerfield(default=1) email_address = models.charfield(max_length=50, null=true, blank=true) name = models.charfield(max_length=200, null=true, blank=true) class contactlist(models.model): unique_id = models.integerfield(default=1) name = models.charfield(max_length=200, null=true, blank=true) contacts = models.manytomanyfield(contact, related_name='contact_lists') in contactlist.html: <form action="/contactlists/add_contacts/ method="post"...

How to retrieve folder files from Google Cloud using PHP client library? -

i want retrieve files of folder in google cloud storage. searched lot cannot found anything. have tried this: $bucket = $storageservice->objects->get(default_bucket,"myfolder/",array()); $getbucketmarkup = generatemarkup('get bucket', $bucket); print_r($getbucketmarkup); i have solved putting 2 parameters of list objects in array 1 delimiter , second 1 prefix $bucket = $storageservice->objects->listobjects(default_bucket,array( "delimiter"=>"/", "prefix"=>$folder_name ));

Android OnClickListener for RecyclerView's Child's Child -

what want set onclicklistener imageview in item in recyclerview. want click on imageview code , click anywhere else run code b. how can that? using: public class recycleradapter extends recyclerview.adapter<recycleradapter.recyclerviewholder> { layoutinflater inflater; context context; clicklistener clicklistener; list<postcontent> posts = collections.emptylist(); public recycleradapter(context context) { this.context = context; inflater = layoutinflater.from(context); } public void setposts(list<postcontent> posts) { this.posts = posts; } @override public recyclerviewholder oncreateviewholder(viewgroup viewgroup, int i) { view view = inflater.inflate(r.layout.post_row, viewgroup, false); recyclerviewholder viewholder = new recyclerviewholder(view); return viewholder; } @override public void onbindviewholder(recyclerviewholder viewholder, int i) { ...

php - (NATIVE JAVASCRIPT) - The function with ajax request does not provide a response -

i'm working in module in user going register , following methods i'm going mention check if email of registrant in use. why function ajax request not return value other function ajax request? way, i'm not using javascript framework such jquery, plain , native javascript ;) by way, here code ^_^ note: xmlhttprequest() okay. nothing :) function checkemailexistense(email){ var url = "library/functions.php?action=emailchecker&emailadd=" + email; http.onreadystatechange = function(){ if (http.status == 200 && (http.readystate === 4)){ var res = http.responsetext; if (res == "invalid") { return 0; } } } http.open("get", url , true); http.send(); } on javascript function wherein have ajax request registration, have if statement check if returning value of function above 0; var emailaddress = document.getelementbyid("emailadd").value; if (checkemailexistense(emaila...

ios - Xcode - Width and Horizontal Position Are Ambiguous -

Image
i'm trying figure out how autolayout works , have run problem don't understand why getting warning "the width , horizontal position ambiguous" view. view bottom thin blue line can see in screenshot of viewcontroller dealing with: the arrow , home buttons not have constraints. constraints larger gray view follows: the constraints "authors" label follows: and constraints blue thin view follows: i don't understand why getting warning since larger gray view isn't getting warning there doesn't seem difference in how treat 2 views. made sure include constraints on leading , trailing space both of them why horizontal position ambiguous thin blue one? can kind of see why width might ambiguous don't understand why wouldn't ambiguous larger gray view. shouldn't autolayout automatically deal it? want width obvious scale screen size. its better not put such view inside top bar, below greybar best if doing partition...

node.js - nodejs sync issue with q -

i used http fetch json, can not pass front page, used q, helpfully can execute sync, still problems, can help? //getturnto.js var conf = require("../conf/setting.json"); var http = require("http"); function turntougc(){ if(!(this instanceof turntougc)){ return new turntougc(); } }; turntougc.prototype.getugcjson = function(item,callback){ var ugcpath = conf.ugcpath; var options = { host:conf.ugchost, port:conf.ugcport, path:ugcpath }; http.get(options,function(res){ var buf = ""; res.on("data",function(d){ buf += d; }); res.on("error",function(error){ callback(error); }); res.on("end", function () { var ret; try{ ret = json.parse(buf); ...

sql server - Cant Print Int after varchar -

why can't print deptid integer? alter proc spgetnamebyid @id int, @name varchar(50) output, @gender varchar (50) output, @deptid int output begin select @name = name, @gender = gender , @deptid = deptid tblemployee id = @id end declare @getname varchar(50), @getgender varchar(50), @getdeptid int execute spgetnamebyid 1, @getname out, @getgender out, @getdeptid out print 'name of employee ' + @getname + ' gender ' + @getgender + 'dept id ' + @getdeptid my error msg 245, level 16, state 1, line 3 conversion failed when converting varchar value 'name of employee john gender maledept id ' data type int. the @getdeptid integer value, need convert varchar before concatenating string print 'name of employee ' + @getname + ' gender ' + @getgender + 'dept id ' + cast(@getdeptid varchar(10)) reason when not explicitl...

bitbucket - How can I locally preview a Markdown Wiki? -

bitbucket's wiki uses markdown syntax. there plenty of ways preview single .md file, there way preview whole markdown site under os x ? i.e. handle multiple files @ once, internal links working . searching yields dozens of solutions single files, none apparently supposed work setup. you want "static site generator" (see few lists here ). primary function walk directory , convert files within html. can "build" site , browse files on filesystem, or many tools offer "serve" command serve files on localhost previewing. example, github uses jekyll parts of service ( github pages ). however, don't know tools bitbucket using, can't point more specific give identical behavior bitbucket's wiki. believe python shop (github ruby--thus ruby tool), there multiple python implementations of markdown parsers doesn't way there. additionally, static site generators blog tools (generate posts in ordered list date) , others not (g...

c# - How to return Dictionary<complexType,int> with WebAPI -

i'm providing webapi 2 endpoint done in way: my controller simply: public idictionary<myclass, int> getmyclasses(string id) { dictionary<myclasses, int> sample = new dictionary<myclasses, int>(); sample.add(new myclasses() { property1 = "aaa", property2 = 5, property3 = 8 },10); return sample; } the structure of myclass is: public class myclass { string property1 {get;set;} int property2 {get;set;} int property3 {get;set;} } when run webservice, helper webpage shows me expected outputs are: { "mynamespace.myproject.myclass": 1 } on other hand xml sample i'd (except want json, not xml): <arrayofkeyvalueofmyclassintl85fhlc_p xmlns:i="http://www.w3.org/2001/xmlschema-instance" xmlns="http://schemas.microsoft.com/2003/10/serialization/arrays"> <keyvalueofmyclassintl85fhlc_p> <key xmlns:d3p1="http://schemas.datacontract.org/20...

android - SQLLITEDATABASE crash-oncreate not called ? db.getreadabledatabase/getwritabledatabase crash -

i'm beginner @ android , sqlite well. have been trying build database retrieves , shows entries items, price , time. have looked through other topics can't seem find why crashes. have tried lot of ways make work, code trying use: public class data extends sqliteopenhelper { private static final string database_name ="items.db"; private static final string t="database created"; private static final int database_version=1; context ct; sqlitedatabase db; public data (context ctx) { super(ctx, database_name, null, database_version); ct=ctx; } @override public void oncreate(sqlitedatabase db) { db.execsql("create table record (_id primary key autoincrement,time text,item text,type text,amt text)"); int duration = toast.length_long; toast toast = toast.maketext(ct, t, duration); toast.show(); } @override public void onupgrade(sqlitedatabase db,int o...

javascript - Deezer JS API returning Location:http://www.mydomain.com.br/dz/channel.html#token|exception|unknown -

im doing software play deezer`s songs, , im using deezer javascript api. but when use getstatus of user there error: deezer js api returning: location: http://www.mydomain.com.br/dz/channel.html#token|exception|unknown and throw exception: uncaught error has occured, please retry action or when use login, popup show following error: "you must enter valid redirect uri" what need fix errors? you have set domain of website, not whole url , work.

oracle - Get all rows from a table having a particular column value but ordered by different column value -

i having trouble formulating question, give example demonstrate. consider table as, create table abc ( pid number(10,0) not null, disp_col varchar2(100 byte), val_col varchar2(20 byte), ord_col1 number(5,2), ord_col2 number(5,2), constraint pk_pid primary key ( pid ) ); and data have is, pid | disp_col | val_col | ord_col1 | ord_col2 ---------------------------------------------- 1 | disp1 | val1 | 1 | 14 2 | disp2 | val26 | 2 | 22 3 | disp1 | val8 | 1 | 17 4 | disp1 | val56 | 1 | 9 5 | disp2 | val9 | 2 | -10 6 | disp3 | val12 | 2 | 20 7 | aisp1 | val7 | 2 | -3 now based on descending ordering of ord_col1, ord_col2, want unique disp_col values , rows of disp_col value follow. data should like, pid | disp_col | val_col | ord_col1 | ord_col2 ---------------------------------------------- 2 | disp2 | val26 | 2 | 22 5 | ...

How to convert tag names and values from XML into HTML using Perl -

is there way convert simple xml document html using perl give me table of tag names , tag values? the xml file output.xml this <?xml version="1.0"?> <doc> <gi-estb-mib-nph> <estbgeneralerrorcode.0>integer: 0</estbgeneralerrorcode.0> <estbgeneralconnectedstate.0>integer: true(1)</estbgeneralconnectedstate.0> <estbgeneralplatformid.0>integer: 2076</estbgeneralplatformid.0> <estbgeneralfamilyid.0>integer: 25</estbgeneralfamilyid.0> <estbgeneralmodelid.0>integer: 60436</estbgeneralmodelid.0> <estbmocamacaddress.0>string: 0:0:0:0:0:0</estbmocamacaddress.0> <estbmocanumberofnodes.0>integer: 0</estbmocanumberofnodes.0> </gi-estb-mib-nph> </doc> i trying create html looks this 1. estbgeneralplatformid.0 - integer: 2076 2. estbgeneralfamilyid.0 - integer: 25 3. i trying use code web having har...

jquery - Can I use a split in replace? -

i have html looks this: <div id=lw> <div class=lw> <ul id=lwe> <li class=lwe> <div class=lwn> <span class=lwn0>jul 1 - sep 6 </span> i care "jul" part of contents of span . trying see span has "jul", replace "july". i'm trying shave off " - sep 6" using split() on span class, , replacing old html text new. code: var = $(".lwn0").text(); var rep = $(".lwn0").html().replace(a, a.split(' - ')[0]); $(".lwn0").html(rep); that's not working. i'm not sure why. is legal use split() inside of replace() ? you're using replace on html instead of text. this should work: var rep = a.replace(a, a.split(' - ')[0]);

graphics - R ggplot geom_text Aesthetic Length -

i'm working big data setcontaining 1 dummy variable , factor variable 14 levels- sample of have posted here . i'm trying make stacked proportional bar graph using following code: ggplot(data,aes(factor(data$factor),fill=data$dummy))+ geom_bar(position="fill")+ ylab("proportion")+ theme(axis.title.y=element_text(angle=0)) it works great , almost plot need. want add small text labels reporting number of observations of each factor level. intuition tells me should work labels<-c("n=1853" , "n=392", "n=181" , "n=80", "n=69", "n=32" , "n=10", "n=6", "n=4", "n=5", "n=3", "n=3", "n=2", "n=1" ) ggplot(data,aes(factor(data$factor),fill=data$dummy))+ geom_bar(position="fill")+ geom_text(aes(label=labels,y=.5))+ ylab("proportion")+ theme(axis.title.y=element_text(angle=...

python - Confirm changes made by user -

i want registered users have ability change existing data.. make sure don't mess it, want ability check new data before commiting db. how can nice possible, me , admins need 1 click reject/accept updated data? this job can implement workflow systems similar viewflow or goflow , others, in way added/changed data saves on database waiting confirm workflow master actors.

ionic framework - cordova-plugins-file-transfer from npm prevent deviceready to fire -

when using phone gap build deviceready event not fire when using newest cordova-plugins-file-transfer (1.2.0). i'm using cordova-plugins-file npm (2.0.0 or 2.1.0). if remove cordova-plugins-file-transfer line config.xml , rebuild app, deviceready event fires normal. can explain going on? works fine when when use ios emulator.

css - Unexpected behavior changing inline-block and float with media query -

Image
i'm creating responsive page 3 elements. left 2 elements set display:inline-block they'll appear side-by-side. third element set float:right align right side of page instead of being inline other 2 elements. have css media query makes 3 elements display vertically when window less 600px wide. when shrink window smaller 600px , stretch out wide again, third element not display @ top of page. floats right side of page, there space @ top if it's placed below other 2 elements. i see behavior on mac in chrome 43 , safari 7.1.6, not in firefox 38.0.5. why happen? there remedy? i realize there other ways structure layout avoid issue. i'm more interested in why behavior occurs in alternate methods, since seems happen in specific browsers. here's illustration of issue: please see demonstration below. use "full page" button can resize window test media query. div#image { display: inline-block; vertical-align: middle; width: 30%; ...

regex - Python - Split url into its components -

i have huge list of urls this: http://www.example.com/site/section1/var1/var2 where var1 , var2 dynamic elements of url. want extract url string var1. i've tried use urlparse output this: parseresult(scheme='http', netloc='www.example.com', path='/site/section1/var1/var2', params='', query='', fragment='') alternatively, can apply split() method: >>> url = "http://www.example.com/site/section1/var1/var2" >>> url.split("/")[-2:] ['var1', 'var2']

c# - Protect .NET code from reverse engineering? -

obfuscation 1 way, can't protect breaking piracy protection security of application. how make sure application not tampered with, , how make sure registration mechanism can't reverse engineered? also possible convert c# application native code, , xenocode costly. c# provides lot of features, , ideal language code, writing whole codebase again in c++ out of question. secure certificates can removed signed assemblies in .net. you can't. there steps can take make little more difficult, executable on local machine crackable. eventually, code has converted native machine code , every application runnable vulnerable. what want make difficult enough crack make not worth peoples' trouble. some suggestions have protect application: obfuscate code. dotfuscator has free edition , comes visual studio. use public/private key or asymmetric encryption generate product licenses. ensures you can generate license codes. if application is cracked, can ...

c++ - Efficiently storing DNA base-pair data in RAM? -

very related question: most efficient way store big dna sequence? , one: declaring new data type dna i'd find way efficiently store long sets of characters actg without wasting entire byte each value, when should require 2 bits. however, don't see descriptions in responses regarding how go storing 2-bit data in c++, or java or language matter, although figure c++ should ideal language it. so question this, syntax create conveniently usable 2-bit data type? assume sort of structure going need made fill byte-sized(lol) chunks of data, i'm not certain. i'd interested in knowing if such thing possible in other languages well, such javascript or perl, how go in c++. example code appreciated, thank you. i suggest encode data in std::bitset , store bitsets in std::vector . can code dna pair in bitset , waste 4 bits per element in vector or code 2 dna pairs in each bitset , have perfect storage.

html - Change overlapped image visibility on radio button click -

i want change visibility options 2 overlayed images radio buttons. .productbutton appears default, .productbutton_lower visibility: hidden . radio button becomes checked, .productbutton_lower becomes visible while .productbutton becomes hidden. html <strong>bottle size</strong><br/> <label class="prodbutt"> <input type="radio" class="size" value="10" name="size" required="required" /> <img src="http://i.imgur.com/vtmveab.png" class="productbutton" /> <img src="http://i.imgur.com/k9jvwfr.png" class="productbutton_lower" /> </label> <label class="prodbutt"> <input type="radio" class="size" value="30" name="size" required="required" /> <img src="http://i.imgur.com/kksv0wu.png" class="productbutton" /> <img sr...

android - How do I set a color filter on a drawable which will be used in a RemoteView? -

i have imaveview on remoteview have apply filter. when not in remoteview , works well: drawable icon = getresources().getdrawable(r.drawable.icon); icon.setcolorfilter(color, porterduff.mode.src_in); image.setimagedrawable(icon); the remoteview not appear have method me set drawable not resource. how go doing this? thanks. i had similar problem. me solution use bitmap. these 2 methods should give answer or @ least kind of solution. private void setcurrentstatus(context context, remoteviews remoteviews) { bitmap source = bitmapfactory.decoderesource(context.getresources(), r.mipmap.ic_launcher); bitmap result = changebitmapcolor(source, color.yellow); remoteviews.setbitmap(r.id.iv_icon, "setimagebitmap", result); } private bitmap changebitmapcolor(bitmap sourcebitmap, int color) { bitmap resultbitmap = bitmap.createbitmap(sourcebitmap, 0, 0, sourcebitmap.getwidth() - 1, sourcebitmap.getheight() - 1); paint ...

javascript - detect not closed html tags in a text, and fix it -

i have html text called news generated ckeditor, may contain html tags bold, italic, paragraph and.... want choose first 100 characters of , show them users of app. choosing first 100 characters of news may cause choose html text has unclosed tags(the closing tags of html text may after character number 100). there php or js function parse text , fix unclosed html tags or @ least remove unclosed html tags? as far removing tags altogether, strip_tags function in php should trick. strip_tags($input, '<br><br/>'); the second argument allowed tags (the ones don't stripped).

regex - Regular Expression to match most explicit string -

i have experience regular expressions far expert level , need way match record explicit string in file each record begins unique 1-5 digit integer , padded various other characters when shorter 5 digits. example, file has records begin with: 32000 3201x 32014 320xy in example, non-numeric characters represent wildcards. thought following regex examples work rather match record explicit number, match record least explicit number. remember, not know in file need test possibilities locate explicit match. if need search 32000, regex looks like: /^3\d{4}|^32\d{3}|^320\d{2}|^3200\d|^32000/ should match 32000 matches 320xy if need search 32014, regex looks like: /^3\d{4}|^32\d{3}|^320\d{2}|^3201\d|^32014/ should match 32014 matches 320xy if need search 32015, regex looks like: /^3\d{4}|^32\d{3}|^320\d{2}|^3201\d|^32015/ should match 3201x matches 320xy in each case, matched result least specific numeric value. tried reversing regex follows still same results: ...

Excel VBA Sentence Case Funtion Needs Fine Tuning -

Image
below function built others changes text sentence case (first letter of each sentence capitalized). function works nicely except doesn't capitalize first letter of first word. issue if sentence entered in caps, function nothing. i'm looking assistance in tweaking function correct these issues. option explicit function propercaps(strin string) string dim objregex object dim objregmc object dim objregm object set objregex = createobject("vbscript.regexp") strin = lcase$(strin) objregex .global = true .ignorecase = true .pattern = "(^|[\.\?\!\r\t]\s?)([a-z])" if .test(strin) set objregmc = .execute(strin) each objregm in objregmc mid$(strin, objregm.firstindex + 1, objregm.length) = ucase$(objregm) next end if end propercaps = strin end function thanks, gary i renamed function sentencecase() , made few more adjustments: public function sentencecase(byval str string) string ...

Controlling the brightness of the flashlight in android -

i want develop android application using penlight. when use flashlight, brightness strong. want reduce brightness of flash light. have used camera , flash mode torch. can please to reduce brightness of flashlight. thank you.. unfortunately there no reliable solution there no official android api kind of functionality. there hacky "solution" works on rooted devices. said, nothing reliable. see post .

What does `git add -A` really do? -

according the git documentation : -a --all --no-ignore-removal update index not working tree has file matching <pathspec> index has entry. adds, modifies, , removes index entries match working tree. if no <pathspec> given when -a option used, files in entire working tree updated (old versions of git used limit update current directory , subdirectories). i understood mean when run git add -a subdirectory , git doing this: $ git update-index --again $ git add subdirectory however, upon doing simple test in local dummy git repository, not update files outside of <pathspec> have been staged. in fact, can't find difference in behavior or without -a option. can explain behavior of -a option git add (the git documentation's explanations bit bitter swallow)? the --no-ignore-removal clue. means if file does not appear in working tree does appear in index - e.g. if have rm ed not git rm ed - removed index (as...

search - Searching all jpg's from all drives in a computer vb.net -

i want list jpg files drives in computer there full path. tried following code list few random files, wont search files. got here: searching drive vb.net public sub dirsearch(byval sdir string) dim fl string try each dir string in directory.getdirectories(sdir) each fl in directory.getfiles(dir, "*.jpg") listbox1.items.add(fl) next dirsearch(dir) next catch ex exception debug.writeline(ex.message) end try end sub 'form1 load event private sub form1_load(sender object, e eventargs) handles mybase.load dirsearch("c:\") dirsearch("d:\") dirsearch("e:\") dirsearch("f:\") dirsearch("g:\") dirsearch("h:\") dirsearch("i:\") dirsearch("j:\") dirsearch("k:\") 'dirsearch("so on.....") savetxtfile() end sub save searche...

datetime - cast in sql server yyyy/mm/dd instead of dd/mm/yyyy -

i have script insert 1000 rows of data in table, in datetime column have information. cast(n'2015-05-14 00:00:00.000' datetime) the problem cast trying cast in dd/mm/yyyy format input in yyyy/mm/dd format. don't use cast when converting varchar datetime , use convert instead, convert takes in date format. convert(datetime, '2015-05-14 00:00:00.000', 121) see more at: http://www.sqlusa.com/bestpractices/datetimeconversion/ its written way since have generated script of data insert, cant change 1 one, many rows insert are unable modify script? seems easy find/replace. cast(n' -> convert(datetime, ' ' datetime) -> ', 121)

java - Scanner's buffer not representative of entire file when newlines enabled -

basically, i'm doing writing file , reading later. few times looking @ buffer, , seeing lines 'cut off,' , getting concerned flushing issue. however, stumbled across this question , states: so, appears scanner not read entire file @ once...it reads file buffer - means in chunks. and see reflected in scanner. looking @ buffer size, see 1024 size. however! writing each entry separate line, passing in message , appending \n before writing. taking \n away results in interesting. when running without newlines, find buffer size has magically increased interesting 5,232, , can see entire contents of file in buffer! the way make scanner new scanner(new fileinputstream("path.txt")) , , inspect using intellij's variable inspection (that's got idea of cutting off from, wasn't able see in file) essentially, question is: why adding newlines force buffer fixed size , obey rules, , not adding newlines (meaning entire file 1 line) lets buffer whate...

javascript - grunt-contrib-concat: specify last file to be concatenated? -

i'm using grunt-contrib-concat concatenate custom js files together, , wrap them iife. i'm running load order issues ( namely, init file executing before modules, causing undefined errors ). want specify init.js should last in concat order, don't want specify order other js files well, specific 1 goes last. here current config of concat: /** * set project info */ project: { src: 'src', app: 'app', assets: '<%= project.app %>/assets', css: [ '<%= project.src %>/scss/style.scss' ], js: [ '<%= project.src %>/js/*.js' ] }, concat: { dev: { files: { '<%= project.assets %>/js/scripts.min.js': '<%= project.js %>' } }, options: { stripbanners: true, nonull: true, banner: ';(function($, window, document, undefined){ \n "use strict";', footer: '}(jquery, window, document));' } }, how specify last file...

python - How to use PIL (pillow) to draw text in any language? -

i'm rendering user input text on background image python pil(i'm using pillow). the code simple: draw = imagedraw.draw(im) draw.text((x, y), text, font=font, fill=font_color) the problem is, user may input in language, how determine font use? ps: know have have font files first, searched , found google noto , downloaded fonts, put them in /usr/local/share/fonts/ , these fonts separated language, still can't load font can render user input texts. noto (which literally adobe's source pro fonts different name because it's easier google market way) isn't single font, it's family of fonts. when go download them , google explicitly tells there lots of different versions lots of different target languages, 2 simple reasons that: if need typeset entire planet's set of known scripts, there vastly more glyphs fit in single font (opentype fonts have hard limit of 65535 glyphs per file due fact glyph ids encoded ushort fields. , fonts comp...

python - How to get grid information from pressed Button in tkinter? -

i need create table of buttons using tkinter in python 2.7, has n rows , n columns, , has no button in bottom right corner. problem when press button, in place, need create free space , move button space empty before, , cannot because don't know how grid (x , y axes) information of pressed button use create free space. this current code: from tkinter import * #input: n=int(raw_input("input whole positive number: ")) l = range(1,n+1) k = n m = n #program: root = tk() in l: j in l: frame = frame(root) frame.grid(row = i, column = j) if j == k , == m: pass else: button = button(frame) button.grid(row = i, column = j) root.mainloop() it this, wanted button grid position, , use change k , m variables make empty space in position pressed button was. you can pass row , column using lambda expression button: button = button(..., command=lambda row=i, column=j: dosomething(row, c...

javascript - Connecting Chrome Extension to StackExchange oAuth API -

Image
tl;dr -- trying build chrome extension displays number of current notifications user stackoverflow. i following chrome extension tutorial on creating extension utilizes oauth. swapping out google oauth bits (what think are) stackexchange api bits, end following in background.js file: var oauth = chromeexoauth.initbackgroundpage({ //es6 template strings! 'request_url' : `https://stackexchange.com/oauth?client_id=${stack_app.id}&scope=read_inbox,no_expiry`, 'authorize_url' : 'https://stackexchange.com/oauth/login_success', 'access_url' : 'https://stackexchange.com/oauth/access_token', 'consumer_key' : stack_app.key, 'consumer_secret' : stack_app.secret, //'scope' : '', //not sure need this... 'app_name' : 'stackoverflow notifications (chrome extension)' }); oauth.authorize(function () { console.log('authorize...'); }); when ...