Posts

Showing posts from May, 2012

ios - Load UITabBarController from Nib -

how load uitabbarcontroller nib? for uiviewcontrollers this let viewcontroller = subclassofviewcontroller(nibname: "subclassofaviewcontroller", bundle: nil); but not find similar method load uitabbarcontroller nib any thoughts? thank you edit: not using storyboards if using storyboard let tabbarcontroller = [[uistoryboard storyboardwithname:@"main"bundle:null] instantiateviewcontrollerwithidentifier:@"subclassofaviewcontroller"]; where subclassofaviewcontroller identifier. else let viewcontroller = subclassofviewcontroller(nibname: "subclassofaviewcontroller", bundle: nil) this method fine. since uitabbarcontroller subclass of uiviewcontroller there no need of separate method here in subclass

omnet++ - Running parallel simulations (using the Command Line) -

how can run simulation different configurations? using omnet++ version 4.6 . my omnetpp.ini file looks below : [general] [config dcn2] network = dcn2 # leaf switch #**.down_port = 2 **.up_port = 16 #12 # 4 # spine switch **.port = 28 # 20 #2048 # crossconnect **.cross_down_port = 28 # 20 #2048 **.cross_up_port = 28 # 20 #2048 # set destination of packet **.number_leaf_switch = 28 # 20 #2048 # link speed #**.switch_switch_link_speed = 40 mbps **.interarrivaltime = ${exponential(.0001),exponential(0.0002),exponential(0.0003)} **.batch_length = 10 **.buffer_length = 10 sim-time-limit = 1000s i want run code different values of interarrivaltime . can neither run different configs (one after another), nor can run individual runs in parallel on separate cores. i have tried cmdev option in run configurations different runs doesn't show apart 1st one. when try mentioning number of processes more 1 first run gets simulated. cannot find out reason. con

math - Equations not displaying correctly -

how equations in link display correctly? appear $$some_maths_text$$ in browsers. http://newsroom.uber.com/2014/09/inferring-uber-rider-destinations/ thanks. try getting mathjax . javascript library can render mathematical equations. browsers need add on libraries display mathematics , mathjax popular method @ moment. other method include making static images or using mathml works in firefox.

html - Unable to shift a DIV from bottom to middle of parent DIV -

i unable shift div id="pop_ctrl" in middle of parent div id="ops" . tried vertical-align:middle it's not working. html: <div style="float:left;display:inline-block"> <div id="ops" class="utilities_div" data-type="0">&nbsp;&nbsp; <div style="display: block; color: white; cursor: pointer;" id="pop_ctrl"><i class="fa fa-plus"></i>&nbsp;&nbsp;add data</div> <ul style="display: none; position: relative; top: 0px; left: 0px; background: rgb(128, 0, 0) none repeat scroll 0% 0%; width: 100%; float: left; padding: 0px; border-radius: 10px;" id="demo_ul"> <li style="display: block; color: rgb(255, 255, 255); float: left; text-align: center; border-radius: 10px;" class="demo_li"> <div><i class="fa fa-sort-numeric-asc"></i&

java ee - NamedQuery resultList returning objects, but all values are null -

