Posts

Showing posts from May, 2015

css - Style Twitter bootstrap Navigation -

how people typically style output of twitter bootstrap collapsible navigation? the standard structure follows. <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <button data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar" type="button"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a href="#" class="brand">project name</a> <div class="nav-collapse collapse"> <ul class="nav"> <li class="active"><a href="#">home</a></li> <li><a href="#about">about</a></li>

Getting error while reading contacts in android development -

i'm new android development. i'm developing in eclipse , java. i'm trying read contacts , string manupulation substring() or contains (). did following steps, permission added ( ) code read contacts : cursor people=getcontentresolver().query(contactscontract.contacts.content_uri, null, null, null, null); while(people.movetonext()) { int id=people.getcolumnindex(phonelookup.display_name); string name= people.getstring(id); if(name!="") { edittext1.settext(name.substring(2,3)); } } here i'm getting error because of substring. i'm getting error if use string class methods. if assign hardcoded value in name,then i'm not getting error. ie. string name= "john"; // people.getstring(id); error messages : 08-19 22:13:03.467: e/androidruntime(4265): fatal exception: main 08-19 22:13:03.467: e/androidruntime(4265): java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=1111,

How do I track who uses my Excel spreadsheet? -

i created excel spreadsheet boss wants put on company's internal website. spreadsheet contains seldom-used, esoteric, handy functions employees within company find useful. the problem don't know future users are, , boss wants me identify uses spreadsheet. he asked password-protect excel spreadsheet in such way 1 password not unlock of copies people can download site. example, can't make password "stackoverflow" because once user legitimately gets password me, , shared other people, can used within company unlock subsequently downloaded spreadsheets. never able ascertain using spreadsheet. also, cannot modify website, hope achieve tracking of users through excel , email. is there way have excel randomly generate string, user emails me, , respond appropriate password unlock file (based off generated string)? requires user check in me before using spreadsheet (the ideal situation). is such arrangement possible in excel 2010 professional plus?

c# - GSM communication, cross threading -

i'm bit new in c# programming somehow managed pickup project requires great skill , knowledge gsm (sms) communication using serialport. using system; using system.collections.generic; using system.componentmodel; using system.drawing; using system.data; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.io.ports; namespace smsget { public partial class smslogpanel : usercontrol { #region default constructor public smslogpanel() { initializecomponent(); serialport1 = new serialport(); serialport1.databits = 8; serialport1.dtrenable = true; serialport1.encoding.equals("iso-8859-1"); serialport1.handshake = handshake.requesttosend; serialport1.parity = parity.none; serialport1.writetimeout = 300; serialport1.stopbits = stopbits.one; checklink(); } #e

database - Android-Send data from an application to a lamp Server -

i want send data android application lamp server , store data on database. don't have experience in because it's first time set lamp server , create database communicate android application. tell shortly made android app takes photo , makes ocr. want take resullt example product name , price, , send server in order store in database. searched web got little confused because saw lot of different methods in order this. so, want ask best way , how i'm going it? thank you! sending data android app no different other client can think of, call webapp, java app or other application capable of doing http request, long have proper server side code (php), catch request parameters sent http request made client, connecting database , populating values, of course important take on count 1 of authentication mechanisms available, people care can hit server , populate database. here example how http request using "get" method in android: http://sunil-android.blogs

c# - Append Error Text to Textbox -

i have sql update command runs upon button click. try/catch function , use catch function append errors may thrown textbox. possible? thanks! catch (exception ex) { tb.text += ex.message; } for read feedback typically use textblock and if want sql exceptions catch (sqlexception ex)

c# - Convert &#XXXX; character from HTML to correct format -

when html source page code in c# app string : &#1607;&#1605;&#1740;&#1606;&#1580;&#1608;&#1585;&#1740; &#1578;&#1587;&#1578;&#1740; but in web page see : همینجوری تستی now want in app when html source page code ,and when user want see , can see string in correct format ,to wit user see : همینجوری تستی in c# when string webrequest how can convert string correct format ? kind regards. you're looking webutility.htmldecode() method .

c# - How to completely clear/set text of WinRT's RichEditBox? -

