Posts

Showing posts from September, 2012

ruby - Rerouting to AWS hosted assets from a Heroku Rails app -

i have heroku hosted rails app has reached 300mb limit slug size , can no push heroku. fix issue, i've setup aws s3 account , want redirect assets being requested rails app new s3 location. rails app serving json files point static assets using relative url. ios app using rails json has hardcoded domain url, , appends path resources domain , requests assets needs. i want update heroku app , change asset locations without requiring update ios app in order change asset domain. so, need redirect static asset requests rails app aws server. in git repo, i've ignored assets in public folder i've moved aws server. asset files present on local machine, not part of git repo when uploaded heroku. so far i've tried changing config.action_controller.asset_host not seem work since these static assets , being returned web server before rails gets it. i tried using routes rules redirect different domain, these routes never seem captured. static files appear returned befo...

algorithm - Number of subsets of size 'k' whose sum when taken mod with 'p' gives 'x' -

given: set of size n integer elements in range [1,p] , integer k<=n suppose function f(a subset) = (sum of elements in subset)%p i need find each x such 0<=x<=p-1 how many subsets of size k have f( subset ) = x a dp solution complexity n p k trivial there n*p solution?

c - What is the full function of TCPIP_TCP_ArrayGet of Harmony Configurator? -

i read docs of tcpip module of harmony configurator it's lacking of documentation , wanna know if knows complete/detailed functionality of tcpip_tcp_arrayget function. please me out , kind me cause i'm newbie here on stackoverflow , on project i'm working on. thanks documentation tcpip_tcp_arrayget reads array of data bytes tcp socket's rx buffer/fifo. data removed fifo in process. uint16_t tcpip_tcp_arrayget( tcp_socket htcp, uint8_t* buffer, uint16_t* count ); precondition tcp initialized parameters htcp - socket data read. buffer - pointer array store data read. len - number of bytes read. returns number of bytes read socket. if less len, rx fifo buffer became empty or socket not connected. thanks help.

node.js - Images not pulled from AWS S3 to heroku nodejs app -

i have sails nodejs app running on heroku. have several images need pulled onto page i.e. logo. when had images pulled photobucket works. moved images aws s3. followed https://devcenter.heroku.com/articles/s3 . images accessible link i.e.: https://s3.amazonaws.com/kenguru/main/kglogoweb.png . not being pulled when page loaded. any suggestions appreciated.

html - Why is my website not using the fonts I specified? No access to the font? -

i using rails , have specified fonts follows: #application.html.erb includes in head: <link href='http://fonts.googleapis.com/css?family=indie+flower' rel='stylesheet' type='text/css'> #one of stylesheets includes: body{ font-family: 'indie flower', sans-serif; } i'm using bootstrap gem (which perhaps overriding above?). on development server, however, site not use fonts specified. think it's helvetica instead. doing wrong? i checked inspector, gives following information: for body says font-family: "indie flower",sans-serif; . for example, next div says same. the h3 within div says font-family: inherit; . same h5 within div . for p within div says font-family: "indie flower",sans-serif; so expect font indeed indie flower isn't. checked using font, , again text shows belief helvetica instead of font specified. what doing wrong? update: application.html.erb : <!doctype html...

objective c - how to get item from rac_sequence, reactive cocoa, ios -

i parsing needed links in header of response server. header looks like access-control-allow-origin → * age → 0 cache-control → private,must-revalidate connection → keep-alive content-encoding → gzip content-type → application/json date → sat, 13 jun 2015 15:58:56 gmt etag → w/"cb38bb07f1635fd6aba5969985bf0607" link → http://thisiscurrentlink&limit=24 ; rel="next", http://thisislastlink&limit=24 ; rel="last", http://thisisfirstlink&limit=24 ; rel="first",<>; rel="prev" server → nginx vary → accept-encoding x-total-count → 131 transfer-encoding → chunked by doing this, can links array contains links nsstring *linkheader = [(nshttpurlresponse *)operation.response allheaderfields][@"link"]; nsarray *links = [linkheader componentsseparatedbystring:@","]; then doing following links needed racsequence *sequence = [links.ra...

How can you create an iCloud Calender for an iOS app to use with swift? -