i have table in database these columns: id serial not null, name character varying(255) not null, url character varying(255) the entity: @entity @table(name = "topmenu") @xmlrootelement @namedqueries({ @namedquery(name = "topmenu.findall", query = "select t topmenu t"), @namedquery(name = "topmenu.findbyid", query = "select t topmenu t t.id = :id")}) public class topmenu implements serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.identity) @basic(optional = false) @column(name = "id") private integer id; @basic(optional = false) @column(name = "name") private string name; @column(name = "url") private string url; public topmenu() { } public topmenu(integer id) { this

How to add the Material design effect to android views? -

i using appcompat theme provide material theme versions prior lollipop. when set image resource navigation icon or menu button in toolbar , ripple effect (motion) on clicking them. when try give same icons inside toolbar, behave ordinary views, there no motion on click. how ripples created? android able create ripples on drawables provide? how can make ripples appear when use image resources in imageview ? you can create ripple setting background image in xml layout. android:background="?android:attr/selectableitembackground"

algorithm - Deletion from B-Tree - M=5 -

i'm dealing deletion in btree in specific case m=5 - - maximum number of keys in node 4 , minimum number of keys in node 2 now when deleting in btree using defensive approach (i must use one) when approach node must guarantee has 1 key more minimum required. here problem - let's have root 1 key , 2 children 2 keys each. when approach 1 of these children have guarantee has @ least 3 keys (because m=5). i have 2 ways - borrow neighbor or borrow father , merge. can't borrow neighbor has minimum of 2 keys borrowing father , merging creates node 5 keys - , it's more maximum of allowed keys (as m=5). what should in case? more - correct way treat such situation classical b-trees constrain key counts non-root nodes lie between d , 2d d. means merging of nodes possible if underflow has already occurred , other node involved in merge has minimum occupancy. separator key pulled parent node makes key count of (d - 1) + d + 1 = 2d, maximum fits node. merging

javascript - swfobject not defined error -

i'm trying detect flash support, , i'm trying proceed in answer: cross browser flash detection in javascript my code following, same error: swfobject not defined. shouldn't because i'm trying in browsers support flash (chrome , firefox). if(swfobject){ console.log("you have swfobject."); if(swfobject.hasflashplayerversion("1")){ console.log("you have flash!"); } else{ console.log("you not flash :("); } }else{ console.log("you don't have swfobject"); } is problem newest browsers? there other way detect it? mdn page on flash led me through completly diferent path: if(navigator.mimetypes["application/x-shockwave-flash"]){ var plugin = navigator.mimetypes["application/x-shockwave-flash"].enabledplugin; var description = plugin.description; var versionarray = description.match(/[\d.]+/g); var flashversionosxscriptable = 12;

How to help in debugging an app (in this case Qt based)? -

ok, first of - i'm not programmer. there apps work relies on , i'd in debugging those. consider useful bug report? kind of data ease nailing issue down? there tools use provide additional data find useful? it got me thinking after upgraded new version of 3d package , linux build on fedora 21 works rather badly. example on gnome (on xfce ok) none of popovers inside main app window (the app qt based) work. what's more interesting popovers work in floating windows of app. might imagine i'm interested in fixing , i'd send revalant info. http://i814.photobucket.com/albums/zz63/pj_pics/various/popoversbug_zpsscgat2xw.jpeg~original you'll learn 1 of greatest assets program can have when comes debugging logging. logging general information fine, exceptions gold nuggets looking when comes debugging system. you should record, minimum, the type of exception the date , time raised any additional information exception might pertinent. the callstack.

Adding spinner in new NavigationView in android design support library -

with new navigationview in android can create drawers 1 bellow (src: http://android-developers.blogspot.in/2015/05/android-design-support-library.html ) <android.support.design.widget.navigationview android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:menu="@menu/drawer"/> now each list item in drawer can defined in form of menu: <group android:checkablebehavior="single"> <item android:id="@+id/navigation_item_1" android:checked="true" android:icon="@drawable/ic_android" android:title="@string/navigation_item_1"/> <item android:id="@+id/navigation_item_2" android:icon="@drawable/ic_android" android:title="@string/navigation_item_2"/> </group> my navigation drawer contains header , list of items, 1 of these items s

php - Sort by date using Isotope, breaking down into day/months/years -

i using isotope arrange , sort bunch of elements. have buttons controlling sorting. i can't 'date' sorting work properly. have date being printed inside each element sorted , applied class of .date it. prints dd/mm/yy <span class="date"><?php the_date('d/m/y');?></span> in simplest form can sort using - getsortdata: { date: '.date', } this organise number order fine days goes wrong when comes months. how can sort sort true date rather number. i have tried using examples i've found on stackoverflow each 1 breaks isotope , elements not layout. below example of sort have work, maybe can use see need do? distance: function( itemelem ) { var distance= $( itemelem ).find('.wppl-address').text(); return parsefloat( distance.replace( /[\(\)]/g, '') ); }, have php output : <span class="date" data-date="<?php the_date('c');?>" > <?php the_d

C# Timer Interval Every 24 Hours -

i'm following tutorial on how create windows service send automated emails on web server. i've got tutorial working, however, example code executes service every 60mins, instead, i'd service executed once day, every 24 hours, @ 9am every morning. below sample code private timer scheduletimer = null; private datetime lastrun; private bool flag; public staremailservice() { initializecomponent(); if (!system.diagnostics.eventlog.sourceexists("emailsource")) { system.diagnostics.eventlog.createeventsource("emailsource", "emaillog"); } eventlogemail.source = "emailsource"; eventlogemail.log = "emaillog"; scheduletimer = new timer(); scheduletimer.interval = 1 * 5 * 60 * 1000; scheduletimer.elapsed += new elapsedeventhandler(scheduletimer_elapsed); } protected override void onstart(string[] args) {

php - How to insert image into remote database by iOS app? -

in ios app, have store image in remote database. have done blob already.but want storing path only. have tried lot failing write client side code. client side code: nsdata *imagedata = uiimagejpegrepresentation(self.imgview.image,0.2); //change image nsdata if (imagedata != nil) { nsstring *filenames = @"catttt.jpeg"; //set name here nslog(@"%@", filenames); nsstring *urlstring = @"http://localhost/insertintoimage.php"; nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init]; [request seturl:[nsurl urlwithstring:urlstring]]; [request sethttpmethod:@"post"]; nsstring *boundary = @"---------------------------14737809831466499882746641449"; nsstring *contenttype = [nsstring stringwithformat:@"multipart/form-data; boundary=%@",boundary]; [request addvalue:contenttype forhttpheaderfield: @"content-type"]; nsmutabledata *body = [nsmutabledata data];

c# - retrieve images from .NET web service stored on azure like blob -

im trying figure out how retrieve images web service connected azure thats has images stored blob.. want pointed in right direction, sure if 1 have code example helpful aswell! i have not tried code yet used google, youtube find example... no luck.. :/ i can store images in folder web service if easier? blobs accessible using standard urls. may need shared access signature access file on private blob. i can point in direction: https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/ https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-1/ your service should (if understand need): create output stream create in input stream blob object , accessed using sas connect output stream input stream there plenty of examples around doing this...

c# - ASP.NET - Model does not exist -

i'm having problems using foreach , html list in view. controller calls service returns ienumerable of number of items, , i'm trying display these items html list in view. however, i'm getting "cs0103: name 'model' not exist in current context" on line 7 of view. far i'm aware i've got right syntax displaying things model. what going wrong? i have model this: public class newsitem { public datetime publishdate { get; set; } public string title { get; set; } public string description { get; set; } public string content { get; set; } } and controller this: public actionresult index() { newsreader newsreader = new newsreader(); var newsitems = newsreader.getnewsitems(); return view(newsitems); } and view: @model ienumerable<site.services.news.newsitem> @{ layout = "~/views/shared/_layout.cshtml"; } @foreach(var item in model) { <ul> <li>@html.displayfor(m =&

ios - Buggy CATransform3D? -

edited (the example contained mistake replaced one) the following code example how work: catransform3d temp = catransform3didentity; temp.m34 = -0.002; temp = catransform3dtranslate(temp, 0, -230, 0); temp = catransform3drotate(temp, -m_pi / 5, 1, 0, 0); temp = catransform3dtranslate(temp, 0, 230, 0); the output before last line of code: (lldb) po temp (m11 = 1, m12 = 0, m13 = 0, m14 = 0, m21 = 0, m22 = 0.809017002, m23 = -0.587785244, m24 = 0.00117557053, m31 = 0, m32 = 0.587785244, m33 = 0.809017002, m34 = -0.00161803409, m41 = 0, m42 = -230, m43 = 0, m44 = 1) the output after last line of code: (lldb) po temp (m11 = 1, m12 = 0, m13 = 0, m14 = 0, m21 = 0, m22 = 0.809017002, m23 = -0.587785244, m24 = 0.00117557053, m31 = 0, m32 = 0.587785244, m33 = 0.809017002, m34 = -0.00161803409, m41 = 0, m42 = -43.9260902, m43 = -135.190613, m44 = 1.27038121) whats ...? last line of code nothing because e (it indentation matrix , multiplication should return same result) hav

openerp - Can't access Odoo on Google cloud -

i have installed odoo on google cloud (vm ware instance ubuntu 14.04 lts ) , started odoo service. seems well. but while trying access instance external ip not allowing me access. check whether ip working or not have installed apache2. can access apache2 default page external ip. have installed odoo on google cloud? on google cloud default http traffic not allowed. can access apache's default page means have allowed http traffic. may problem port. can access apache's default page because default port of apache 80 , open. if starting odoo on port default port(8069) need port. need run command on terminal using root like iptables -i input 1 -p tcp --dport 8080 -j accept after can access odoo on http://your.ip:8069 another possible option redirect port 8069 on port 80. redirect port open file /etc/rc.local using nano /etc/rc.local paste command iptables -t nat -a prerouting -p tcp --dport 80 -j redirect --to-port 8069 and reboot server using su

angularjs - How to bind title attribute value in ng-table -

i using ng-table display values in table view. message displayed in remarks column (last column of table) huge. so, displaying few character. when user hovers on cells want show entire message in tool-tip. tried set in title attribute, it's not working. sample code : http://plnkr.co/edit/i4nctnhmfxgbbx7zjxs9?p=preview <table ng-table="tableparams" class="table"> <tr ng-repeat="doc in $data"> <td data-title="'#'" sortable="doc_name">{{$index + 1 }}</td> <td data-title="'visa type'" sortable="'type'">{{doc.type}}</td> <td data-title="'country'" sortable="'country'">{{doc.country}}</td> <td data-title="'starting date'" sortable="'start_date'">{{doc.start_date}}</td> <td data-title="'expired date&

java - Why protected method is not accessible from subclass? -

consider following code snippets: package vehicle; public abstract class abstractvehicle { protected int speedfactor() { return 5; } } package car; import vehicle.abstractvehicle; public class sedancar extends abstractvehicle { public static void main(string[] args) { sedancar sedan = new sedancar(); sedan .speedfactor(); abstractvehicle vehicle = new sedancar(); // vehicle //won't compile // .speedfactor(); } } sedancar subclass of abstractvehicle contains protected method speedfactor . able call method speedfactor if referenced same class. when super class used reference method speedfactor not accessible. what reason hiding method? your sedancar class in different package abstractvehicle class. protected methods can accessed same package or subclasses. in case of sedancar : sedancar sedan = new sedancar(); sedan.speedfactor(); you calling protected method same pa

Computer Vision Application on website -

i want create website user can see how computer vision algorithm or application wotks. example, user uploads or gives link image , clicks "rgb decomposition", result 3 pictures: red, green , blue channels of original image. please, advise how create it? mean technologies should use. web hosting or cloud computing service, etc.? opencv combined python option. google pyimagesearch , find valuable resources adrian rosebrock.

php - give color to specific row of a table acc. to situation -

i created table database column name "do have passport" user answers in yes or no want user answer yes row should green , row user answer no row white can 1 tell me how can apply css table works dynamically. <html> <head> <style> table, th, td { border: 1px solid black; border-collapse: collapse; } </style> </head> </html> <?php $conn = new mysqli("localhost","root","","db_dat"); $havepassport=''; $sql="select * upload; $result = $conn->query($sql); while($row = $result->fetch_assoc()) { $havepassport.='<table>'.'<tr>'.'<td>'; $havepassport.=$row['having_passport']; $havepassport.='</table>'.'</tr>'.'</td>'; echo $havepassport; } ?> you doing wrong. while add new table html. so, if have 100 rows, 100 table

javascript - How to extract event from one source only Fullcalendar -

i have build program employees of company declare days of work, vacation, days of illness etc.. idea use fullcalendar drag , drop function make nice. on month view, drag event "work" , put days worked, simple that. what try do, extract event displayed put them in database, tried using : $('#calendar').fullcalendar('clientevents'); but event googlecalendar used display public holidays in background event. in other words, have 2 types of events, ones drag , drop, , ones put there googlecalendar on backgroundevents. simply put, how can filter event extract ignore googlecalendar? put in array event calendar, don't want google. if possible, i'd grateful hint on next step, putting events in data base. what solution extract event added hand? alright, got mate @ office. leaving answer here in case: googlecalendars events , manually added events don't have same attributs, googlecalendars ones have 'source' , 'url'

d3.js - D3 - get selected Date range on brushend -

i new d3 , using brushing on grouped bar chart http://fiddle.jshell.net/cjad3/21/ i trying range selected. listing "brushend" event , calling function brushend(). getting called returning me x-axis coordinates in numbers ([42, 318]). want in date dormat 'sat 25' 'mon 27' thanks help. this use invert method of x-scale. unfortunately, that method doesn't exist ordinal scales. luckily, jason davies, patch still around . don't messing source, adapted function: function brushend() { console.log("brushend"); var b = brush.empty() ? contextxscale.domain() : brush.extent(); console.log(b); var d = mini_x0.domain(), r = mini_x0.range(), startdate = d[d3.bisect(r, b[0]) - 1], findate = d[d3.bisect(r, b[1]) - 1]; console.log([startdate, findate]); } updated fiddle .

csv - filtered list of files in a directory -

i have files in directory following naming convention arriving daily , wish filter list of file interoperate data. have been playing regular , finding difficult match file want filter. import re fnames = ["jeexport_20150501-20150531_credit-balance-adjustment-applied_20150531183249.csv", "jeexport_20150501-20150531_external-credit-balance-payment_20150531183254.csv", "jeexport_20150501-20150531_external-payment_20150531183251.csv", "jeexport_20150501-20150531_invoice-item_20150531183255.csv", "jeexport_20150501-20150531_invoice-item-adjustment_20150531183304.csv" "jeexport_20150501-20150531_invoice-item-adjustment-tax_20150531183313.csv", "jeexport_20150501-20150531_taxation-item_20150531183240.csv"] element in fnames: m = re.match("[a-za-z]+\-[a-za-z]+|-[a-za-z]+", element) if m == 'invoice-item-adjustment': print(eleme

windows installer - How do I enforce an argument to be passed into the Shortcut from a WIX Toolset Configuration File? -

i using wix toolset create msi. i shortcut call exe "/config". how do that? essentially program is, let's say, called "program.exe". if run using cmd, want run following: program.exe /config how can set shortcuts created msi installer call above , not program.exe use arguments attribute on shortcut element set attributes want passed application: <shortcut id="applicationstartmenushortcut" name="my application name" description="my application description" target="program.exe" arguments="/config"/>

Uncheck all Check boxes in Android -

i have clear button in layout on click of want uncheck checkboxes inside linear layout listview . xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:id ="@+id/mainlayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <button android:id="@+id/btnclear" android:layout_width="wrap_content" android:layout_height="wrap_content" a

Stylizing material buttons in Android v21 -

Image
i trying maintain material design ripple effect devices lollipop , above (21+) , stylize button doesn't have large margin/space around it. example 1: buttons ripple effect margin/gap: example 2: buttons no ripple effect , without margin/gap: i want layout of exmaple 2 ripple effect used in example 1 . what styles-v21 example 1 : <?xml version="1.0" encoding="utf-8"?> <resources> ... other styles ... <style name="facebookbutton" parent="android:widget.material.button"> <item name="android:colorbuttonnormal">#ff3b5998</item> <item name="android:layout_margin">0dp</item> <item name="android:borderlessbuttonstyle">@style/widget.appcompat.button.borderless</item> </style> <style name="googlebutton" parent="android:widget.material.button"> <item name="

node.js - How do I stream large files over ssh in Node? -

i'm trying stream cat command using ssh2 module hangs @ point of execution. i'm executing cat there.txt there.txt around 10 mb or so. for example: local = fs.createwritestream('here.txt'); conn.exec('cat there.txt', function(err, stream) { if (err) throw err; stream.pipe(local).on('finish, function() { console.log('done'); }); } this stops @ 1 point. i've piped stream local stdout, , hangs after while. in actual code, pipe through bunch of other transform streams think better transferring files local system first (the files may larger 200mb). try out createreadstream serving huge files: fs.exists(correctfilepath, function(exists) { if (exists) { var readstream = fs.createreadstream(correctfilepath); console.log("about serve " + correctfilepath); res.writehead(200); readstream.setencoding("binary"); readstream.on("data", function (chunk) { res.write(chu

java - Differences between HashMap and Hashtable? -

what differences between hashmap , hashtable in java? which more efficient non-threaded applications? there several differences between hashmap , hashtable in java: hashtable synchronized , whereas hashmap not. makes hashmap better non-threaded applications, unsynchronized objects typically perform better synchronized ones. hashtable not allow null keys or values. hashmap allows 1 null key , number of null values. one of hashmap's subclasses linkedhashmap , in event you'd want predictable iteration order (which insertion order default), swap out hashmap linkedhashmap . wouldn't easy if using hashtable . since synchronization not issue you, i'd recommend hashmap . if synchronization becomes issue, may @ concurrenthashmap .

Why Kotlin needs to bundle its runtime after compiled? -

i'm trying understand underlying architecture, think getting wrong. taking tutorial here example. when do: kotlinc-jvm hello.kt -include-runtime -d hello.jar why it's needed bundle kotlin runtime jar if compiler converted code java bytecode? when write application in java, rely on of standard class libraries. java. classes (e.g. java.lang.* , java.util.* ...) included every jre, don't need package them yourself. kotlin includes own standard class library (the kotlin runtime ), separate java class library. distribute jar file can run plain old jre, need bundle kotlin runtime well. if didn't bundle kotlin runtime, user have ensure kotlin runtime on classpath when executing application. page linked gives example of scenario: compiling library if you’re developing library used other kotlin applications, can produce .jar file without including kotlin runtime it. $ kotlinc-jvm hello.kt -d hello.jar if you're targeting other k

javascript - ui-router resolve showing previous resolve result on first load, sometimes not showing at all on reloads -

so have structured this. relevant state code: resolve:{ projectpromise: ['$stateparams', 'projects', 'session', function($stateparams, projects, session){ projects.getproject($stateparams.id).success(function(data){ session.currentproject = data; }); }] } getproject: o.getproject = function(project_id, container){ return $http.get('/project/' + project_id); }; inside of relevant controller: $scope.currentproject = session.currentproject; and inside of relevant template: {{currentproject.title}} when navigate /projects/:projectid first time, shows title of correct project. if go , navigate new project, however, still shows title of first project. when refresh shows correct title. if keep refreshing after title doesn't appear @ all. i'm sure lot of problem stems not having understanding of how structure of this, call getproject , if getproject sho

mysql - How to run this complex query on millions of rows -

i have millions of rows of message.rb i have migration i'm trying run: add_index :messages, [:mm_id, :c_id, :s_id], unique: true, name: :mm_unique however migration failing because finding duplicate rows. don't care value of s_id (as long integer) , s_id , mm_id need unique in scope of c_id so need find messages mm_id not null , mm_id, s_id, , c_id have duplicate rows. then, how can write query fix quickly? i'd set random value on s_id long integer since dont care value is. your query should find duplicate rows : message.joins("inner join ( select mm_id, s_id, c_id, count(*) total_count messages group mm_id, s_id, , c_id having count(*) >= 2 ) b on messages.mm_id = b.mm_id , messages.s_id = b.s_id , messages.c_id = b.c_id" ) .where("messages.mm_id not null") .select("messages.*, b.total_count duplicate")

javascript - How to use Variables in setState in JSX -

i use variable in setstate function in jsx file react. how restructure code: var name = e.target.name; if(name == "title"){ this.setstate({ title: e.target.value}); } else if(name == "date"){ this.setstate({ date: e.target.value}); } else if(name == "amount"){ this.setstate({ amount: e.target.value}); } into (so don't repeat myself)? var name = e.target.name; this.setstate({ name: e.target.value}); the above syntax sets state of "name" , not value of "name" variable. easy: var newstate = {}; newstate[e.target.name] = e.target.value; this.setstate(newstate);

struct - Linked list in C seg faults -

having seg fault erros code posted below. new c , have been having trouble it. in main made struct node* head (pointer struct node) , assigned null. send struct node * head push function should insert user defined integers front of list. believe having issues inside push function, aprecciated. ~thanks //node.h struct node{ int val; struct node* next; }; int length(struct node *); struct node* push(struct node *, int); void print(struct node *, int); //node.c #include "./node.h" #include<stdlib.h> #include<stdio.h> int length(struct node *current){ if(current->next != null) return 1 + length(current->next); else return 1; } struct node* push(struct node *head, int num){ struct node *temp = malloc(sizeof(struct node)); temp->val = num; temp->next = head; head = temp; return head; } void print(struct node* head, int size){ printf("the list %i", size);

logging - Cannot log WinZip command line process -

i got following vbscript test code zip test files via winzip command line: dim strwinzipdir, strzipfiletocreate, strfilestozip, strwinzip, strcommand strwinzipdir = "c:\program files\winzip\winzip32.exe" strzipfiletocreate = "c:\users\ext_dirmod_01\desktop\testlog.zip" strfilestozip = """c:\users\ext_dirmod_01\desktop\facturasgra.vbs"" ""c:\users\ext_dirmod_01\desktop\test zip windows.vbs""" set objfso = createobject("scripting.filesystemobject") strwinzip = objfso.getfile(strwinzipdir).shortpath strcommand = strwinzip & " -min -a -r """ & strzipfiletocreate & """ " & strfilestozip set objshell = createobject("wscript.shell") set objexec = objshell.exec(strcommand) while objexec.status = 0 loop what want log run of zip process both successful completion , error/s appearance. in case of error want exact message winzip returns. i

Reversing a string and printing it in IA32 assembly -

so i'm trying read string, increase counter (in case, %edx) until read \n, , then, going backwards print reversed. this code: .section .data cadsal: .asciz "por favor ingrese su cadena:\n" leer: .asciz "%s" salidafinal: .asciz "la cadena introducida, invertida es:\n" imp: .asciz "%c\n" .section .bss .comm cadena,50,1 .section .text .globl _start _start: leal cadsal, %eax pushl %eax call printf addl $4, %esp leal cadena, %eax pushl %eax leal leer, %eax pushl %eax call scanf addl $8, %esp xorl %edx, %edx contar: movb cadena(%edx), %al incl %edx cmpb $0, %al jne contar leal salidafinal, %ecx pushl %ecx call printf addl $4, %esp addl $-2, %edx invertir: movb cadena(%edx), %al pushl %eax leal imp, %ebx pushl %ebx call printf addl $8, %esp decl %edx cmpl $0, %edx jge invertir movl $1, %eax int $0x80 i'm using command -nostartfiles when compiling. works, when run it, segmentation fault

c++ - how do I allocate a pointer to a class with multiple inheritance -

suppose have: class human { string choice; public: human(string); }; class computer { string compchoice; public: computer(string); }; class refree : public human, public computer { public: string findwinner(); }; int main() { human* h1 = new human("name"); computer* c1 = new computer("ai"); refree* r1 = new refree(); } this code fails compile with: in function 'int main()': error: use of deleted function 'refree::refree()' note: 'refree::refree()' implicitly deleted because default definition ill-formed: error: no matching function call 'human::human()' note: candidates are: note: human::human(std::string) note: candidate expects 1 argument, 0 provided why fail, , how can construct pointer refree ? since human , computer have user-declared constructors take argument, default constructors implicitly deleted. in order construct them, need give them argument. however, trying

swift - Object Not Passing in NavigationController -

Image
i having issue that's confusing me. converting project objective-c swift , using storyboards first time. app downloads rss data , stores title, link , pubdate in article object in coredata. when user clicks row loads article in webview. the issue having has passing article object the webview. able pass button placed on tableviewcell selecting cell causes app crash , says article object passed webview nil. if test before passing println(), shows not nil. here code using button placed on cell. @ibaction func article(sender: anyobject) { // pulling recent story display on homeviewcontroller let fetchrequest = nsfetchrequest(entityname: "article") let predicate = nspredicate(format: "feed == 'flo cycling' or feed == 'triathlete' or feed == 'velo news' or feed == 'cycling news' or feed == 'ironman'") fetchrequest.predicate = predicate let sortdescriptor = nssortdescr

theorem proving - Coq can't find subterm when using rewrite tactic -

i'm trying modified proof of compile_correct first chapter of certified programming dependent types. in version, try make use of fact progdenote fold, , use weaker inductive hypothesis in proof of main lemma in priving compile_correct . the code identical book is: require import bool arith list. set implicit arguments. inductive binop : set := plus | times. inductive exp : set := | const : nat -> exp | binop : binop -> exp -> exp -> exp. definition binopdenote (b : binop) : nat -> nat -> nat := match b | plus => plus | times => mult end. fixpoint expdenote (e : exp) : nat := match e | const n => n | binop b e1 e2 => (binopdenote b) (expdenote e1) (expdenote e2) end. inductive instr : set := | iconst : nat -> instr | ibinop : binop -> instr. definition prog := list instr. definition stack := list nat. definition instrdenote (i : instr) (s : stack) : option stack := match | iconst n => (n

javascript - AmChart.makeChart properties not having an effect -

i using makechart method of amcharts construct line chart, see jsfiddle - http://jsfiddle.net/lw7ahxwh/ the problem having of properties not changing chart, whereas others of same field are: graphs: [ { id: "sensordata1", title: "sensor 1", valuefield: "sensor5", type: "line", linethickness: 100, //the linethickness not change linecolor: "#000000" //the linecolor not change }, all parameters other linethickness , linecolor work. chartscrollbar: { updateonreleaseonly: true, graph: "sensordata1", position: "bottom", //cannot scrollbar bottom height: 100 //the scrollbar not change height number }, the chartscrollbar graph , updateonreleaseonly work, position , height appear ignored. there few other examples in j

How can I use Javascript to loop through HTML elements and remove inline attributes? -

i working online store platform doesn't provide full editing access html on page , looking vanilla js solution remove various inline styling can't remove directly. i interested in reusable function such purpose, use type of capability on project later. my solution involved creation of 2 dimensional array , 2 helper functions. hope else finds useful on 1 of projects: step 1 - setup element/node list the first part of fill application elements want work with. nested arrays have 2 values: css selector element in question, , boolean (true/false) flag indicate if element's children should have attributes removed. var element_array = [ ['.selector', true], ['.other-selector', false] ]; step 2: setup inline attribute array the next step indicate html attributes want remove each element. each entered array: var remove_attributes_array = [ 'style', 'align', 'border', 'cellpadding',

javascript - Force AngularJS to reapply a directive on a fresh element -

in 1 of project, have create canvas element events linked it. reason, created directive takes context, in context, have defined set of methods bound element. onmouseup onmousedown ontouchmove ... this working 1 canvas problems arise when have switch between multiple canvas here's template: <canvas ng-if="context" drawing-canvas="context"></canvas> and directive: mod.directive('drawingcanvas', ['nano', function (nano) { function link (scope, element, attrs) { scope.$watch(attrs.drawingcanvas, function (context) { var el = element.clone(true) element.replacewith(el) element = el context.ctx = element[0].getcontext("2d") //bind events }) return { restrict: 'a', link: link } }]) at first, didn't have replacewith part. used create fresh element without bound events of previous contexts. problem method when remove canvas. seems angularjs loo

Shutdown firefox but on next launch, one time restore session -

Image
in firefox, if restart it, come same session restored as possible. without changing preference "restore session on startup". there way addon trick on firefox? need shut down on next launch should restore session. need without changing preference of: my user has clicked button restart aurora/firefox.exe nigtly/firefox.exe im trying accomplish this. var appstartup = components.classes["@mozilla.org/toolkit/app-startup;1"] .getservice(components.interfaces.nsiappstartup); appstartup.quit(ci.nsiappstartup.eattemptquit | ci.nsiappstartup.erestart); see https://developer.mozilla.org/en-us/docs/mozilla/tech/xpcom/reference/interface/nsiappstartup#constants couple of other restart related options.

ruby on rails - How to create server (failover) redundancy and reliability solution -

i looking way redirect traffic heroku application instance else when heroku/aws experiencing downtime. i envision along these lines love feedback , other ideas. app running on heroku(or wherever) returns error. request redirect fallback url (i have far set up) this url contains clone (db included) of original application. this clone can read want avoid having sync db , forth. i reasonably efficient way of keeping dbs in uptodate every 30-60 minutes or well. not sure how this. thought docker might start more dynamic deploy. goal have redundancy , not tied using heroku app resides. am missing something? reasonable implement? taking time. [update] found this . although of light, little can use because set quite ways off 1 used. heroku paas, easy & fast server setup. when application start growing big enough, suggest change iaas virtual machine example aws, google cloud platform, azure, etc.

java - Android Studio how does R.string... work (XMLReader) -

i'm working libgdx , app multilanguage xml files. could explain me how auto-generate class files like: public final class r { public static final class attr { } public static final class drawable { public static final int ic_launcher=0x7f020000; } public static final class string { public static final int app_name=0x7f030000; } public static final class style { public static final int gdxtheme=0x7f040000; } } questions: for 0x7f040000? how xmlreader work?

Making this C array processing code more python (and even numpy) -

i'm trying head around amazing list processing abilities of python (and numpy). i'm converting c code wrote python. i have text datafile first row header, , every odd row input data , every row output data. data space separated. i'm quite chuffed managed read data lists using nested list comprehensions. amazing stuff. with open('data.txt', 'r') f: # lines list of strings lines = list(f) # convert header row list of ints , info header = map(int, lines[0].split(' ')) num_samples = header[0] input_dim = header[1] output_dim = header[2] del header # bad ass list comprehensions inputs = [[float(x) x in l.split()] l in lines[1::2]] outputs = [[float(x) x in l.split()] l in lines[2::2]] del x, l, lines then want produce new list each element function of corresponding input-output pair. couldn't figure out how python specific optimizations. here in c-style python: # calculate position pos

Facebook User vs Event (get RSVP status for user on event) -

is there better way of checking rsvp status of user (logged in our application) vs. specific event through graph api, calling /v2.3/{user_id}/events , going through events find 1 we're interested , rsvp_status field there? what i've tried, , didn't work: /v2.3/{user_id}/events/{event_id} /v2.3/{user_id}/events?event={event_id} /v2.3/{user_id}/events?event_id={event_id} calling of them, find out if user in of rsvp groups: /v2.3/{event_id}/{attending|invited|maybe|declined|noreply}?user={user_id} also fql not solution, if wants c&p existing fql answers, because that's deprecated since api v2.0 this related answer wondering efficiency on using graph api, because pulling user's events , going through them both time , resource expensive operation ok, found answer, quite simple: /v2.3/{event_id}/invited?user={user_id} currently method will return nothing, if user not yet part of event (was never invited , never attended/maybe himsel

Python Canopy kernel keeps crashing -

when restart kernel in canopy (latest version), goes loop kernel crash repeatedly, , when restarting repeatedly, not exit loop. it's annoying have when doesn't work, , i'm trying avoid having re-install. suggestions? p.s.: have contacted enthought. this did. install canopy 1.5.5 now open canopy terminal go package manager-> updates -> install 7 updates once install updates , see both kernel , 'pip' getting updated. i have not encountered 'python kernel has crashed error since then'. note: have linux os

gruntjs - Getting undefined with custom function execution in grunt task -

try execute below custom task: 'use strict'; module.exports = function(grunt) { grunt.initconfig({ log: { one: [1, 2, 3], two: "hello world", three: true, four: { five: function() { grunt.log.writeln("hi"); }, six: function() { grunt.log.writeln("welcome"); } } } }); grunt.registermultitask('log', 'log stuff', function() { grunt.log.writeln(this.target + ": " + this.data + "\n"); if (this.target === 'four') { console.log(this.data); for(var d in this.data) { console.log(this.data['five']()); console.log(this.data['six']()); } } }); grunt.registertask('default', 'log'); }; i