how 1 overwrite or clear text (and formatting) of winrt's richeditbox? i'm asking because method settext of it's document property seems append new text. thus "binding" below: void vm_propertychanged(object sender, system.componentmodel.propertychangedeventargs e) { if (e.propertyname == "content") richeditbox.document.settext(windows.ui.text.textsetoptions.none, vm.content); } private void contentchanged(object sender, routedeventargs e) { richeditbox box = (richeditbox)sender; string content; box.document.gettext(windows.ui.text.textgetoptions.none, out content); vm.content = content; } where vm_propertychanged listens changes in content string property of viewmodel , contentchanged handler textchanged event of richeditbox, create infinite loop appending "\r" vm.content , box's text itself. when replace textgetoptions.none textgetoptions.formatrtf viewmodel's content property gets mor

python - List of all arrays not contained in other lists of arrays -

i have list of 2 dimensional points, represented 2 element long lists/arrays. e.g.: points = [[ 10. , 10. ], [ 11. , 10. ], [ 10.5 , 9.1339746], [ 10.5 , 10. ], [ 10.75 , 9.5669873], [ 10.25 , 9.5669873], [ 2. , 2. ], [ 3. , 2. ], [ 2.5 , 1.1339746], [ 2.5 , 2. ], [ 2.75 , 1.5669873], [ 2.25 , 1.5669873]] i want have list not contain elements of first list. exclude = [[2., 2.], [3., 2.], [2.5, 2.]] unfortunately new_list = [p p in points if p not in exclude] will produce [[ 10. , 10. ], [ 11. , 10. ], [ 10.5 , 9.1339746], [ 10.5 , 10. ], [ 10.75 , 9.5669873], [ 10.25 , 9.5669873], [ 2.75 , 1.5669873], [ 2.25 , 1.5669873]] instead of [[ 10. , 10. ], [ 11. , 10.

jquery - Settings values to Session Variable from Javascript -

i have shopping cart, time slot selection product delivery want display date next 1 week, first column(per day in per row), , timeslots in column, format below: column1 column2 aug 19, 2013 [radiobutton]10:00am [radiobutton]12:00pm aug 20, 2013 [radiobutton]10:00am [radiobutton]12:00pm aug 21, 2013 [radiobutton]10:00am [radiobutton]12:00pm aug 22, 2013 [radiobutton]10:00am [radiobutton]12:00pm aug 23, 2013 [radiobutton]10:00am [radiobutton]12:00pm aug 24, 2013 [radiobutton]10:00am [radiobutton]12:00pm aug 25, 2013 [radiobutton]10:00am [radiobutton]12:00pm i tried using gridview radiobuttonlist (for time slots), problem user able select time every days. alternative trying check timeslot selected @ javascript end , because want slot accessible next checkout wizard, want store selected time slot in session. able validate time slot if not selected, , value in alert, if selected. when try save value session hidden

email - Reply-To header not picking the php variable -

i creating page sends response contact form within mail reply-to not working (the variable using having value, not added within headers) here's code: <?php //$uname=$_request['uname']; if(isset($_request['name'])) { $name=$_request['name']; } if(isset($_request['email'])) { $email=$_request['email']; } if(isset($_request['phone'])) { $phone=$_request['phone']; } if(isset($_request['message'])) { $message=$_request['message']; } // testing if variables have values echo "$name $email $phone $message"; // result: true till here if($name=="" || $email=="" || $phone=="" || $message=="") { header("location:../?inst=invalid"); } else { // ---------------- send mail form ---------------- // send e-mail ... $to="mail@example.com"; // subject $subject="$name contacted via contact form"; //

excel - Cannot add DLL reference with AddFromFile -

i trying use com visible .net dll excel vba. have been successful when registering dll using regasm , manually adding reference via tools -> references menu item in vba developer window. however, trying register dll without using regasm command excel file can used on computer without registering dll. far i've tried: dim jart_instance object sub initialize() dim refpath string, x byte const refname = "jart xxx" refpath = application.activeworkbook.path & "\jart\jart.dll" activeworkbook.vbproject.references x = 1 .count if .item(x).description refname .remove .item(x) end if next .addfromfile (refpath) end end sub sub postinitialize() set jart_instance = new jart.mainjobcontrol end sub i have added reference "microsoft visual basic applications extensibility 5.3". when run above code "run-time error '48': error in loading dll". hav

mainframe - How to display the actual value of a comp variable in cobol -

i have following variable in cobol program gets value file, when read: 01 employee-number pic 09(8) comp 01 employee-number-x redefines employee-number pic x(04) i have variable in same program: 01 d-element-number pic 9(04) now, move employee-number d-element-number then write d-element-number file value read input file : 0013 0024 so value comes employee-number , employee-number-x , move value d-element-number , write variable output file. but in output file: 4660 ffff 4660 4660 decimal equivalent of x'1234' but want see like: 1234 ffff 1234 how can achieve ? i allowed change definition of d-element-number nothing else. assuming when have x'00001234' want c'00001234', have here. http://ibmmainframes.com/viewtopic.php?p=234231#234231 ignore rest of discussion now, concentrate on post. this key part: perform until x-ws-1000 > x-ws-1000-max move ws-1000-byte-tbl (x-ws-1000)

Adding multiple Loopback Alsa devices in ubuntu -

i need create virtual loopback alsa sinks in ubuntu setup. can create 1 adding following /etc/modprobe.d/sound.conf alias snd-card-0 snd-aloop options snd-aloop index=21 pcm_substreams=8 i need create multiple of these can't seem find documentation on how distinguish between virtual cards. create 20. this creates 5 loopback cards: options snd-aloop enable=1,1,1,1,1 index=10,11,12,13,14

bash - Include a file to an executable script, grab line 1 and line 2, assign them to data_holders -

assume there file named a.txt contains: aaa bbb i need create executable script that grab these 2 lines a.txt and print them in terminal. in other words when run.. ./script it needs print aaa:bbb update i need assign first line file a.txt letter "a" i need assign second line file a.txt letter "b" so can access "a" , "b" within bash script separately. you can use awk this: awk '{printf $1":"}' a.txt

html - Checkboxes within Select list -

how have checkboxes within select list? list generated xquery code, making little more complicated. i'm struggling figure out how use "input" tag here. {if( $workcount > 1 ) <form name="bentform" action="{$g:blakeroot}archive/comparison.xq" onsubmit="return mysubmit()" target="comparison"> <input name="selection" type="submit" value="compare" onclick="document.bentform.target='bentwin'"/> <br/><br/> <select name="copies" multiple="multiple" size="3" > <option selected="yes" value="all">all copies , *versions other works*</option> {for $copies in collection($g:collection)/bad[starts-with(@id , $workid)]/@id let $bad := collection($g:collection)/bad[@id = $copies] let $copyversion := string($bad/@copy), $comporder := $bad[@id = $copies]//compdate[1]/@value, $printorder :=$bad[@id

c# - Display loading while Caching image from URL -

i have code in wpf c# use load images web such: if (myimgurl != "") { var imgbitmap = new bitmapimage(); imgbitmap.begininit(); imgbitmap.urisource = new uri(myimgurl, urikind.relativeorabsolute); imgbitmap.cacheoption = bitmapcacheoption.onload; imgbitmap.endinit(); myimgcontrol.source = imgbitmap; } it works takes while before images displayed (if internet slow , all). how can have progressring (from mahapps.metro toolkit) display , enabled while image loads , disappear when image displayed? i not aware of event trigger when image being downloaded , when loaded. take @ following events in class bitmapsource (the base class of bitmapimage): downloadprogress downloadcompleted downloadfailed and note. creating bitmapimage uri , showing immediately. hence there no need set bitmapcacheoption.onload (which afaik necessary if load stream should closed after endinit ). shorten code this: if (!string.isnullorempty(myimgurl)) {

wordpress - Nginx 'rewrite or internal redirection cycle while internally redirecting' resulting in 500 -

i'm having bit of problem nginx 1.2.1-2.2 on raspbian wheezy. think started after changed index thing in sites-available/default file. here relevant files: nginx.conf user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # basic settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; index index.html index.htm index.php; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # logging settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # gzip settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_vers

MySQL: Growth in Column Value for Given Foreign Key and Specific Date Range -

i have table in database update every day amount of pins on pinterest given url (page_id). how write query return page_id largest growth given date range? typically, plan on setting @startdate = yesterday , setting @enddate = today, i'd flexibility adjust dates within query. here current schema of pins table: mysql> describe pins; +---------+---------+------+-----+---------+----------------+ | field | type | null | key | default | | +---------+---------+------+-----+---------+----------------+ | id | int(11) | no | pri | null | auto_increment | | page_id | int(11) | no | mul | null | | | date | date | yes | | null | | | pins | int(11) | yes | | null | | +---------+---------+------+-----+---------+----------------+ here desired output of query need with: mysql> [fancy-mysql-query] order pins_dayoverday desc limit 1; +-------------------+---------------------------

Serialization/Deserialization ruby object in YAML -

i'm trying understand serialization/deserialization of ruby object using yaml under 1.8.7 , 1.9+ , have few queries regarding (i can't find documentation on this) ruby 1.8.7 class element yaml_as "tag:ruby.yaml.org,2002:element" def self.yaml_new(klass, tag, val) puts "print in yaml" end end yaml.parser => syck ## parser set syck e = element.new.to_yaml => "--- !ruby/element {}\n\n" question 1: why didn't tag:ruby.yaml.org,2002:element instead of --- !ruby/element {}\n\n ? yaml.load(e) => print in "yaml" ##print statement execute ## not sure change parser in 1.8 `pysch` skipping part ruby 1.9+ yaml::engine.yamler => pysch e = element.new.to_yaml => "--- !<tag:ruby.yaml.org,2002:element> {}\n" ## see tag in 1.9+ fine question 2 : why working in 1.9+ , not in 1.8.7 ? yaml.load(e) => ## print not gettin

javascript - How can I add a custom class to the AmChart legend? -

i want wrap html tag around labels in legend. looked through documentation amlegend() , , didn't find obvious. there way this? the legend comes "amchartslegend" if prefer own classnames can access within created chart instance "legenddiv" var chart = amcharts.makechart({...}); chart.legenddiv.classlist.add('your-classname'); i hope helped :)

c# - How do I build a path containing variables? -

i want create file directory, path contains 2 variables , error. textwriter tw = new streamwriter(variable1+ "\" + variable2 + ".txt", true); tw.writeline(textbox.text); tw.close(); which correct format of path in streamwriter? well you'll have got error because "\" isn't valid string literal. however, you'd better off using path.combine - , file.appendalltext : var file = path.combine(variable1, variable2 + ".txt"); file.appendalltext(file, textbox.text); note if did still want use writer, should use using statement file handle closed if exception thrown.

MSBuild: Generate XML documentation for main project but not dependency projects -

i have .sln file several projects in it. keep simple, let's call them... projecta projectb projectc ...where main project references b , c. goal update build script generate xml "intellisense" documentation file projecta, without giving build warnings missing documentation b , c. current build script i have msbuild script includes following in build step: <propertygroup> <customoutputpath>c:\build\output\</customoutputpath> </propertygroup> <itemgroup> <projects include="projecta\projecta.csproj"> <properties>outputpath=$(customoutputpath)</properties> </projects> </itemgroup> <msbuild projects="@(projects)" /> (there multiple projects listed in itemgroup, again, let's keep simple.) when run build script, it's smart enough compile b, c, , me, though i've specified a. output appears in "customoutputpath" location. the close

c# - checking returned children in knockout js -

i using knockout display items on page. have list of groups ex: group 1, group 2,... each group in it's own div. when click on 1 of groups open , display items in group. of groups don't have items display , instead of not showing change display: "no items in group" i having trouble doing in view in javascript , thought able in knockout/jquery script view: <div class="accordion-group elements-by-item"> <div class="accordion-heading"> <a class="ui_title accordion-toggle text_x-large item_accordion_toggle" data-toggle="collapse" data-parent="#bytimeindex" data-bind="text: title() != null ? title() : identity(), attr: { 'href': '#itemcontent_' + id(), 'data-item-id': id() }"> </a> </div> <div class="accordion-body collapse state-loading" data-bind="attr: { 'id':

dump from OpenERP Python is harmless? -

i getting dump openerp, seems harmless. code serves http; dump happens when connection dropped? exception happened during processing of request ('10.100.2.71', 42799) traceback (most recent call last): file "/usr/lib/python2.7/socketserver.py", line 582, in process_request_thread self.finish_request(request, client_address) file "/usr/lib/python2.7/socketserver.py", line 323, in finish_request self.requesthandlerclass(request, client_address, self) file "/usr/lib/python2.7/socketserver.py", line 640, in __init__ self.finish() file "/usr/lib/python2.7/socketserver.py", line 693, in finish self.wfile.flush() file "/usr/lib/python2.7/socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [errno 32] broken pipe this means underlying tcp connection abruptly dropped. in case means trying write data socket has been closed on other side (by clie

Derived types are not published to consumers in MassTransit -

i having issues publishing generic messages derived types , having handler invoked using masstransit v2.8.0. if publish message of type htmlblocknewmessage , consumer never invoked. if publish servicebusmessage object , change consumer consumes<servicebusmessage>.context , consumer invoked. the code fails derived type. works parent type (servicebusmessage). types: [serializable] public class servicebusmessage { } [serializable] public class servicebusresponse { public int resultcode { get; set; } } // request [serializable] public class contentitemmessage : servicebusmessage { public string siteid { get; set; } public string pageid { get; set; } public string contentitemid { get; set; } } [serializable] public class htmlblocknewmessage : contentitemmessage { public string htmldata { get; set; } } // response [serializable] public class contentitemmessageresponse : servicebusresponse { public string name { get; set; } public string ite

http - CouchDB port 80 -

is possible run couchdb on port 80? i'm looking host couchapp , don't want users have type port number in url. when change port 80 in couchdb config becomes unavailable, , have no access on 80 or other port. have change port in local.ini file. is not recommended setup? better hosting behind reverse proxy? if so, tips on how working behind iis reverse proxy? tried using arr , url rewrite, no success. edit: first, chapter of couchdb definitive guide seems suggest ok server web apps directly couch. curious community thinks: http://guide.couchdb.org/editions/1/en/standalone.html second, installed couchdb on second machine not have iis installed on , ran on port 80 fine, suspect though i've turned off websites in iis still hogging port 80. way make iis give port 80? ok figured out. default iis listens port 80 on ips. grabs 127.0.0.1 , listens on port 80 there well, if turn of websites listening on 80. to remedy need add ip address ip listen list. defau

jQuery Mobile :: Scroll does not stop on Samsung Galaxy S3 (Android 4.0.4) -

i learning jquery mobile , did small app see list of countries , brief info. have developed scrolling list ul , li. tested app on browsers , works fine when tested on samsung galaxy s3 , google nexus, got strange observations. here observations - on samsung galaxy (android 4.0.4) - a) whenever scroll list, scrolling not stop if there no records. shows white background no records in it. b) whenever try click on list, list flickers upside or downside , opens wrong list item instead of desired list item. c) mobile's button not exit , takes mobiles app gallery. keeps moving through history of pages. on google nexus (android 4.3) - 1) scrolling works fine , stops @ end of records. 2) list not flicker upside / downside. opens desired item. 3) samsung galaxy s3, keeps moving me through history pages instead of existing me out of app. since working on google nexus, doesn't code problem not sure. can please resolve problems have been facing on samsung galaxy s3

