Posts

Showing posts from September, 2011

ios - Enable UIAlertAction of UIAlertController only after input -

i using uialertcontroller present dialog uitextfield , 1 uialertaction button labeled "ok". how disable button until number of characters (say 5 characters) input uitextfield ? add following property in header file @property(nonatomic, strong)uialertaction *okaction; then copy following code in viewdidload method of viewcontroller self.okaction = [uialertaction actionwithtitle:@"ok" style:uialertactionstyledefault handler:nil]; self.okaction.enabled = no; uialertcontroller *controller = [uialertcontroller alertcontrollerwithtitle:nil message:@"enter text" preferredstyle:uialertcontrollerstylealert]; [controller addtextfieldwithconfigurationhandler:^(uitextfield *textfield) { textfield.delegate = self; }]; [controller

javascript - What are the advantages of using arguments in functions? -

when define function why might want use argument / parameter? benefits of using arguments? how useful? explain? thanks. var playlist = [ 'i did way', 'respect', 'imagine', 'born run', 'louie louie', 'maybellene' ]; function print(message) { document.write(message); } function printlist (list) { var listhtml = '<ol>'; (var = 0; < list.length; += 1) { listhtml += '<li>' + list[i] + '</li>'; } listhtml += '</ol>'; print(listhtml); } printlist(playlist); why have arguments been used in example above? arguments let apply same logic different data, meaning can re-use code. if don't use arguments there limitation on re-usability of functions or methods, can produce same output repeatedly, same how asking question on , on again no new information give same answer. in example, printlist function written such that, if wanted, generate mu

vb.net - While I'm debugging and clicked a button then "InvalidCastException was unhandled" is going to popup -

Image
my code doesn't have error, when try click button happens. can guys guess what's error? look @ photo you should swap second , third argument call msgbox. error occurs second argument should msgboxstyle , you're providing string ('ilist'). take @ documention on msdn more information.

laravel - update parent timestamps when updating child model in polymorphic relationship -

in laravel 5.1 have 2 models.a city model , photo model. there polymorphic relation between city , photo. while updating city's photo with $city->photos()->updateorcreate($attributes,$values) the child time stamps updates. parent model's timestamp , city in case, not update accordingly , should manually call $city->touch() how can update parent model's timestamp when touching child model in laravel? for polymorphic relations class photo extends eloquent { protected $touches = ['city']; public function city() { return $this->morphto() // add function if not done } } class city extends eloquent { public function photos() { return $this->morphmany(app\photo::class, 'city'); } } in case, when photo updated, touches parent (city in situation). hope helps.

Build Java ver error on Android Studio -

i hoping shed light on following build error when trying launch project in android studio imported form eclipse: error:execution failed task ':diveapp:dexdebug'. com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command '/library/java/javavirtualmachines/jdk1.7.0_11.jdk/contents/home/bin/java'' finished non-zero exit value 2 i running on os x yosemite 10.10 , running java 8.0 update 60 (build 1.8.8_60-b27). url above seems reference jdk1.7.0_11jdk, not sure if issue or how check. cheers look @ gradle console log, see exact error. most of time because added same package few times - library different modules or in different places. if not - try clean - rebuild project. p.s. can change jdk project in file -> project structure also, there answers question error:execution failed task ':app:dexdebug'. com.android.ide.common.process.processexception

html - How do I link an external css to overwrite bootstrap css for centering elements? -

i'm having hard time making websites responsive downloaded basic template , navigation sample bootstrap, i'm wondering how edit navigation bar? because multiple css folders. tried creating new css file , editing through there can't seem make work. i'm trying making text centre in container/wrapper (i'm not sure called, each word in box , centre word in box html: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- above 3 meta tags *must* come first in head; other head content must come *after* these tags --> <title>example</title> <!-- bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="navbar.css" rel=&q

ios - Saving AnyObject to NSUserdefaults -

this question has answer here: attempt set non-property-list object nsuserdefaults 7 answers i'm working on swift application interacts shopify api through mobile buy sdk . i'm having issues saving cart device. else works fine, when use following code save cart device: func savecart() { nsuserdefaults.standarduserdefaults().setobject(cart, forkey: "cart") println("cart saved") } i receive following error: terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'attempt insert non-property list object <buycart: 0x7fb5e30512f0> key cart' from nsuserdefaults class reference: the nsuserdefaults class provides convenience methods accessing common types such floats, doubles, integers, booleans, , urls. default object must property list, is, instance of (or collections c

r - adding a layer to the current plot without creating a new one in ggplot2 -

in basic r can add layers existing plot without creating new one. df <- data.frame(x = 1:10, y = runif(10)) plot(df, type = "l") points(df, add = t) the second line creates plot , third line adds points existing plot. in ggplot2: my_plot <- ggplot(df, aes(x, y)) + geom_path() my_plot my_plot + geom_point() the second line creates plot , third 1 creates plot. can somehow add points existing plot created second line? there add=true in ggplot? the reason want behaviour using ggplot2 in shiny causes blinks in animations. here idea. keep plot reactivevalue , have observer update plot user inputs. then, have observer watch plot data render plot when plot data changes. way long calculations happen before plot data changed, rendering of plot should happen there should little visible interrupt. here example using diamond dataset ggplot2 large enough slow when rendering paths. shinyapp( shinyui( fluidpage( sidebarlayout(

Google Reverse Geocoding - Urban/Rural flag, and Road Type -

would happen know if possible obtain or derive following pieces of information google reverse geocoder api? urban flag i know whether given point within urban or rural zone/area. road type i know road type of given point if point on road. know whether major highway, secondary highway, or regular street. thanks!

javascript - Unable to change background of navbar on scrolling? -

i new web-dev , trying change background color transparent blue upon scrolling. using bootstrap. tried using javascript code didn't work $(document).ready(function(){ var scroll_start = 0; var startchange = $('#startchange'); var offset = startchange.offset(); if (startchange.length){ $(document).scroll(function() { scroll_start = $(this).scrolltop(); if(scroll_start > offset.top) { $("nav.navbar div.container-fluid").css('background-color', '#f0f0f0'); } else { $("nav.navbar div.container-fluid").css('background-color', 'transparent'); } }); } this html code using <nav class="navbar" data-spy="affix"> <div class="container-fluid"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" dat

c++ - How to dynamically create elements in VTK? -

i've been trying create primitives text input file in vtk. means, input file example: cube s x y z sphere r x y z cube s x y z cone r h x y z where have name of element , attributes such position, radius, etc, depending on primitive. have done far put 1 actor each primitive in same rendered scene. program draw cube, sphere , cone based on example above. want accomplish dynamically draw whatever input says. i supposse have create actor every object in scene. don't know how many objects input indicates before running it. thinking list of actors (because can push many actors list input says), i'm not sure if it's neccessary. need big on here. ty what need vtkactorcollection . think of list of actors. supply number of actors (the number of premitives), , iterate through collection , connect suitable source it.

Twisted adbapi fetchone -

if use runinteraction of twisted's adbapi, , within function call like curs. execute("select id mytable name='bob'") id = curs.fetchone()[0] am guaranteed id select or 1 of other deferred threads? deferreds thread-safe can guarantee. example code lookslike: def _getage(txn, user): # run in thread, can use blocking calls txn.execute("select * foo") # ... other cursor commands called on txn ... txn.execute("select age users name = ?", user) result = txn.fetchall() if result: return result[0][0] else: return none def getage(user): return dbpool.runinteraction(_getage, user) def printresult(age): if age != none: print age, "years old" else: print "no such user" getage("joe").addcallback(printresult) this official docs . didn't remove row more clear , teaching.

Can I marshal List<? extends BaseObject> to json with Moxy (Jersey 2.17) out of box? -

jersey 2.17 moxy. model: @xmltype(name="product.product") @xmlaccessortype(xmlaccesstype.field) public abstract class product { } @xmltype(name="product.paperproduct") @xmlaccessortype(xmlaccesstype.field) public class paperproduct extends product { } @xmltype(name="product.woodproduct") @xmlaccessortype(xmlaccesstype.field) public class woodproduct extends product { } resource find paperproduct: @get @path("paperproduct") public response findpaperproducts() { list<paperproduct> products = findservice.findpaperproducts(); genericentity genericentity = new genericentity(products, new parameterizedtypeimpl(list.class, paperproduct.class)); return response.ok(genericentity, responsemediatype).build(); } json result (good): [ { "@xsi:type" : "product.paperproduct", "name" : "note book", }] resource find products, including woodproduct: @get @path("product"

Impossible to add a footer to a ScrollView - android -

Image
i'm working on mobile app , have problem when try put footer under scroll view. here code: <relativelayout android:id="@+id/relativelayout01" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <relativelayout android:layout_alignparentbottom="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/bottomcontent" android:orientation="vertical" android:background="@drawable/border"> //the footer added dynamically </relativelayout> <scrollview android:layout_weight="1" android:id="@+id/scroller" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillviewport="tru

algorithm - Get interval of binary search tree as fast as sorted array -

currently implementing bst in java university project. know, bst quite in searching single unit o(log n) in balanced tree. but how perform search between value a , b ? (a < b) let's have tree │ ┌── 125 │ ┌── 122 │ │ └── 120 │ ┌── 117 │ │ │ ┌── 113 │ │ └── 112 │ │ └── 108 │ ┌── 86 │ │ │ ┌── 85 │ │ └── 72 └── 59 │ ┌── 56 │ ┌── 52 │ ┌── 47 │ │ │ ┌── 43 │ │ └── 39 │ │ │ ┌── 38 │ │ └── 36 └── 28 │ ┌── 18 │ ┌── 15 └── 2 └── 1 i want create method range(a,b) return value between a , b inclusive. (note: a , b not necessary in tree!) for example: range(53,112) return 56,59,72,85,86,108,112 here pseudo code /* recursive method */ range(a,b) range(a,b,root); /* helper method */ range(a,b,node) if (a <= node.value <= b) if (node.left != nul

git - What's the best practice to create an enterprise version of the community project and sync up code with community project? -

Image
there community project has master branch development, , want make copy of our version. we want add our private code our version of project , want rebase/merge community code our version. (the private code not useful community , community not accept private code) the rules are: all bugfix patches submit community master branch. all feature patches first submit community master branch, if not accepted, submit our repo. so, how handle case? what's best practice create enterprise version of community project , sync code community project? thanks. =============================

javascript - Hide an input value on the Front end While maintaining the value on the Back -

i trying hide input value. want use input text type sort of password input field. dont want values displayed though. how go hiding value after insertion has been made? values hidden. i have tried few methods no luck. still need access in jquery/ajax can pass sql password verification. appreciated. thanks html <input type=text id=num1 onclick="hidevalue()"> javascript function hidevalue(){ document.getelementbyid('num1').value.visibility="hidden"; } you need tell theat password field. <input type="password" id="num1">

networking - are 5G and 5Ghz wifi Router is same? -

sorry all, newbie here.. maybe it's stupid question, read wikipedia , other source still don't answer... are 5g (mobile network article: http://www.fiercewireless.com/tech/story/china-south-korea-commit-5g-leadership-while-japan-and-us-rely-private-effo/2014-06-08 ) , 5ghz ( new wifi http://www.cnet.com/news/5g-wi-fi-802-11ac-explained-its-cool/ ) same? if it's same, how inference in 5g? increase? not same. 5g refers mobile / cellular technology runs on licensed frequency. technology still under research, there's nothing solid yet, seems fcc targeting 24ghz frequencies purpose. same article mentions samsung's research in 28ghz frequency range. 5ghz routers run on 1 (or more) 5ghz unlicensed frequencies. no overlap.

java - NoClassDefFoundError on implementing Runnable class in android studio -

i keep getting noclassdeffounderror on code. here code: handler.postdelayed(check = new runnable() { @override public void run() { if (foreground && paused) { foreground = false; log.i(tag, "went background"); (listener l : listeners) { try { l.onbecamebackground(); } catch (exception exc) { log.e(tag, "listener threw exception!", exc); } } } else { log.i(tag, "still foreground"); } } } , check_delay); the error occurs on assigning new runnable() check i tried separating runnable , , tried no success final runnable temp = new runnable() { @override public void run() { if (foreground && paused) { foreground = false; lo

php - How to get some portion in the url? -

i working in php. want portion of url using php, for example, url " http://localhost:82/index.php?route=product/product&path=117&product_id=2153 ". want route=product/product only. since variable might not exist, (and should) ensure code not trigger notices with: <?php if (isset($_get['route'])) { $route = $_get['route']; }else{ // fallback behaviour goes here } alternatively, if want skip manual index checks , maybe add further validations can use filter extension: <?php echo filter_input(input_get, 'route'); you can read using $_request below: <?php echo $_request['route']; ?>

javascript - Best way to show new notifications -

i'm developing system there notification section icon have high light icon if new notification arrive. first solution wanted use domnodeinserted container div of notification pane. method deprecated. second option implement timer checks whether dom count increase , according highlight icon. is there better way implement scenario using javascript. that event deprecated in favor of mutation observers supported modern browsers. https://developer.mozilla.org/en-us/docs/web/api/mutationobserver // select target node var target = document.queryselector('#some-id'); // create observer instance var observer = new mutationobserver(function(mutations) { mutations.foreach(function(mutation) { console.log(mutation.type); }); }); // configuration of observer: var config = { attributes: true, childlist: true, characterdata: true }; // pass in target node, observer options observer.observe(target, config); // later, can stop observing observer.disconnect(

node.js - blocking code in non-blocking http server -

for example, have http server, node.js, non-blocking. for each request db operation. what cannot understand difference between blocking db operation , non-blocking db operation? since web server non-blocking, blocking db operation inside request makes no difference? here's analogy might understand. let's suppose you're in sales , have 50 phone calls make today. in blocking model, place call and, if person isn't ready talk you, have sit on line , wait , wait until ready talk you. when ready talk you, have conversation, hang , can make next call , repeat process. so, time phone busy , not able make calls sum of time waiting client ready talk plus time talked. in non-blocking model, place call , if person not available, leave quick message , call when ready talk. hang leaving message , call next client. total time phone busy time leave quick message , time talk when call back. doesn't matter if call in 1 minute or 3 hours - not affect over

java - How can I get old String object value once current object modified -

if string immutable object , whenever modify string object create instance i.e. in memory have 2 objects currently. how can value of first initialized value? public class mutablevsimmutable { public static void main(string[] args) { string str1 = new string("dilip"); system.out.println(str1.hashcode()); str1 = str1 + " singh"; system.out.println(str1.hashcode()); **// here want first initialized value of "str1" i.e. "dilip"** } } string immutable in java when manipulate string,a new object created , reference previous object lost.there no way recover it.java provides stringbuffer , stringbuilder deal kind of situation.important thing note no new object created when manipulate stringbuilder object.you can use stringbuilder str1 = new stringbuilder("dilip"); system.out.println(str1.hashcode()); str1 = str1 + " singh"; system.out.println(str1.hashcode());

devops - Bluemix project owner change -

if employee owner of bluemix devops project leaves company, can , how change owner of project replacement? it possible have several administrators , transfer ownership of projects. there basic overview of account management devops . if scenario employee administrator (like sole superuser leaving company) need contact bluemix account management solution.

angularjs - How to Display Enum value in Kendo grid By using Angular js? -

everyone.my question how display enum value kendo grid colummn? right passed is. requirement reduce code , use enum var leveltype = function myfunction() { na = 0,`enter code here` speechrecognition = 1,`enter code here` transcriptionist = 2, review = 3, superproof = 4, preaudit = 5, formatter = 6, postaudit = 7, customer = 8 } directly , provide enum type value in kendo grid. using angular function please answer should in angularjs. how can reduce template code , directly assign value of enum kendo grid . enter code here thanks but want reduce code of template , kendo grid display api value .i want put condtion if 1 come api display value enum type corresponding 1. columns: [ { template: "<div class='mdi-device-access-time' id='red-clock'> </div> #=stattype#" +

c++ - How to: copying an instance of a class without a proper default constructor; that has members without a default constructor? -

// b doesn't have default constructor. class { public: a(important resource) : b(resource) {} b b; }; reading rule of three figure out issue copying instances of class vector. so issue we're generating instances inside loop: std::vector<a> some_vector(0); (int = 0; < 7; i++) some_vector.push_back(a(resources[i])); from see valgrind, smells copy constructor mucking things up. when change code to: std::vector<a*> some_vector(0); (int = 0; < 7; i++) some_vector.push_back(new a(resources[i])); the issue alleviated. don't doing though when not needed. i'm thinking, how copy constructor know when attempting copy class without proper default constructor right? for elements of type t pushed std::vector in c++, t must meet requirements of copyassignable , copyconstructible. this means must have working move or copy-constructor used when creating new objects. not need default constructor in general, operations may req

wpf - How To Use ReportViewer -

//declare object reportviewer rv = new reportviewer(); error 1 the type 'system.windows.forms.usercontrol' defined in assembly not referenced. you must add reference assembly 'system.windows.forms, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089'. c:\users\dsingh\documents\visual studio 2012\projects\rd\rd\mainwindow.xaml.cs 27 13 rd your error answers question, try adding windows forms assembly. follow following steps right click on project in visual studio click on add reference option click on .net tab scroll system.windows.forms component name click on add reference and don't forget add reference in window or page start tag. follow link provided in below comment fredrikredin

python - saving search results as text instead of list -

Image
i using django 1.8 , working on blog application. when search tweets( name instead of posts) , want save search results obtained after querying database, text instead of list. view function below: def search(request): query = request.get.get('q','') if query: qset = ( q(text__icontains=query) #q(hashes__icontains=query) #q(artist__icontains=query) ) results = tweet.objects.filter(qset).distinct() else: results = [] number_of_results = len(results) search_item = query returned_items = [] res in results: text = res.text returned_items.append(text) returns = returned_items[:] search = search(search_item=search_item,returns=returns) search.save() context = {'query':query,'results':results,'number_of_results':number_of_results,'title':'search results '+request.get.get('q','')}

c# - how to arrange the item of a list into series arrangement -

Image
i have list of data contains of random data combination of string , number: list<string> data1 = new list<string>() { "1001a", "1002a", "1003a", "1004a", "1015a", "1016a", "1007a", "1008a", "1009a", }; i want data arrange series this: 1001a - 1004a, 1007a - 1009a, 1015a, 1016a for every more 2 counts of data series output shall have "-" between first count , last count of series, other non series data added last part , separated ",". i'd made codes arrange data series last char of it: string get_revisionmark = "a"; var raw_serries = arrange_revisionseries.where(p => p[p.length - 1].tostring() == get_revisionmark) .orderby(p => p[p.length - 1) .thenby(p => p.substring(0, p.length - 1)).tolist(); just ignore last char i'd have function that, , problem arrangement of numbers, length of data not fi

c# - create dynamic controls with div in asp.net -

i want create dynamic div controls inside it. code below. textbox tb_name = new textbox(); tb_name.id = guid.newguid().tostring(); panel.controls.add(new literalcontrol("<div class='form-group'><div class='clearfix' style='margin-top:15px;'></div><div class='row'><div class='col-md-3'></div><div class='col-md-3'>"+tb_name +"</div></div></div>")); but displaying system.web.ui.webcontrols.textbox . how solve it? you can try this: <input type='text' id='" + guid.newguid().tostring() +"' runat='server'/> hence complete code looks following: panel.controls.add(new literalcontrol("<div class='form-group'><div class='clearfix' style='margin-top:15px;'></div><div class='row'><div class='col-md-3'></div><div class='col-md

angularjs - angular CacheFactory doesn't set any value -

i'm having issue cachefactory module , problem not set anything! here code, logically when first time code run, second time when refresh page should show me value doesn't , it's ' undefined ' function itemfcy($http,$q,cachefactory) { var items={}; var factory = { getitems: }; return factory; function get() { var cache= cachefactory.get('itemscache'); console.log("cache value is:"+cache); var deferred = $q.defer(); $http.get('/items.json') .success(function(data, status, headers, config) { items= data; cachefactory.createcache('itemscache',items); deferred.resolve(sliders); return deferred.promise; }) .error(function(data, status, headers, config) { console.log("error on loading items"); }) return deferred.promise; } it print cache value is:undefined why doesn't set anything? i think should us

Java: how to get youtube access/refresh token for app? -

i have google app credentials: app-name, api-key, client-id, client-email, client-secret ... is possible access youtube api without user autorization. example user auth can refresh tokern , access token this: tokenresponse response = new refreshtokenrequest( google_http_transport, google_json_factory, new genericurl( "https://www.googleapis.com/oauth2/v3/token" ), channelyoutubeaccess.getrefreshtoken() ).setclientauthentication( new clientparametersauthentication( getgoogleclientid(), getgoogleclientsecret() ) ).execute(); if( response != null ) { accesstoken = response.getaccesstoken(); } could me. thank you. https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list?part=snippet&id=qk8mjjjvaes&_h=4& final youtube.videos.list listrq = youtube.videos().list("id, status").setid(id).setkey(client_key); videolistresponse searchresponse = listrq.execute();

javascript - Leaflet - overwriting layer on click event -

i have mobx reaction, conditionaly maps layer.on({click}) function layer group. reaction( () => this.managingdates, () => { if (this.managingdates) { this.mapstore.polygonlayer.eachlayer(layer => { layer.on({ click: e => { this.mapstore.setmanagedparcel({ feature: e.target.feature, bounds: layer.getbounds() }); layer.setstyle({ color: "red" }); } }); }); } else { this.mapstore.polygonlayer.eachlayer(layer => { layer.on({ click: e => { this.mapstore.setactiveparcel(e.target.feature); layer.setstyle({ color: "yellow" }); } }); }); } } ); this fine first time around, when rea

What attributes does python import from a module? -

i checked answers this , have question attributes imported module in python. for example, have module temp9.py : a=10 b=20 print('a={0}, b={1}'.format(a,b)) def t9outer(): print('in imported module') def t9inner(): print('inner function') then import module so: import temp9 . if attributes of imported file using command: list(filter(lambda x: not x.startswith('__'),dir(temp9))) i output: ['a', 'b', 't9outer'] my questions are a , b global in scope of temp9 , not across modules (as above answer says), how exported? why t9inner() not imported though enclosed t9outer() , gets imported? the answer same both questions. defined @ module level imported; not defined @ module level not imported.

java - LWJGL Program stops working (without changing code) [ECLIPSE] -

ever since updated eclipse mars it's been having lot issues, right have lwjgl program, if launch after opened eclipse, works fine, if relaunch afterwards program displays black, haven't changed code stops working, , if change code , undo , launch works, relaunching again makes stop working again. madness?! i had lot issues mars, , using luna on linux. eveything work. try reinstall mars. maybe solve problems.

c# - visual studio 2013 project installer how to create custom actions -

i trying create custom action in setup project in visual studio 2013 using extension https://visualstudiogallery.msdn.microsoft.com/9abe329c-9bba-44a1-be59-0fbf6151054d but cannot add custom action or installer class project. the purpose of custom action change file access rights after installing application, how can ? in simplest case go editor window view=>editor=>custom actions, , add executable right click (say) install node , add exe, browsing it. might too, still applies: https://www.simple-talk.com/dotnet/visual-studio/visual-studio-setup---projects-and-custom-actions/ but haven't said you've tried exactly, or trying add class. if you're trying add installer class setup project, that's wrong place. if, example, installing service installer class, it's class add service. in setup project have custom action call class. in case, have added installer class c# project (or whatever is)?

java - How do i throw an exception and also execute the remaining business logic in the catch block? -

i want hack here. trying out execute of business logic after throwing exception. business logic defined in catch block. don't want keep throw statement @ end of catch block. there hack can try? thinking create thread in point , inside throw exception. not sure whether work or not. please me out. package demo1.web; import demo.exceptions.supportinfoexception; public class testinnerexception { void testit() throws exception{ try{ int i=0; int j=1/i; }catch(exception e){ system.out.println("business logic .. .. . . "); throw e; // want excute these below line , unreachable because aleready throwing excetion .. //any hacks ? system.out.println("lines after throwing exception ... ."); } system.out.println("i want logic run . . . . ."); } public static void main(string[] args) throws supportinfoexception, exception { testinnerexception t = new testinnerexception(

python - Find the superblock on disk -

i have write python script in work. script must print devices meet conditions. 1 of conditions superblock. device must have superblock. other conditions: any partitions not mounted - done any partition not in raid - done uuid not in fstab - done arr uuid in mdadm.conf - done device has superblock - ????? is there has idea how it? have confess dont have any. it's not necessary manage python. there way how check ? :) thank much. you can grep output of dumpe2fs device_name existance of "superblock at" . here's example on centos 5 linux system: >>> import shlex, subprocess >>> filesystems = ['/dev/mapper/volgroup00-logvol00', '/dev/vda1', 'tmpfs'] >>> fs in filesystems: ... command = '/sbin/dumpe2fs ' + fs ... p = subprocess.popen(shlex.split(command),stdout=subprocess.pipe,stderr=subprocess.stdout) ... output = p.communicate()[0] ... if 'superblock at' in ou

python - Django Class model access self -

i'm using django package checks whether browser mobile. want apply paginate_by on mobile device there's less galleries using self.request.mobile . here's class: class gallerylist(listview): model = gallery paginate_by = 20 context_object_name = 'galleries' category = none def get_queryset(self): if self.request.mobile: self.template_name = 'mobile/gallery.html' qs = gallery.objects.filter(visible=true,).order_by('-created','-hot') return qs you can override method get_template_names of listview following: def get_template_names(self): if self.request.mobile: return 'mobile/gallery.html' return 'normal/gallery.html' edit: for paginate can try this: def get_paginate_by(self, queryset): if self.request.mobile: return 5 return 20

gruntjs - Execute shell command (grunt build) with FAKE (F# make) -

i want automate build process of project using fake requires me run grunt task. in particular, want create target runs grunt build task in subfolder of solution folder. due lack of f# knowledge, not able pass multiple parameters static exec method of shell class. https://fsharp.github.io/fake/apidocs/fake-processhelper-shell.html this have got far: target "rungrunt" (fun _ -> let errorcode = shell.exec "grunt" "build" "\frontend" () ) this fails following error message: build.fsx(38,23): error fs0003: value not function , cannot applied if remove last 2 parameters, works, fails find grunt @ runtime: system.componentmodel.win32exception (0x80004005): system cannot find file specified @ system.diagnostics.process.startwithcreateprocess(processstartinfo startinfo) @ system.diagnostics.process.start() @ fake.processhelper.start(process proc) in c:\code\fake\src\app\fakelib\processhelper.fs:line 22 @ fake

javascript - Closure problems in class definition -

i'm using coffescript create angular application. i have strange problem code. webservice.coffe (simplificated) servicemanager.service "webservice", class constructor : (@$http) -> # private handleresult = (callback, errorcallback, autherrorcallback) => (result) => if result.result callback result else if result.code 102 @logout autherrorcallback, errorcallback else errorcallback result.code, result.error : (url, callback, errorcallback) -> @$http.get url .success handleresult callback, errorcallback, (=> @get url, callback, errorcallback) .error handleerror errorcallback logout : (callback, errorcallback) -> @$http.get "logout" .success callback() .error errorcallback() in simplificated code, error _class.logout not function when handleresult called , error code 102. the => operator should

winapi - Build twnsorflow for win32 -

i trying build tensorflow win32 cmake. fine until hit line: libprotobuf.lib(descriptor.obj) : fatal error lnk1112: module machine type 'x64' conflicts target machine type 'x86' [a:\src\tensorflow\tensorflow\contrib\cmake\build32\proto_text.vcxproj] upon checking, libprotobuf.lib indeed built x64 binary. so should change make build win32 library? this problem resolved. apparently during building, tensorflow downloads protobuf, , generated project file has target machine set x64. easy fix. now have encountered new problem: during building of pywrap_tensorflow_internal project, following link error happened: error lnk2001: unresolved external symbol "public: virtual __cdecl tensorflow::opdef::~opdef(void)" it looks project using __cdecl calling convention while ~opdef destructor using __thiscall. , can't change calling convention of class destructor. have no idea how happen. any idea on how fix calling convention mismatch issue?

mysql - Restore DBs from old version wamp to new version wamp -

i had wamp2.4 installed. uninstalled , install wamp2.5. have 2 folders in "c:\wamp\bin\mysql" mysql5.6.12 mysql5.6.17 i copied db folders mysql5.6.12 mysql5.6.17 . i go phpmyadmin , dbs listed there , clicked on table xyz , says xyz doesn't exists. any solution???? even better option first have take logical backup of db (can use mysqldump) , restore after upgrading mysql version. now saying have moved files old folder new folder assuming related (myisam innodb engine) files have been moved. need check permissions mysql should have permission on new mysql folder.

javascript - Event difference bootstrap collapse -

at moment i've code out like $('.collapse').on('show.bs.collapse',function(){ $('.glyphicon-plus').removeclass('glyphicon-plus').addclass('glyphicon-menu-up'); }); $('.collapse').on('hide.bs.collapse',function(){ $('.glyphicon-menu-up').removeclass('glyphicon-menu-up').addclass('glyphicon-plus'); }); and html code (for example) <span class="glyphicon glyphicon-plus" data-toggle="collapse" data-target="#a" aria-expanded="false" aria-controls="a"></span> <div class="collapse" id="a"></div> <span class="glyphicon glyphicon-plus" data-toggle="collapse" data-target="#b" aria-expanded="false" aria-controls="b"></span> <div class="collapse" id="b"></div> <span class="glyphicon glyphicon-p

java - jTDS SNAPSHOT isolation with spring transacion -

is there way use mssql snapshot transaction isolation spring transactions? when try set defaulttransactiondefinition def = new defaulttransactiondefinition(); def.setisolationlevel(4096); i java.lang.illegalargumentexception: values of isolation constants allowed spring checks values defined in org.springframework.transaction.transactiondefinition used , trying set value 4096 becase corresponds jtds setting snapshot isolation: /** * sql server custom transaction isolation level. */ public static final int transaction_snapshot = 4096; this in net.sourceforge.jtds.jdbc.connectionjdbc2

sql - Limiting output with different criterias -

i have following sql statement: select row_number() over(), car, group, yearout (select..... )inner year(inner.yearout) between '2010' , '2030' order inner.group)temp the output 1 test1 1 2010 2 test2 1 2010 3 test3 1 2012 4 test1 2 2010 5 test1 3 2011 and on. there table called outerno filled like: no yearo amnt 1 2010 10 2 2010 15 3 2010 5 4 2010 10 5 2010 15 6 2010 8 1 2011 4 2 2011 15 and on. there 6 groups in table each year. now problem need limit output of query stated in outerno table. need first 10 row 2010 group 1, first 15 rows of 2010 group 2 , on. each year , group there value in outerno. i tried use row_number don't know how limit output in way since needing example rows 1-10, 50-65, 83-88 , on. any idea on how this? thanks in advance help. thevagabond you'd use row_number() give record numbers per group. add clause row n

node.js - Express session stored in redis for anonymous -

i'm using express 4.0 module express-session , connect-redis , passport manage sessions. ok login , logout, can retrieve session etc. but i've noticed weird: when i'm anonymous, if i'm going redis , type: $ keys * redis return entry 1) "sess:vwdwtjpxkitmqq77xi8cotlltdrz7s8s" if nobody connected. when i'm connect, key replaced corresponding session. , when i'm logout, key changes again another. when anonymous user call url, req.sessionid set. in site https://engineering.linkedin.com/nodejs/blazing-fast-nodejs-10-performance-tips-linkedin-mobile i've read create session anonymous (7. go session-free) , think it's related. i add middlewhere in main app.js file like: var passport = require('passport'), user = require('../models/user'), localstrategy = require('passport-local').strategy, session = require('express-session'), redisstore = require('connect-redis')(session); app.us

java - How to add multiple pages in PDFBox -

i want write content in pdf using pdfbox. once page height less margin need create page. want retain cursor information. s there way through can cursor information cursor present can subtract margin cursor position , add page it. right have done this pdrectangle rect = page.getmediabox(); float positiony = rect.getwidth(); positiony = positiony - pdfwriter.defaultbottommargin; if(positiony < positionx) { positiony = rect.getwidth(); pdpage page2 = page; rect = page2.getmediabox(); document.addpage(page2); pdpagecontentstream contentstream = new pdpagecontentstream(document, page2); contentstream.appendrawcommands("t*\n"); contentstream.begintext(); // contentstream.setfont(font, 12); contentstream.movetextpositionbyamount(positionx, positiony); contentstream.drawstring(tmptext[k]); contentstream.endtext(

XPath/Python - How to get different html tags and text inside a <div> -

i'm trying scrape html content @ url: http://www.dlib.org/dlib/november14/beel/11beel.html python sintax: s="http://www.dlib.org/dlib/november14/beel/11beel.html" content = requests.get(s) tree = html.fromstring(content.text) titoli = tree.xpath('/html/body/form/table[3]/tr/td/table[5]/tr/td/table[1]/tr/td[2]/h3/text()') par = tree.xpath('/html/body/form/table[3]/tr/td/table[5]/tr/td/table[1]/tr/td[2]/p/text()') articoli = json.dumps({'titoli':titoli,'contenuti':par}) print ("content-type: json") print print (articoli) the main request find xpath query return every tags, tags content , text inside useful div of page, can find path /html/body/form/table[3]/tr/td/table[5] or using web inspector under commented line: !-- content table --. code i've posted before not possible entire content of div titles , text inside p div, can't find way. to actual html content of section

indexing - How to reindex solr after deleting a row from PostgreSql? -

i taking csv dump database , indexing table using solr.if delete row table, how remove row solr index? there several strategies: know deleted ids marking them deleted in original database , sending special $deletedocbyid key in dataimporthandler periodically delete , reindex scratch, way legacy records go away automatically add field "date-indexed" every record (e.g. in updaterequestprocessor chain) , then, @ end of reindexing, run query delete records have old "date-indexed" indicates has not been updated.

image - Sending message to whatsapp from Android app -

how can send image directly whatsapp android app? tried using bitmap b = bitmapfactory.decoderesource(getresources(), r.drawable.ic_launcher); uri imageuri = getimageuri(getapplicationcontext(), b); intent sendintent = new intent(); sendintent.setaction(intent.action_send); sendintent.setpackage("com.whatsapp"); sendintent.putextra(intent.extra_text, "this text send."); sendintent.putextra(intent.extra_stream, imageuri); sendintent.settype("image/*"); startactivity(sendintent); the above code opens send window of whatsapp. there other way image directly sent without opening whats app window? android intent system like social apps on android, whatsapp listens intents share media , text. create intent share text, example, , whatsapp displayed system picker: intent sendintent = new intent(); sendintent.setact

windows phone 8 - Convert pdb to exe file? -

i have developed windows phone apps in visual studio 2013 using windows phone 8 sdk. project , don't know how execute exe file, in bin folder .pdb file how change these .exe file? in windows phone, there nothing called execute .exe file. instead, wp users install app using app package: .xap file. when build project, if success, vs create .xap file in project debug folder or release folder. go project , search ".xap" file. if submit app store, need upload ".xap" file.

sql server 2012 - MSSQL query no longer works with Windows 10 client: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value -

we have been using following sql query long time in winforms program no problems, until end users upgraded windows 10. they exception:"error [22007] [microsoft][sql server native client 11.0][sql server]the conversion of varchar data type datetime data type resulted in out-of-range value." this error has been posted inside here earlier, did not find post occurrence connected windows 10 upgrade. the query targeted sql server 2012, using native client 11. works on windows 7 , 8, throws exception in windows 10: select distinct tblemployee.employeeid, tblemployee.lastname, (coalesce(tblemployee.firstname, '') + ' (' + coalesce(tblemployee.employeeidtext, '') +')' ) firstname tblemployee left join tblassignmentservice on tblemployee.employeeid = tblassignmentservice.employeeid tblassignmentservice.servicedate >= '2015-08-31 00.00.00' , tblassignmentservice.servicedate < '2015-09-07 00.00.00' order tblemployee.l