i've seen many people search user's calendars , grab first 1 that's writable , start throwing events on there. don't practice; prefer respect users little more. so how can make own calendar app use events creates? i came following function, assuming app allowed access users calendars: let eventstore = ekeventstore() func checkcalendar() -> ekcalendar { var retcal: ekcalendar? let calendars = eventstore.calendarsforentitytype(ekentitytypeevent) as! [ekcalendar] // grab every calendar user has var exists: bool = false calendar in calendars { // search these calendars if calendar.title == "any string" { exists = true retcal = calendar } } var err : nserror? if !exists { let newcalendar = ekcalendar(forentitytype:ekentitytypeevent, eventstore:eventstore) newcalendar.title="any string" newcalendar.source = eventstore.defaultcalendarforneweven...

vagrantfile - Print message after booting vagrant machine with "vagrant up" -

i need display message on completion of vagrant up command. i've tried defining function: def hello puts 'hello' end and calling , end of file: hello but prints @ beginning of output rather end. how can print message @ end? vagrant has builtin support message appear after vagrant up . add vagrantfile : config.vm.post_up_message = "this start message!" and after vm has come you'll see message in green: ==> default: machine 'default' has post `vagrant up` message. message ==> default: creator of vagrantfile, , not vagrant itself: ==> default: ==> default: start message!

php - Need help returning a json string after a successful jquery $.post() -

i posting php page returning following json encoded string {"msg":"hi {{full_name}}, <br \/>\r\n<br \/>\r\n nice meeting you."} i had added json object in <script> </script> however when run $.post() , try output data.msg says undefined . here full code $.post("mass_messaging.php",{template_id: template_id}) .done(function(data){ console.log(data.msg) //outputs undefined??? }); below snippet of html code <script> addmustacheplaceholder(); {"msg":"hi {{full_name}}, <br \/>\r\n<br \/>\r\n nice meeting you."} </script> any appreciated. you need parse json string , need object. jquery can automatically if set data type: $.post("mass_messaging.php", {template_id: template_id}, function(){}, "json") ^^^^^^ here apart not ...

hashtable - Is there an extensible open address hash table? -

i'm implementing key-value store in memory used real-time service. needs fast , low latency. because number of elements not known in advance, table should grow gradually. prefer open-address hash tables since faster chaining ones. however, open-address hash tables typically require occasional slow rehashs, during service unavailable. not acceptable. on other hand, extensible hash tables typically based on chaining, , slower open address ones. are there hash tables fast open address ones (like google's dense_hash_map) , not have large rehash overhead? one simple way use array of k small hash tables, rehash overhead can reduced 1/k. however, doesn't make sense in case, because need reduce total unavailable time rather max unavailable time. if k small hash tables used, although max unavailable time reduced 1/k, rehashs occur k times more often.

python - errors after upgrading to python3.4 on mac -

after completing upgrading python 2.7 3.4 on mac (10.10.3), can't compile codes. python 3.4.3 (v3.4.3:9b73f1c3e601, feb 23 2015, 02:52:03) [gcc 4.2.1 (apple inc. build 5666) (dot 3)] on darwin type "copyright", "credits" or "license()" more information. >>> ================================ restart ================================ >>> traceback (most recent call last): file "/users/tpmac/prebs.py", line 31, in <module> doc = file(os.path.join(subdir,f)).read() nameerror: name 'file' not defined >>> these codes working python 2.7 on system. there no builtin file in python3, has been removed use open: open(os.path.join(subdir,f)).read() it better use with when opening file: open(os.path.join(subdir,f)) fle: doc = fle.read() there comprehensive guide here on porting code python2 3

vba - Stop code from copying header -

i have been tweaking following vba code copies data sheet new sheets bases on code in column. hang not have headers code copies first line new sheets. how change code not header? sub parse_data() dim lr long dim ws worksheet dim vcol, integer dim icol long dim myarr variant dim title string dim titlerow integer vcol = 5 set ws = activesheet lr = ws.cells(ws.rows.count, vcol).end(xlup).row title = "a1:aa1" titlerow = ws.range(title).cells(1).row icol = ws.columns.count ws.cells(1, icol) = "unique" = 2 lr on error resume next if ws.cells(i, vcol) <> "" , application.worksheetfunction.match(ws.cells(i, vcol), ws.columns(icol), 0) = 0 ws.cells(ws.rows.count, icol).end(xlup).offset(1) = ws.cells(i, vcol) end if next myarr = application.worksheetfunction.transpose(ws.columns(icol).specialcells(xlcelltypeconstants)) ws.columns(icol).clear = 2 ubound(myarr) ws....

ruby - Accessing instance variable in `each` loop -

is possible this? customer1.shopping_cart.each |item| puts("#{item.name}") the item class has attr_reader instance variable name. customer1.shopping_cart.each |item| puts("#{item.name}") end this put names every item customer1.shopping_cart collection (presumably array or set) upd: bit more idiomatic syntax: customer1.shopping_cart.map(&:name).each(&method(:puts))

php - Get all of the text from a string after the first one sentence -

so using code first sentence out of string preg_match('/^([^.!?]*[\.!?]+){0,1}/', $text, $abstract); can please me on how create regular expression remaining text or text after first sentence ? thanks this should give general idea using explode() : <?php $string = 'sentence one. sentence two. sentence three. sentence four.'; $sentences = explode(".", $string); echo $sentences[0]; // echos 'sentence one' echo $sentences[1]; // echos ' sentence two' echo $sentences[2]; // echos ' sentence three' echo $sentences[3]; // echos ' sentence four' // following demonstrates how you're asking, i'm not quite // sure specific use case adapt necessary. echo $sentences[0]; // echos 'sentence one' // echo remaining sentences // start @ 1 not 0 skip first sentence ($i = 1; $i < count($sentences); $i++) { echo $sentences[$i]; } note treat '.' end of sentence may not suitable in cases, ex...

c# - how to fire a keydown or keypress event -

i want key press event fire without pressing key user. use inputsimulator.simulatekeypress(virtualkeycode.vk_u); also system.windows.forms.sendkeys.send("a"); that did not cause use var key = key.insert; // key send var target = keyboard.focusedelement; // target element var routedevent = keyboard.keydownevent; // event send target.raiseevent( new keyeventargs( keyboard.primarydevice, presentationsource.fromvisual(target), 0, key) { routedevent = routedevent } ); that make following error the name 'key' not exist in current context use using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.runtime.interopservices; using system.globalization; using system.windows.input; using windowsinput; and writ...

javascript - Duplicate a chunk of HTML code with button press using jQuery -

i trying build website has multiple choice questions. want feature enables user add question button press. after pressing button editable mcq template should appear. have done coding question this <div id="mcq"> <div id="question"> <p class="q1" data_opt="a"><b>q1.</b>what next number in series 1,2,3,...</p> </div> <div class="options"> <div id="optlist"> <p id="optid" class="opt ans" data-opt="a">4</p> <p id="optid" class="opt" data-opt="b">5</p> <p id="optid" class="opt" data-opt="c">6</p> <p id="optid" class="opt" data-opt="d">7</p> </div> </div> <div class="stats"> <ul...

php - Select multiple not working -

i have select dropdown in html won't select multiple values. here code have this: <div class="col-sm-10"> <select multiple id="cmbservice" name="cmbservice" class="form-control" > <option value="0">- select 1 -</option> <?php try{ $dbhost = "localhost"; $dbuser = "mdchadmin"; $dbpass = "123456"; $dbname = "mdch_new"; $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname); if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "select promo_number, promo_name promos status=1"; $result = $conn->query($sql); ...

Transfer folder from one SFTP server to another every day -

i have 2 different servers. use winscp transfer folder manually: i connect sftp on svr-01 -> transfer folder local machine i connect sftp on svr-02 -> transfer folder local machine svr-02 what want?: i automatically. example: in command or script, svr-01 transfer folder /opt/home/files-everyday/ svr-02 /opt/backup/ when transfer finished, delete /opt/home/files-everyday/ svr-01. this should done every day. one folder created every day date "20150613" in svr-01 , folder automatically transferred svr-02. you can use winscp scripting windows batch file: @echo off mkdir %temp%\intermediate winscp.com /log=c:\path\log.log /command ^ "open sftp://user1:password1@server1.example.com/ -hostkey=""ssh-rsa 2048 87:d6...a7""" ^ "get /opt/home/files-everyday/* %temp%\intermediate\" ^ "open ftps://user2:password2@server2.example.com/" ^ "put %temp%\intermediate\* /opt/backup/...

CSS tag to increase font size -

is there method create css tag increases font size? like: <style> p { font-size: 100%; } lrg { font-size: +40%; } </style> <p>hi <lrg>tom</lrg>!</p> in above example, default text size 100% text size of inside tag 140% (100+40). is there way receive similar results?? you can use em units: span { font-size: 1.4em; /* 40% bigger parent */ } <p>hi <span>tom</span>!</p>

objective c - iOS: SDWebImageManager not caching image -

Image
i'm creating slideshow using uiimageview , , image links in array , while @ it, learned sdwebimagemanager lets hit urls once , caches images later use. but i'm monitoring in app 1st image cached, believe, 2nd image url being hit. here's code: - (void)viewdidload { [super viewdidload]; arry = [[nsmutablearray alloc] init]; [arry addobject:@"http://adjingo.2cimple.com/content/151/image/6291.jpg"]; [arry addobject:@"http://adjingo.2cimple.com/content/151/image/6290.jpg"]; nsurl *imageurl = [nsurl urlwithstring:[arry objectatindex:0]]; __block uiactivityindicatorview *activityindicator; __weak uiimageview *weakimageview = self.imageview; sdwebimagemanager *manager = [sdwebimagemanager sharedmanager]; [manager downloadimagewithurl:imageurl options:0 progress:^(nsinteger receivedsize, nsinteger expectedsize) { // progression tracking code ...

javascript - css checkbox checked material design overlay -

i'm trying fancy material design checkboxes got stuck @ applying overlay when checkboxes checked. here example of have done far: http://codepen.io/stefancenusa/pen/rvwebb input[type="checkbox"]:checked + label { /*what should write here?*/ } what intend do: after checkbox clicked, i'd white overlay tick in center appear on colored circle. is possible? how can achieve that? thank you! fork i gave shot. hope helps. input[type="checkbox"]:checked + label:before { content: '✓'; font-size: 2em; line-height: 53px; text-align: center; display: block; position: absolute; width: 53px; height: 53px; top: 0; left: 0; color: #fff; } update: tweaked little.. you can set cool icon replace text, other font or background-image .

algorithm - Minimum exact cover of grid with squares; extra cuts -

Image
this problem appeared in challenge , since closed should ok ask it. the problem (not question itself, background information) can visually described this, borrowing own image: i chose solve optimally. that's (for decision variant) np-complete problem (it's in np, , smells exact cover, though haven't proven general exact cover problem can reduced it), that's fine, has fast in practice, not in worst case. in context of question, i'm not interested in approximation algorithms, unless provide cuts. there obvious ilp model: generate possible squares (a square possible if covers cells of grid present), introduce binary variable x_i every square indicating whether use or not, then minimize sum x_i subject to: 1) x_i integer 2) 0 ≤ x_i ≤ 1 3) every cell c (sum[j | c ϵ square_j] x_j) = 1 constraint 3 says every cell covered once. constraints 1 , 2 make x_i binary. minimum solution gives optimum solution original problem. the linear relaxation of (i...

c - How to synchronise two processes using a semaphore -

i have been asked synchronize 2 processes share integer in shared memory. synchronization done semaphore. the first process start incrementing integer 2 in steps of 2 10, when should block because integer 0 mod 5, permitting second process continue incrementing same integer 3 time, , stop when integer 0 mod 5; loop way. until 100 i wrote code , unsure whether write v(s) , p(s) successfully. first process #define keys 100 #define key 200 main() { int s, idm, *n = 0; idm = shmget(key, sizeof(int), ipc - creat | 0666); creat - sem(keys); init - sem(idm, 0, 0); n = (int *)shmat(idm, 0, 0); while (*n < 100) { *n += 2; printf(% d, *n); if (*n % 5 == 0) { v(s); p(s); } shmdt(n); } second process #define keys 100 #define key 200 main() { int s, idm, *n = 0; idm = shmget(key, sizeof(int), ipc - excl | 0666); creat - sem(keys); init - sem(idm, 0, 0); ...

php - Create Nested Array From Mysql -

i trying proper json data mysql. made lot of progress. take look; i have table below: name folder path raymala 787 01.jpg,02.jpg,03.jpg,04.jpg,05.jpg... raymala 788 01.jpg,02.jpg,03.jpg,04.jpg,05.jpg,06.jpg... falitiko 332 01.jpg... falitiko 333 01.jpg,02.jpg... my current code:making array single table cell. $rows = array(); while($r = mysqli_fetch_assoc($result)) { $rows[] = $r; } $narray = array(); foreach($rows $value){ $narray[] = array('name' => $value['name'], 'folder' => $value['folder'], 'path' => explode(",", $value['path'])); } print json_encode($narray); current json output:see name value repeating. [ { "name": "raymala", "folder": "787", "paths": ["1.jpg", "2.jpg", "3.jpg"] }, { "...

html - Why are the links in my footer including the margin-right? -

i practicing html , css skills using notepad++ , have ran problem when adding couple of links footer. problem having each link including margin-right value of 15px (i.e. white space between each link can clicked on). want able click on words direct me particular page. here html code footer: <body> <div id="footer"> <div id="footerlinks"> <a href="index.html"> <span style="color: #ffffcc"> <p class="footerlink"> home </p> </span> </a> <a href="about.html"> <p class="footerlink"> </p> </a> <a href="rooms.html"> <p class="footerlink"> rooms ...

microtime - Get Time Ticks in PHP -

consider line of code in c# ordernumber.value = datetime.now.ticks.tostring(); how same ordernumber.value in php $ordernumbervalue = microtime(); //? i try echo microtime(true) * 10000000; but result string.length difference. short length c#. from .net documentation: datetime.ticks property the value of property represents number of 100-nanosecond intervals have elapsed since 12:00:00 midnight, january 1, 0001 (0:00:00 utc on january 1, 0001, in gregorian calendar), represents datetime.minvalue. not include number of ticks attributable leap seconds. in php implemented time() : time returns current time measured in number of seconds since unix epoch (january 1 1970 00:00:00 gmt). microtime() returns time in seconds , microseconds after decimal point, has greater precision. archaic reasons, default value string, if pass true first argument, you'll nice float: rr-@burza:~$ php -r 'echo microtime(true);' 1434193280.3...

osx - Where is that folder /etc/apache2/sites-available on mac os yosemite? -

i found /etc/apache2/ , there not folder: sites-available i need config: in "apache2/sites-available/" directory edit default below <directory /var/www/> options indexes followsymlinks allowoverride order allow,deny allow xsendfilepath / </directory> how can resolve on mac os yosemite? you can add configuration directly /etc/apache2/httpd.conf . if need sites-available directory, can make under /etc/apache2/ , add include /etc/apache2/sites-available/* directive httpd.conf .

android - How to create a Java object in C++ using JNI? -

this question has answer here: use jni create, populate , return java class instance 2 answers i want initialize sip connection using native android api , qt android extras (jni) , qt. if programming in java, create sipprofile object start connection in jni (as know) can execute methods in classes. can create object of type of java class? have this? does qandroidjniobject me? this class reference: http://developer.android.com/reference/android/net/sip/sipprofile.html sample code: public sipprofile msipprofile = null; ... sipprofile.builder builder = new sipprofile.builder(username, domain); builder.setpassword(password); msipprofile = builder.build(); sample reference: http://developer.android.com/guide/topics/connectivity/sip.html update: i'm not using jni itself. i'm using "qt android extras". i used know how this. please...

python - Retrieving and Displaying a ManyToMany field in Django from a OnetoOne Class -

i trying display list of trees user can 'heart' in django , having no luck. models.py from django.db import models django.contrib.auth.models import user class tree(models.model): treeid = models.integerfield(primary_key=true) neighbourhood = models.charfield(max_length=128,blank=true) commonname = models.charfield(max_length=128, blank=true) diameter = models.floatfield(blank=true) streetnumber = models.positivesmallintegerfield(blank=true) street = models.charfield(max_length=128, blank=true) class userprofile(models.model): # line required. links userprofile user model instance. user = models.onetoonefield(user) # tree field used store user's favourite trees tree = models.manytomanyfield(tree, blank=true) views.py @login_required def favourites(request): current_user = userprofile.objects.get(id=request.user.id) tree_list = current_user.tree.all() context_dict = {'trees' : tree_list} ret...

c++ - Xlib - Problems taking an screenshot -

Image
i'm developing c++ program takes screenshot xlib . first of open display , ximage pointer xgetimage() . after can pixels xgetpixel() . returns decimal value , have convert rgb . now, simplest method save ".ppm" image. works fine something fails : some pixel's colours wrong. the ppm depth 24 bits , think problem may transparency but, ¿ problem ? ¿ how can alpha channel ? ¿ should use library opengl ? thanks!

Getting Image/File Data From WebKitFormBoundary Django Python -

request.post['name'] not work, request.body show webkitformboundary . want keep single variable. ------webkitformboundary0n4xfpxtspvthukp content-disposition: form-data; name="name" ------webkitformboundary0n4xfpxtspvthukp content-disposition: form-data; name="address"

android - Strange layout issue -

i using relative layout, , section taken it: <imageview android:id="@+id/btnlifeminus5" android:layout_width="50dp" android:layout_height="50dp" android:background="#2a80b9" android:visibility="invisible" android:adjustviewbounds="false" android:clickable="true" android:croptopadding="false" android:padding="0dp" android:scaletype="fitstart" android:layout_marginleft="0dp" android:layout_margintop="0dp" /> <imageview android:id="@+id/btnlifeplus5" android:layout_width="50dp" android:layout_height="50dp" android:background="#2a80b9" android:visibility="invisible" android:adjustviewbounds="false" android:clickable="true" android:croptopadding="false" android:padding="0dp" android...

fabricjs - How can i set a custom cursor for fabric object? -

this not drawing mode. want according condition able change cursor when on element. $('#canvasid').css('cursor','pointer'); not working me. know property library? thanks. after tests working me: canvas.observe('mouse:over', function (e) { if (e.target.get('type') == 'line') { e.target.hovercursor = 'crosshair'; } });

android - Starting activity inside fragment boundaries itself -

i want start new activity inside fragment boundaries instead of loading in complete new full screen. i tried : fragmentmanager fragmentmanager = getfragmentmanager(); fragmenttransaction fragmenttransaction = fragmentmanager.begintransaction(); intent intent = new intent(this,menufragmentactivity.class); menufragment newfragment = new menufragment(); fragmenttransaction.add(r.id.menufragment,newfragment); newfragment.startactivity(intent); fragmenttransaction.commit(); but starts activity in new screen rather in confined fragment ? the behavior you're seeing correct. for layout purposes, activities cannot "children" of fragments. it's other way around: fragments children of activities. so, basically, you're trying won't work. you should read full fragments guide if haven't already. here's relevant quote layouts: when add fragment part of activity layout, lives in viewgroup inside activity's view hierarchy , fragment ...

objective c - Can thread be used analogously with queue, or do they mean separate things? -

i reading through this great tutorial when came accross following line (as background: learning how use dispatch_apply replace for loop , concurrently download photos): be aware although have code add photos in thread safe manner, ordering of images different depending on thread finishes first. this line threw me off reason. thought dispatch_apply run task on 1 concurrent thread , globaluserinitiatedqueue , not multiple different threads. calls method saying: dispatch_apply(addresses.count, globaluserinitiatedqueue) { so globaluserinitiatedqueue 1 thread, multiple threads, , what's difference between thread , queue? seems, they're used analogously. mean concurrent queue has multiple threads running @ same time? thanks - from guide: "concurrent queues (also known type of global dispatch queue) execute 1 or more tasks concurrently, tasks still started in order in added queue. executing tasks run on distinct threads managed dispat...

kernel - Purpose and usage of firmware packages on Linux -

i have written firmware many micro-controllers, 8051, avr, , arm. have clear idea firmware is. recently when updating linux distro, noticed there many firmware related packages being updated, e.g. iwl3160-firmware, , iwl1000-firmware. have files .fw extension. if firmware piece of code, burnt non-volatile memory of embedded controller, these .fw files doing? is burnt respective devices' non-volatile memory @ time of system update, or dynamically loaded device's volatile program memory every time device switched on? or vendor specific proprietary codes used kernel access device? an answer specific example, iwl3160-firmware, appreciated. "firmware" has become broader , evolved code written nvm of chip more of term referring programmed middleware. i haven't inspected these files myself can't imagine being burned in. imagine drivers take high level input application level , convert operations low level hardware. thats firmware now.

javascript - jquery colorbox 'inline' modal opening for first time only -

i using jquery colorbox 'inline'. opening first time specific link. <a class="addfile inline" href="#inline_content"> <img src="img/nav-icons/icon_plis.png" alt=""> add file </a> with jquery written on $(".inline").colorbox({inline:true, width:"40%",href:"#inline_content"}); but when trying open inline content (#inline_content2) different link(s) on same page, previous inline content (#inline_content) opening. please me resolve issue. -thanks in click event $('.inline').on('click',function(e){ e.preventdefault(); $(this).colorbox({inline:true, width:"40%",href:$(this).attr("href")}); }); or can use .each(); $('.inline').each(function(){ $(this).colorbox({inline:true, width:"40%",href:$(this).attr("href")}); }); if both of them not work make specific class each anchor $(...

cloudant - how to 'flatten' the table in dashDB created by the schema discovery process (SDP)? -

i've used cloudant schema discovery process (sdp) create , populate table in dashdb. data in cloudant time series in nature: ... { "date": "20150101t00:00:00", "type": "temperature", "reading": "21" } { "date": "20150101t00:00:00", "type": "windspeed", "reading": "15" } { "date": "20150101t00:00:10", "type": "airhumidity", "reading": "51" } { "date": "20150101t00:00:10", "type": "temperature", "reading": "22" } ... when data pushed dashdb, maintains similar structure, i.e. date | type | reading ------------------+---------------+--------- 20150101t00:00:00 | temperature | 21 20150101t00:00:00 | windspeed | 15 20150101t00:00:10 | airhumidity | 51 20150101t00:00:10 | temperature | 22 however, data in ...

php - How to add a new file in common folder in opencart -

i want add new .tpl file in opencart's common folder. see there 12 files in common folder , define in home.tpl file , home.php file header,footer, breadcrumb, column_left,column_right , on. so how add new file in common folder , define show content in website home page.

vb.net - Ignore max length property on ADO.NET DataTable -

i create datatable using dataset tool in vb.net. i'm facing problem maxlength property, auto generated when created. is there anyway ignore property? kept getting .net exception length violation. or there other way modify property quick, mean without open each table , modify each column using designer? as zohar peled stated: no can't. if datatype of field equires set maxlength, applicable law field - no exceptions. to save time of manual edit, fetch tables datasource sql query, loop through tables , then, if field exists within given table, execute alter table command edit field-propertys. depending on amount of affected tables, open-db-and-do-it-by-hand-method might faster , simpler.

ruby - Getting Load error -- watir-webdriver on Mac Yosemite -

i have ruby 2.2.2, have watir-webdriver gem installed, when run following script require 'rubygems' require 'watir-webdriver' browser = watir::browser.new :firefox it gives in `require': cannot load such file -- watir-webdriver(loaderror) /system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' i have rubymine 7.1.2 here gem list $ gem list * local gems * bigdecimal (1.2.6) bundler (1.10.3) bundler-unload (1.0.2) childprocess (0.5.6) executable-hooks (1.3.2) ffi (1.9.8) gem-wrappers (1.2.7) io-console (0.4.3) json (1.8.1) multi_json (1.11.1) psych (2.0.8) rake (10.4.2) rdoc (4.2.0) rubygems-bundler (1.4.4) rubyzip (1.1.7) rvm (1.11.3.9) selenium-webdriver (2.46.2) watir-webdriver (0.7.0) websocket (1.2.2) yard (0.8.7.6) please suggest do? /system/library/frameworks/ruby.framework/versions/2.0/... system library in os x yosemite . ruby 2.2 (or other version)...

How to assign a natural number to variable in Coq? -

how can assign natural number register (a register represented natural number). for example how load natural number n register k? how can compare 2 natural numbers , assign register? my thinking define inductive type n, k natural numbers i'm not sure constructors should like.... i'm doing like: inductive assign (n, k : nat) type := | load k => k | load k n => one way represent state of registers function register number stored natural number. can define register type indexed natural numbers follows: inductive register : type := r : nat -> register. this not strictly necessary, having separate type registers prevents confusion between registers , natural numbers store. state function register nat, , in empty state can consider every register hold value zero. definition state := register -> nat. definition empty_state : state := fun _ => 0. the assignment operation can implemented function takes state , returns new state specified re...

ios - How to detect privacy permission changes (Camera access for example) -

we've been there. want take photos within app, or access photos, microphone, contacts, etc... first ios must prompt user permission. in many cases user deny access. if app detects user has denied access, can navigate user app's privacy settings this: [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:uiapplicationopensettingsurlstring]]; handy. however.... i've noticed if convince user toggle switch on, app not detect changes. consider code. user prompted permission access camera (this shows first time app run). suppose user denied permission. next decide did want enable camera access after all. no problem. user taps on button brings privacy panel. user changes switch allow access. user switches app. block fires uiapplicationdidbecomeactivenotification reads permission again. not reflect user's changes (still reads denied). if app purged memory , run again, read state. not permissions behave way. instance corelocation seems detect user...

javascript - How can I list posts dynamically using jquery and json api? -

i want retrieve posts site web json api, , tried more codes no data displaying. problem? html: <div data-role="page" id="searchpage" > <div data-role="header" data-position="fixed"> <h1>news</h1> </div> <div data-role="content"> <ul data-role="listview" data-inset="true" id="searchfood"></ul> </div> js: $(document).on("pageinit", "#searchpage", function(){ $.getjson("http://www.maan-lagh.com/?json=get_recent_posts", function(data){ var output = ''; $.each(data, function (index, value) { output += '<li><a href="#">' + value.title + '</a></li>'; }); $('#searchfood').html(output).listview("refresh"); }); });

debugging - Cannot debug webview with iOS simulator, webview and xcode -

Image
execution suspends faithfully on breakpoint in webkit's debugger, few moments later, app crashes on simulator (see attached screenshot). using xcode version 6.3.2 (6d2105) ios simulator version 8.3 safari version 8.0.2 (10600.2.5, r185482) it works on actual device. update: happening in device well. console says: bool _webtrythreadlock(bool), 0x16d32e00: multiple locks on web thread not allowed! please file bug. crashing now... 1 0x2e3ba3d7 <redacted> 2 0x226a5fed <redacted> 3 0x226a36ab <redacted> 4 0x226a39ff <redacted> 5 0x225f0201 cfrunlooprunspecific 6 0x225f0013 cfrunloopruninmode 7 0x2e3b9183 <redacted> 8 0x31065e23 <redacted> 9 0x31065d97 _pthread_start 10 0x31063b20 thread_start

sql server 2012 - Parsing Dates in SQL -

i have column in database varchar. data looks this: thu, 4 jul 2013 09:18:24 thu, 11 jul 2013 10:07:01 tue, 28 jan 2014 11:38:37 fri, 26 jul 2013 14:13:42 i want able convert date can recent record. sql server 2012 onwards, can use try_parse : -- if culture argument isn't provided, language of current session used. select try_parse('thu, 4 jul 2013 09:18:24' datetime2) 'datetime2'; try_parse: returns result of expression, translated requested data type, or null if cast fails.

objective c - When implementing the VIPER pattern as described on objc.io, should care be taken to hide ReactiveCocoa as an implementation detail? -

the guide @ http://www.objc.io/issues/13-architecture/viper/#using-viper-to-build-modules highly instructive , while none of groundbreaking, thought well-done. the author suggested glue between layers ought reactivecocoa library. downloaded via cocoapods bit stuck. cannot find example of reactivecocoa + viper pattern. my question: should a) make sure not expose reactivecocoa classes in interfaces, b) expose them because of relevance, or c) not worry it? compare , b examples of detailsviewinteractorinputoutput.h /* eg */ @protocol detailsviewinteractorinput<nsobject> - (void)requestdetails; @end /* eg b */ @protocol detailsviewinteractorinput<nsobject> - (racsignal *)requestdetails; @end /* eg */ @protocol detailsviewinteractoroutput<nsobject> - (void)founddetails:(mydetails *)details; @end /* eg b */ @protocol detailsviewinteractoroutput<nsobject> - (racsignal *)founddetails; @end

node.js - How to simulate error returned from fs.readFile for testing purposes? -

Image
i new test-driven development , trying develop automated testing suite application. i have written tests verify data received successful call node's fs.readfile method, see in screenshot below, when test coverage istanbul module correctly displays have not tested case error returned fs.readfile. how can this? have hunch have mock file-system, have tried using mock-fs module, haven't succeeded. path file hard-coded in function, , using rewire call unexported function application code. therefore, when use rewire's getter method access getappstatus function, uses real fs module used in async.js file getappstatus resides. here's code testing: // check whether application turned on function getappstatus(cb){ fs.readfile(directory + '../config/status.js','utf8', function(err, data){ if(err){ cb(err); } else{ status = data; cb(null, status); } }); } here's test have written case data returned: it(...

compilation - compiling a java program with a package containing a file from a different directory -

i have packaged java program in 1 directory wants import class different directory, won't compile. trying compile command in can understand going on, don't want use ide yet. i've tried every permutation of specifying classpath on javac line, compiler refuses find main packaged java program. believe simple task, can't figure out. i've researched internet , books, can find basic compilation instructions , compilation instructions when classes located in same directory. has been 0 help. know how this? you can compile multiple .java files @ same time, if in different folders. for example, if files: project - folder1 - file1.java - folder2 - file2.java then go project folder , execute following command. on windows: javac.exe folder1\file1.java folder2\file2.java on osx/linux: javac folder1/file1.java folder2/file2.java but project becomes larger , starts including more dependencies, should consider using apache ant...

overlay - How to work in Atom Editor's view directly -

Image
what i'm trying bizarre - want add lines in views don't belong sourcecode. idea use on package allow "layers" - like, example, typing information or diff info. what i'm trying image below: notice between line 45 , 46, there gap not selectable user, nor editable - it's additional info put there. so far, tried create marker overlay, marker "floats" on text, overlaps what's written (and there goes notion of "layers"). i've tried edit dom directly, when scroll, if add lines, invalidated or scroll incorrectly (and need update cursor, gutter information , more things) is possible? there workaround? this older, understand block decorations part of atom 1.6 want. as described in blog post, "a block decoration special kind of decoration allows insert dom node before or after line, , have follow line buffer changes. can see in action running snippet below in devtools": var element = document.createelement(...

How to expand a string within a string in python? -

i have string looks this: 1 | xxx | xxx | xxx | yyy*a*b*c | xxx i want expand yyy*a*b*c part string looks this: 1 | xxx | xxx | xxx | yyya | yyyb | yyyc | xxx i have big file delimiter between these strings. have parsed file dictionary looks this: {'1': ['xxx' , 'xxx', 'xxx', 'yyy*a*b*c', 'xxx' ], '2': ['xxx*d*e*f', ..., 'zzz'], etc} and need have yyy*a*b*c , xxx*d*e*f part replaced additional items in list. how can in python 3? should expand in string before parse dictionary or after parse dictionary (and how)? you can using split , simple list comprehension: def expand_input(input): temp = input.split("*") return [temp[0]+x x in temp[1:]] print(expand_input("yyy*a*b*c")) >>> ['yyya', 'yyyb', 'yyyc']

php - Deleting using Inner Joing having FK -

i need query. this tables : table 1 - general id name last_name table 2 - user id username table1_id (this 1 references table1 ids) - fk since references on cascade, if delete table1, delete others. but don't know how query. i want first id in table2 table2.table1_id , go table1 , delete id got. delete table1 your keys on cascade, delete rows in table2 you can delete 1 row table1 same normally delete table1 id=to_delete this cascade , delete rows in table2 referenced to_delete ok; edit again delete table1 id=(select table1_id table2 id=group_to_delete) will delete row table1 id row in table2, cascade , delete rows in table2 share same key.

instantiation - In Java, how can I manipulate a variable instantiated from another class? -

i new java , making simple application. consists of 2 classes, computer , player . in player , prompt user guess 5 digit string. in computer , instantiate player class so: player number = new player(); number.getguess(); next, created loop check if computer , player's numbers match. in order this, need turn 5 digits of player's number integer. why won't java let me do: int playerdigit = integer.parseint(number.substring(i,i+1)); it keeps giving me error method .substring isn't defined. how can this? appreciated! it because trying access substring (a method of string class). in code show trying access method in class player making reference method substring (of class string put above) , should have make reference string class player . maybe be, supposing class player has name of player , number in game (it's example), this: public class player { int numplayer; string name; } and methods get , set attributes: public void setn...

multiple type of Validation through javascript -

i want validate text filed , multiple radio button field through javascript.here form code: <!doctype html> <html> <head> <title>script</title> <script type="text/javascript" src="script.js"></script> </head> <body> <form name="myform"> <table> <tr> <td> <input type="text" name="job_id" placeholder="*booking/job id no : " > </td> <td> <input type="text" name="taxi_id" placeholder="* driver id/taxi id " > </td> </tr> <tr> <td> <input type="text" name="first_name" placeholder="*first name " > </td> <td> ...