django - settings.DATABASES is improperly configured -

total newbie here, sorry mac osx 10.8 python 2.7 (installed homebrew) postgresql 9.4(installed homebrew) psycopg2 2.5 (installed macports) django 1.0.4 (installed via python setup.py install ) i'm using this tutorial , , after starting python manage.py shell ran >>> django.db import connection >>> cursor = connection.cursor() and got following: traceback (most recent call last): file "<console>", line 1, in <module> file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/django/db/backends/dummy/base.py", line 15, in complain raise improperlyconfigured("settings.databases improperly configured. " improperlyconfigured: settings.databases improperly configured. please supply engine value. check settings documentation more details. the databases section of settings.py file looks this: database_engine = 'django.db.backends.postgresql_psycopg2' #postgresql_p

Where() method and many to many relationship with the entity framework -

i have 2 tables in database video , tags. video table has 3 fields : name, id , list of tags. tags table has 2 fields : tagname, tagid. videoviewmodel model = new videoviewmodel { videos = repository.getvideos .where(v => v.name.contains("apple")) }; now let's i've multiple videos there apple in name 1 of these has green it's tags.tagname how can proceed ? suppose have videos defined in dbcontext db , try this var result = db.videos.where(x => x.name.equals("apple")) .where(x => x.tags.count(y => y.tagname.equals("green")) == 1);

java - Which way is better for update database record? -

i have 2 method update: string query = "update mytable set name = 'new_value' id ='20' "; connection conn; preparedstatement pstate; try { conn = drivermanager.getconnection(dburl, "root", "2323"); pstate = conn.preparestatement(query); pstate.executeupdate(); } catch (sqlexception sql) { sql.printstacktrace(); } or: string query = "update mytable set name = ?" + "where id = ?"; connection conn; preparedstatement pstate; int s; try { conn = drivermanager.getconnection(dburl, "root", "2323"); pstate = conn.preparestatement(query); pstate.setstringt(1, "new_value"); pstate.setstring(2, "20"); s = pstate.executeupdate(); // if s = 1 update done } catch (sqlexception sql) { sql.printstacktrace(); } both methods update database record correctly, better? i second approach. you aren't returning anything, why create

javascript - "Add to cart" button doesn't work because of ReferenceError -

i have "add cart" button in magento theme, haven't edited stopped working. defenitely worked time ago , unfortunately didn't catch moment when things went wrong. when i'm pressing button nothing happens in frontend , see error "uncaught referenceerror: productaddtocartform not defined" in console. here button html: <button class="button btn-cart" title="Добавить в корзину" type="button" onclick="productaddtocartform.submit(this)"><i class="icon-basket"></i>Добавить в корзину</button> however, when @ page source, script in page: <script type="text/javascript"> //<![cdata[ var productaddtocartform = new varienform('product_addtocart_form'); <?php if(mage::getstoreconfig('buyshopconfig/options/ajax_add_to_cart')){?> productaddtocartform.submit = function(button, url) { if (this.validator.validate()) { var form = this.fo

css3 - Twitter bootstrap li is not aligning with upper row first item in second and other rows -

Image
can please take this link , let me know why <li class="span4"> in second , third line not aligning upper row? because first .span4 child within .thumbnails having it's default left-margin removed - you'll need target fourth .span4 , same thing - 1 option use :nth-child() pseudo-class target - e.g. .row-fluid [class*="span"]:first-child, .row-fluid [class*="span"]:nth-child(4) { margin-left: 0; } http://imageshack.com/a/img29/5830/qalb.jpg

asp.net mvc 4 - append id to actionlink jquery dialog -

Image
this i'm looking have row of items has open button should open dialog has item inside of it, can't url post correctly. in adding diagram question saw how stackoverflow pops dialog , that's need do. problem need url /controller/action?id= (id being passed in) url /controller/action?/7 or if rewrite action get /controller/action?/7 how rid of slash or post correctly? actionlink @html.actionlink("open", "additems", new { id = item.id }, new { @id = "itemdialog" }) jquery $('#dialog').dialog({ autoopen: false, width: 400, resizable: false, modal: true }); $('#itemdialog').on("click", function () { var url = $(this).attr('href'); $('#dialog').load(url, function () { $(this).dialog('open'); }); return false; }); controller: public actionresult additems(int id) { var tradeitem = in db.items

ios - compare content of UIButton Selected state -

i learning objective-c ios programming. making app has 2 round rect buttons , label. want compare values of content of buttons , output text label based on whether buttons match or not. have not been able figure out how compare content of buttons though. have model file , view controller i'll post below. thanks can provide this model.h file // matchtest.h #import <foundation/foundation.h> @interface matchtest : nsobject -(nsstring*)doesitmatch:(uibutton *)sender; -(nsstring*)doesitmatchgroup:(nsarray *)buttongroup; @end this model.m file // matchtest.m #import "matchtest.h" @implementation matchtest -(nsstring*)doesitmatch:(uibutton *)sender { nsstring* tempstring; if(sender.isselected) { tempstring = @"selected"; } else { tempstring = @"not selected"; } return tempstring; } -(nsstring*)doesitmatchgroup:(nsarray *)buttongroup { nsstring* tempstring = @"buttons: m

Is this bad use of javascript prototype? -

i have javascript module creating menu objects designed this: // original menu module function menu ( ) { alert ( "menu ( )"); } menu.prototype.init = function ( ) { alert ( "menu.init ( )"); } var menu = new menu; i wish wrap inside api so // new api containing menu ( function ( $api, window, undefined ) { $api.menu = function ( ) { alert ( "$api.menu ( )"); }; $api.menu.prototype.init = function ( ) { alert ( "$api.menu.init ( )"); }; }( window.$api = window.$api || {}, window )); var menu = new $api.menu; it appears work question whether correct? eg end duplicating each prototype function each $api.menu instance? i ask because i've used prototype first method , i'm unsure javascript doing under hood second example. there isin't difference between both in terms of efficiency, difference namespacing constructor in second example, better practice polluting g

c++ - How to flush buffer data to disk when using FFmpeg to write a mp4 file? -

i using ffmpeg write mp4 file, grab bitmap images remote ip camera , encode h.264, media container mp4 file, no problem generate mp4 file if record several minutes, problem ffmpeg never flushs buffer data disk when call method "av_interleaved_write_frame"(all encoded data in memory, never free them), when call method "avio_close(oc->pb);", flush encoded data disk, tried call method "avcodec_flush_buffers" every time after calling "av_interleaved_write_frame", no effect. newbie ffmpeg, if familiar ffmpeg, please me. thanks in advance. sean i got problem, caused never write audio frame, if want encode several bmps video file, please note: 1) don't add audio stream(add_stream). 2) don't open audio stream(open_audio). hope helps others. sean

php - Replace REGEX variable with htmlentities? -

i have following bit of code replacement in preg_replace "<div style="font-style:italic;margin:8px 6px">$2</div>" is there way wrap htmlentities() around $2? you can use preg_replace_callback() : function replace($matches) { return '<div style="font-style:italic;margin:8px 6px">' . htmlentities($matches[2]) . '</div>'; } preg_replace_callback('/pattern/', 'replace', $string);

objective c - Adopting NSSecureCoding with opaque types -

i have objective-c class needs adopt nssecurecoding transport across xpc connection. class has couple properties opaque types ( dispatch_queue_t , dispatch_group_t ). how go implementing -initwithcoder: , -encodewithcoder: in case? documentation says these object-like structures i'm assuming need converted to/from raw bytes when encoding/decoding? if case, i'm not sure methods should used this. option avoid encoding them @ , recreate them inside -initwithcoder: . there's not general solution all opaque types, mentioned dispatch_queue_t , dispatch_group_t . if dispatch queue , group private coded object, recreate them in -initwithcoder: kurt revis said. if they're shared, little bit more hairy, can work around archiving "surrogate" object, traversing object graph after decoding it, replacing references surrogate references single, newly-created "real" object. really though, sounds suspiciously anti-pattern. classes implement n

r svg-like output with lines/paths of constant size -

using mwe geom_polygon example , producing svg file. ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3")) values <- data.frame( id = ids, value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5) ) positions <- data.frame( id = rep(ids, each = 4), x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3, 0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3), y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5, 2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2) ) # need manually merge 2 datapoly <- merge(values, positions, by=c("id")) (p <- ggplot(datapoly, aes(x=x, y=y)) + geom_polygon(aes(fill=value, group=id)) + geom_path(color="white")) dev.copy(svg, "polygon.svg") dev.off() this produces svg file nicely 1 slight drawback: "borders" increase when size of picture increased (as expected). can see here ( constant border in dynamic svg grap