Posts

Showing posts from June, 2014

javascript - Print received data from client in NodeJS server -

i have simple html file containing piece of javascript: <script type="text/javascript"> $.ajax({ url: 'http://192.168.x.x:8080', data: '{"data": "1"}', datatype: "jsonp", cache: false, timeout: 5000, success: function(data) { var ret = jquery.parsejson(data); }, error: function (xhr, status, error) { console.log('error: ' + error.message); document.getelementbyid("error").innerhtml = 'error: ' + error.message; } }); </script> i want nodejs server print data received (there: number 1°). here nodejs code: var http = require('http'); var s = http.createserver(); s.on('request', function(request, response) { response.writehead(200); console.log('a: '...

vb.net - SSRS 2008 Report Dynamic Header works on local machine in BIDS but not from Report Server -

Image
i have report consists of single column tablix single row grouped. inside row 3 sub reports. header of report supposed display 3 pieces of information unique data row grouped on header unique each. i attempted populate data in header having hidden controls in body referenced in expressions of controls in header. method didn't work. switched different possible solution found populate variables using vb , reference them in header using =code.variablename in expression. function populate variables called hidden control in body passes data parameters. this method worked. however, seems work on local machine , 1 of coworker's machines in bids preview. when report published report server, runs , seems fine, except header values don't populate. one of variables integer , other 2 strings. integer value initialized 0 , in report report server shows initialized value of 0, strings still blank. makes me think function isn't being called or there might scope issue? or di...

osx - Python "app transport security" error under El Capitan -

some of python shell scripts newly throwing security errors under apple osx 10.11, el capitan. seems new app transport security doesn't how scripts calling http resources in plain text, rather using https. fetching http://blahblah.com python[5553:5648168] app transport security has blocked cleartext http (http://) resource load since insecure. temporary exceptions can configured via app's info.plist file. how might go fixing this? there no https resource can call, i'm stuck http. advice apple make exception in app's info.plist file, python script invoked shell script, there no info.plist file edited. ideas? root problem seems webkit2png, in python. non-https requests being blocked ats, , there no info.plist modify. i found solution here worked me: https://apple.stackexchange.com/questions/210588/how-does-one-configure-a-temporary-exception-to-ats-on-el-capitan-and-fix-webkit first make sure have version of webkit2png new enough have --ignore-...

Swift - how do I pass a type/object (name or instance) into a method and then (a) get the type (b) instantiate it? -

i need this, i'm having sorts of problems: class myclass { } class someclass { func callmethod(object) { let thetype = object.type // need same result myclass.self let newinstance = object() // need same result myclass() } } let someclass = someclass() let object = myclass someclass.callmethod(object) how this? i want able specify 1 type (e.g. myclass). can either type name or instance of , 2 values shown in code comments. it lot easier if passed in 2 separate variables, i'm sure can in one. you can use .dynamictype property of instance type. can call required init method on (or other class / static method). let thetype = object.dynamictype let newinstance = thetype.init() note : code compiles, depending on type of object . if type has required init() method, safe call on dynamictype . however, appears if type nsobject compiler let call init() on dynamictype though subclass may or may not have init() method given how swift ini...

upload - Uploaded App to Android -

when go download uploaded app play store, click purchase , message comes "error please try again" keep retrying , same message. don't know wrong. uploaded correctly. it's published reason can't download it. stackoverflow no place such questions . try you. try remove test application (if debugged on device) restart device check other device try setting via web interface try updating android services if application paid check availability in country in list check relevance of payment card in android market

bluetooth - iBeacon's customisable UUID conflicts -

if understanding correct, there large range of uuids assigned in specification - there's this . since ibeacon's uuid can customised, wouldn't uuid conflict existing codes , create undesirable outcomes? if understanding correct, service uuids @ byte 30 , 31 of ble packet, overlapped ibeacon's uuids. service uuids 2 bytes can't hard collision occur. it important understand there 2 types of bluetooth advertisements: service advertisements manufacturer advertisements advertisements must 1 type or other, not both. only service advertisements use service uuids (either 16 bit or 128 bit). manufacturer advertisements not. manufacturer advertisements have 2 byte company code registered bluetooth sig. else in manufacturer advertisement arbitrary data. beacon types altbeacon , ibeacon manufacturer advertisements, not contain service uuids. there therefore no possible overlap between proximityuuid , service uuid, different things. other beaco...

java - repainting a JPanel and update the screen -

i 'm trying " fade" jpanel using thread . not fading , turning color white black gradually changing rgb values ​​. public class mostrapainel { public static void main(string[] args) { jframe jf = new jframe(); jf.setsize(500, 500); // centraliza jf.setlocationrelativeto(null); painel painel = new painel(); jf.setcontentpane(painel); jf.setvisible(true); new thread(painel).start(); } } so want repaint panel interval set, panel class public class painel extends jpanel implements runnable { // alt+s /** * create panel. */ int cont = 0; public painel() { setbackground(color.black); } @override protected void paintcomponent(graphics g) { if (cont == 1) super.paintcomponent(g); graphics2d g2 = (graphics2d) g; // system.out.println(cont); g2.setcolor(new color(cont, cont, cont)); int w = getwidth...

Using Javascript to create nested tabs in Wordpress? -

side note: i've been designing in wordpress few months, , don't know else or how else ask this, language may seem inaccurate. i'm using jupiter theme within wordpress create site, textbook. 1 of chapters has content i've created "tabs' element on visual composer front-end editor. however, content needs formatted each of 5 tabs, within each tab there nested tabs. apparently function isn't allowed in visual composer(dragging tabs element within tabs element), created class names each tab , used javascript append tabs within corresponding tab. if assist , tell me why can't seem move other classes new tabs, appreciate it. tried putting tabs within accordion, , fails well. this method works first occurrence of nested tab, others, same javascript fails work. the page need assistance on: chapter 10 the javascript: //these next few lines relate chapter 10 page $('.tabonecontent').appendto($(".tabone").parents(".mk-tabs-pa...

Equivalent of OpenSSL base64 enc in Node.js (openssl enc -base64 -d -A)? -

there's api i'm working returns data that's gunzipped , double base64 encoded. i've tried using several of base64 libraries in npm no avail. doing each library's equivalent decodebase64(decodebase64(something)) fails due output encoding being faulty. this work in shell: something | openssl enc -base64 -d -a | openssl enc -base64 -d -a | gunzip . i'm looking node.js approach behaves same something | openssl enc -base64 -d -a | openssl enc -base64 -d -a | gunzip . the following libraries not work in situation: base64 base-64 js-base64 the solution find library can handle both string , binary representations of base64 (which mirrors openssl). const forge = require('node-forge') const zlib = require('zlib') const pass1 = forge.util.decode64('sdrzsufbqufbqufbqunzcetrmezbstfnl1awrufbque=') const pass2 = forge.util.binary.base64.decode(pass1) const result = zlib.gunzipsync(new buffer(pass2)).tostring() console.log(result...

Update multiple columns in MySQL but only when a value is not null -

i have mysql table multiple columns, a, b, , c. i update columns using 1 sql statement. however, of columns can null. so, if null, update b , c. if , b null, update c. and on, other combinations. how can in 1 single statement? thanks. you can use if within update clause: update test_update set a=if(a null, null, 'a2'), b=if(b null, null, 'b2'), c=if(c null, null, 'c2'); example run: mariadb [test]> select * test_update; +------+------+------+ | | b | c | +------+------+------+ | a1 | null | null | | null | b1 | null | | null | null | c1 | | a1 | b1 | null | | a1 | null | c1 | | null | b1 | c1 | | a1 | b1 | c1 | +------+------+------+ 7 rows in set (0.00 sec) mariadb [test]> update test_update set a=if(a null, null, 'a2'), b=if(b null, null, 'b2'), c=if(c null, null, 'c2'); query ok, 7 rows affected (0.00 sec) rows matched: 7 changed: 7 warnings: 0 mariadb [test]>...

javascript - Jquery 2 scripts aren't cooperating -

i have 2 jquery scripts, aren't cooperating, , dont know why. first script "scrolltop.js: $(function() { $("a").click(function(){ alert("test"); var target = $(this).attr('href'); var strip = target.slice(1); if(this.hash && strip=="wall_menu"){ $("html, body").animate({ scrolltop: $("#wall_menu").offset().top }, 1200); return false; } }); }); it works fine... stops while add script "changecolor.js": $(document).ready(function() { var $changebtn1 = $("#content_0 div.button1"); var strnewstring = $('body').html().replace(/\is/g,'<spon>is</spon>'); $('body').html(strnewstring); $(".button1").click(function(){ $('spon').css("color", "red"); settimeout(function(){ $('spon').cs...

webhdfs not working on HDP sandbox -

i getting error when execute following command on hortonworks sandbox hdp 2.3_1: curl -i "http://localhost:50075/webhdfs/v1/queryresult/part-m-00000?op=open http/1.1 400 bad request content-type: application/json; charset=utf-8 content-length: 161 connection: close {"remoteexception":{"exception":"illegalargumentexception","javaclassname":"java.lang.illegalargumentexception","message":"java.net.unknownhostexception: null"}} when change port 50070, message "curl: (7) couldn't connect host ". webhdfs property enabled in hdsf-site.xml , single node hadoop cluster. <property> <name>dfs.webhdfs.enabled</name> <value>true</value> <final>true</final> </property> does /queryresult/part-m-00000 exist? try hadoop dfs -ls /queryresult/queryresult/part-m-00000 , see if can see file. if can check permissions on file. should have read ...

javascript - How to increase/decrease 'select' option width after the user wants to select an option -

i have select box hardcode width. want width according selected text. if text long width automatically expand , if text short adjust according it. code. .post-select { border:none; -webkit-appearance: none; -moz-appearance: none; appearance: none; } <select id="discoverselect" class="post-select"> <option>all sports</option> <option>ocr</option> <option>triathlon</option> <option>running , marathon</option> <option>ultramarathon</option> <option>cycling</option> </select> if can find length can change width according characters. to find length function textwidth(str){ var span = $("<span>"+str+"</span>"); $("body").append(span); var width = span.width(); span.remove(); return width; }; ...

java - Ubuntu: Gradle maven-publish plugin - Failing to connect by sftp -

i'm trying gradle script upload sftp account, keeps failing error, failed deploy artifacts: not transfer artifact com.himself12794:heroes-mod:jar:0.9-rev1 from/to remote (sftp://himself1@ftp.himself12794-develops.com:18765/public_html/maven): not write resource 'com/himself12794/heroes-mod/0.9-rev1/heroes-mod-0.9-rev1.jar' i'm able connect via sftp command: sftp -p 18765 himself1@ftp.himself12794-develops.com however, publishmavenjavapublicationtomavenrepository task fails, above error. this minecraft forge mod, if sheds light on things. my build.gradle so: buildscript { repositories { jcenter() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } } dependencies { classpath 'net.minecraftforge.gradle:forgegradle:2.0- snapshot' } } apply plugin: 'net.minecraftforge.gradle...

Uploading image from android to php server is not working properly -

Image
i´m trying upload image using openurlconnection i´m facing problems. java class: public class upload extends appcompatactivity { inputstream inputstream; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_upload); strictmode.enabledefaults(); bitmap bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.sss); bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.png, 90, stream); byte [] byte_arr = stream.tobytearray(); string encodedimage = base64.encodetostring(byte_arr, base64.default); string msj = downloadimage(encodedimage); toast.maketext(getbasecontext(), "mensaje "+msj, toast.length_short).show(); } public string downloadimage(string tabla) { string urlg = "http://192.168.43.98/jober/"; try { url url = ne...

c# - Error CS0052 Inconsistent accessibility: field type 'FormDataEntryFilterType' is less accessible than field 'FormDataEntry.type' -

this question has answer here: “inconsistent accessibility” on class definition 3 answers i not know problem not accept " public " in enum formdataentryfiltertype , want change outside if can me, lot the code : enum formdataentryfiltertype { integernumber, decimalnumber, string } public partial class formdataentry : form { public static string inputresult; **public** formdataentryfiltertype type = formdataentryfiltertype.decimalnumber; . . . your formdataentry.type field public, enum type private. enum defaults private because no access modifier has been specified. to fix this, can make enum public: public enum formdataentryfiltertype { integernumber, decimalnumber, string }

sql - What is the quickest way to check if user exists in a large table? (Performance Optimization) -

i'm working on website 500,000 users, issue im having when user goes create new account wait time extremely long because check if user exists using query. select count(username) usernametotal user_table username = 'hellokitty' i decide if can create account based on if usernametotal greater 0. i going index column think slow when try add user table, indexed column table need recreated every time user added. is there faster way , should column indexed? for query: select count(username) usernametotal user_table username = 'hellokitty' you want index on user_table(username) . however, not efficient approach. should keep same index , use exists : if (exists (select 1 user_table username = 'hellokitty')) begin . . . end; this should faster aggregation version, because can stop @ first matching row.

performance - How/why is Integer caching faster in Java? -

according java language specification, section 5.1.7 , java caches integer s -128 127 performance optimization. so when compare a == b , a & b integers in caching range, returns true though they're different objects. mechanically, performance benefits result caching? according this answer, "the purpose save memory, leads faster code due better cache efficiency." how lead faster code? how might use feature improve performance in real code write? does have following method found in integercache class? public static integer valueof(int i) { assert integercache.high >= 127; if (i >= integercache.low && <= integercache.high) return integercache.cache[i + (-integercache.low)]; return new integer(i); } the performance benefit nothing == . real reason cache allows valueof avoid creating lots of objects when same "small" integers boxed repeatedly. integer objects occupy space (at least 16 bytes). crea...

pandas - How to remove connecting area in fill_between() using Python and MatPlot -

i graphing +-2 standard deviations mean on graph (the green points). however, rather have straight vertical lines on top of each x-mean, because there connecting shade area between states misleading. how can this? i've tried , can't figure out. in advance. (since i'm new stack overflow can't post image of graph unfortunately.) plt.scatter(x= joined.index.values, y = joined.poll_mean, color = "g") plt.scatter(x= joined.index.values, y = joined.spread,color = joined.color) plt.fill_between(joined.index,(joined.poll_mean + 2*joined.poll_std).values, (joined.poll_mean - 2*joined.poll_std).values, color='g', alpha = .3) plt.xticks(joined.index.values, joined.state.values, rotation='vertical') are trying error bars? there matplotlib package that. an example piece of code (from here ): import numpy np import matplotlib.pyplot plt # example data x = np.arange(0.1, 4, 0.5) y = np.exp(-x) # example variable error bar values yer...

google cast - Chromecast sender application error when requesting new session -

i have unpublished custom receiver app, , unable cast web player sender app in chrome. receiver "available" message upon initialization of cast api, when click on cast button in player , select chromecast device drop down menu in extension, tv screen goes black , few seconds later onerror method called following error: {code: "channel_error", description: "error: timeout", details: null} the casting works fine when using default media receiver. also, not see network traffic coming chromecast device in server console log, means chromecast not fetching receiver application. i made sure of following: the chromecast dongle registered cast receiver device in cast developer console. my macbook has nodejs server running serve receiver application , "receiver application url" in cast developer console correctly pointing server running on macbook. the chromecast , macbook both on same network, valid 192.168.x.x ip addresses. i found thre...

java - Regex to remove email address from html -

i have html input method need remove email address. problem email address not coming inside div. split across multiple divs. find sample input below div class="p" id="p9" style="top:89.17999pt;left:430.7740pt;font-family:times new roman;font-size:1.0pt;">hello</div> div class="p" id="p10" style="top:89.17999pt;left:484.100pt;font-family:times new roman;font-size:1.0pt;">.</div> div class="p" id="p11" style="top:89.17999pt;left:487.100pt;font-family:times new roman;font-size:1.0pt;">p</div> <div class="p" id="p1" style="top:89.17999pt;left:493.9300pt;font-family:times new roman;font-size:1.0pt;">@</div> div class="p" id="p13" style="top:89.17999pt;left:0.09003pt;font-family:times new roman;font-size:1.0pt;">gmail</div> div class="p" id="p" style="top:89.17999pt...

Xcode 4.2 - c++ include guard structure -

i seem doing wrong way use include guards. of time structuring works, in circumstances code below, have problems. might causing problem me using header file "all.h" big collection of other header files (like "another.h" , other header files needed). the code compile if code in file "another.cpp" commented out, somewhere along line there duplication of function "sleepfunc" (i think), since following error: apple mach-o linker (id) error ld: duplicate symbol sleepfunc(unsigned int) in /users/(project path)/.../another.o , /users/(project path)/.../main.o architecture x86_64 command /developer/usr/bin/clang++ failed exit code 1 i using xcode version 4.2 on mac os x snow leopard (10.6.8). during typing of post, discovered issue, me including header "all.h" in "another.cpp". if thing had (#include in "another.h", use header "another.h" in file another.cpp), makes me unhap...

ruby on rails - Access Denied S3 with Paperclip -

i'm getting acquainted using s3 ruby upload files amazon web service. confronted following error: aws::s3::errors::accessdenied access denied . in poking around on google, found this post on error. claims bucket policies aren't sufficient allow access via web-app , user must given "administrator access" well. i've given try , works fine feel indication i'm not doing right, given administrator access isn't mentioned in other documentation i've read. i'm using aws-sdk gem. weigh in on whether admin access necessary? many thanks! you should not need admin access achieve this. make sure have aws access_key_id , secret_access_key setup in heroku config. and, need make sure user account has access policy set in aws iam console. see this post more info. the default permission paperclip :public_read unless specify bucket private. see information module: paperclip::storage::s3

gridview - Modal pop up in grid view in yii2 -

i pop modal when click on button inside grid view. possible yii2 gridview? <?= gridview::widget([ 'dataprovider' => $dataprovider, 'filtermodel' => $searchmodel, 'columns' => [ ['class' => 'yii\grid\serialcolumn'], 'time_zone', 'no_of_users', 'bill_name', 'bill_address', 'names.name', 'bill_state', 'bill_city', 'bill_postal', 'bill_mobile', ['header'=>'plan info', 'value'=> function($data) { //~ print_r($data);die(); return html::a(yii::t('app', ' {modelclass}', [ 'modelclass' => 'details', ]), ['use...

android - send main activity in background on button click and bring it back after a given time interval -

i new android. android application contains 1 class. public class mainactivity extends activity implements sensoreventlistener i want send in background on button click , comes in foreground again after fixed time interval. how implement this?

php - Call python gearman worker using laravel 5 -

i using laravel 5 . need call python gearman worker . i have created gearman worker in python . , have created gearman client in laravel 5 . i have directly added gearman client code in controller like: $client = new gearmanclient(); $client->addserver(); $job_data = array("func_name" => "searchtweets", "query" => "query_to_search"); $result = $client->donormal("php_twitter_worker", json_decode($job_data)); if ($result) { print_r($result); } but throws error : class 'app\http\controllers\gearmanclient' not found i know error because don't have gearmanclient class in controllers. don't know how use it. after doing r&d , found package using gearman in laravel5 not getting how use gearman client , how make call python gearman worker . any on ? because class namespaced, controller there, php class inside of namespace. therefore, use class root namespace, should either use ...

python - Numpy - Speed up iteration comparison? -

the following use case: i have numpy matrix/array few thousand 2d points. call a. eg: [1 2] [300 400] .. [123 242] i have numpy matrix few 2d points above. call b . basically, want iterate through a , iterate through b , compute distance between a[i] , b[j] . assign array. this: for i, (x0, x1) in enumerate(zip(a[:,0],a[:,1])): weight_distance = 0 j, (p0, p1) in enumerate(zip(a[:,0],a[:,1])): weight_distance = weight_distance + distance((p0,p1),(x0,x1)) weight_array[i] = weight_distance but slow. might numpy way approach this? what you're looking code in scipy.spatial.distance , particularly cdist function. can efficiently compute pairwise distances between arrays of points wide variety of metrics. import numpy np scipy.spatial.distance import cdist = np.random.random((1000, 2)) b = np.random.random((100, 2)) d = cdist(a, b, metric='euclidean') print(d.shape) # (1000, 100) weights = d.sum(1) print(weights.shape) # (1000,...

javascript - angularjs: passing value to custom filter to enable it on dropdown click -

i have data. default data should shown when user click on value in drop-down filter should start filtering data. following below approach. my filter this filter('myfilter', function() { return function(data, userinput) { var filteredarray = []; // show whole data if (true) {/*want insert enablefilter variable here*/ angular.foreach(data, function(dataobj, key) { console.log(dataobj); filteredarray.push(dataobj); }) } //this show filtered data else { angular.foreach(userinput, function(value, key) { angular.foreach(data, function(dataobj, key) { if (dataobj.type.indexof(value) > -1 && filteredarray.indexof(dataobj) == -1) { filteredarray.push(dataobj); } }) }); } return filteredarray; } }); to user click event using ng-change this <select name="multipleselect" id="multiplesel...

javascript - Ruby on Rails updating list with AJAX breaks order -

i have list of elements in order. problem when update element ajax element jumps on bottom of list. when reload page returns on right place though. i'd prefer element stay in place when updating. the list: <div class="shopping-cart"> <%= render "shopping_cart" %> </div> _shopping_cart.html.erb: <% @order_items.each |order_item| %> <%= render 'carts/cart_row', order_item: order_item %> <% end %> _cart_row.html.erb: <%= form_for order_item, remote: true |f| %> <%= f.number_field :quantity, class: "form-control cart-quantity" %> <%= f.submit "submit", class: "btn" %> <% end %> update.js.erb: $(".shopping-cart").html("<%= escape_javascript(render 'carts/shopping_cart') %>") any ideas why happens? thank you. update the controller code: @order_items = current_order.order_items.order("created_...

How to put a 1d string Array into a loop? -

im having problem inputting name in first,second,third,.. entry.. example output of code result in sth this: ouput: input name 1 : input student hw score 1 : 2 input student test score 1 : 3 input finaltest score 1 : 2 so problem im unable input name in loop how can fix ? public static void main (string[] args) { scanner sc = new scanner(system.in); system.out.print("contoh : "); int noofrows; int noofcolumns; int[][] noofarrays; string names[]; system.out.print("input no of students : "); noofrows = sc.nextint(); noofcolumns = noofrows; ////////////////////////////////// names = new string[noofrows]; /////////////////////// noofarrays = new int[noofrows][noofcolumns]; system.out.println("===================="); for(int = 0 ; i<noofrows ;i++) { system.out.print("name "+(i+1)+...

ruby on rails - can't get model to properly validate -

i have following model. works when don't fill in rep or weight keep getting error: undefined method `*' nil:nilclass and in calculate_tonnage method. is there way can check presence of reps or weight, calculate_tonnage en then check if tonnage unique. i assume solution cannot find how this. have clue best way solve problem? class submission < activerecord::base belongs_to :user belongs_to :contest validates_presence_of :user_id, :reps, :weight validates_uniqueness_of :tonnage, scope: [:user_id, :contest_id] after_validation :calculate_tonnage # model helpers def calculate_tonnage self.tonnage = self.weight * self.reps end end sure, change code to: def calculate_tonnage self.tonnage = weight * reps if weight && reps end

python - Accessing class methods inside another class at same scope -

trying work around getting access class method in class while being inside class. code below explain goal. class access(object): def __init__(self): pass def select(self, value): store.keep(value) class store(object): def __init__(self): self.store_value = 0 def keep(self, value): self.store_value = value x = access() y = store() x.select(10) y.store_value ##want output of 10 i don't see way want without access having reference store object. the closest thing can is class access(object): def __init__(self): pass def select(self, value): store.keep(value) class store(object): @classmethod def keep(cls, value): cls.store_value = value x = access() y = store() x.select(10) print y.store_value #will print 10 #but z = store() print z.store_value #will print 10 where store_value shared instances of store.

web - Embedding Python in WWW client (1994) -

the first python workshop in 1994 apparently had "embedding python in www client" 1 of possible topic discussion. during panel discussion @ pycon 2017, barry warsaw mentions "python maybe close being universal language in web browsers" not explain further. does knowledgable of part of python history remember or have recollections happened , why python did not become lingua franca of web? the video recording of panel can seen here .

ios - MapView change UserAnnotationView position -

i know how can change position of userannotationview? have tried: * change position of view, user location changes , annotationview go user location, stopped location updates location manager. * create copy of annotation view , added subview can see square in view hierarchy debugger, not display on mapview if know how can create view same animation of blue dot, fine or if have class imitating same behavior of view. if have idea, let me know... in advice why want change user annotation? annotation object represent user’s current location. if want change annotation, set map.showsuserlocation false , set custom annotation on location want to. but shouldn't change userlocation annotation , don´t think it´s possible.

How to get vim to indent once when entering a newline inside brackets -

one thing has been annoying me lot in vim if enter new line inside pair of brackets, automatically inserts 2 (8 spaces): x = { } y = [ ] z = ( ) i'm unsure how change enters 1 indent (4 spaces). furthermore, closing bracket isn't indented @ when enter new line this: x = { } my vimrc: https://pastebin.com/syq55w9m it's because of option smartindent. according vim : an indent automatically inserted: - after line ending in '{'. - after line starting keyword 'cinwords'. - before line starting '}' personally use auto-pairs instead of vim-autoclose, in case want new line : x = { }

c# - System.TypeInitializationException: 'The type initializer threw an exception.' -

i've simple class myclass method defined in dll, refer dll in code , try initialise object myclass obj = new myclass() . i'm not sure why compiler throwing nullreferenceexception . please assist dll: public class myclass { public myclass(){} public void method() { //some code } } other code: void main() { myclass obj=new myclass(); //this nullreferenceexception error } for posterity, since found answer in comments: typeinitializationexception caused error in static field initialization or static constructor execution. indeed found inner exception stack trace pointed : sqlconstr = configurationmanager.connectionstrings["rmdb.database"].conn‌​ectionstring this error caused fact connection string rmdb.database not specified in app.config application. connection strings (event used dlls) must specified in app.config of application using connection.

swift3 - Firebase saving multiple child values to arrays -

Image
looking @ structure of firebase database: i attempting save values every key every cryptocurrency separate arrays. for example, 'coinamount' key, array looking ["1.0,"2.0"], , 'coinname' ["bitcoin","ethereum"] etc each of 5 keys. my attempt @ this: let index = nsindexpath(item: 0, section: 0) if portfoliocoinfullnamestring.count > 0 { print("portfoliovc: number of coins in portfolio > 0") let coinref = ref.child("\(portfoliocoinfullnamestring[index.row])") coinref.observe(dataeventtype.value) { (snapshot) in child in snapshot.children { let snap = child as! datasnapshot let key = snap.key let value = snap.value print("key = \(key) ,, value = \(value!)") if key == "coinamount" { self.firebasecoinamountar...

php - After manipulation of XML file node values with simpleXML, how do I remove the parent when duplicates arise in the node value? -

my xml file looks - want (simplified sake of example ) add 1 every node value , check duplicates. if duplicate node exists in , want remove parent , return unique xml. <?xml version="1.0" encoding="utf-8"?> <channel> <item> <gid>1240</gid> </item> <item> <gid>1440</gid> </item> <item> <gid>1440</gid> </item> <item> <gid>246</gid> </item> so desired output be: <?xml version="1.0" encoding="utf-8"?> <channel> <item> <gid>1241</gid> </item> <item> <gid>1441</gid> </item> <item> <gid>247</gid> </item> my code looks - manipulation part solved cannot figure out how check if new duplicate , remove parent before returning xml. think storing values array within loop correct after stuck. thankful help. <?php $xm...

EXCEL VBA - Make a msgbox warning if cell is matches content of another cell -

i'm school principal , i'm trying make scheduling managment app in excel. i have 1 sheet each class , 1 sheet each teacher. all sheets same , have important information on same coordinates. for now, i've been able make classes timetables copy on teacher's , works charm. make students timetables , automatically makes teacher's. now have bit of problem. if assign teacher to, let's monday @ 8.30 1 class , then, mistake assign same teacher class overlaps , carries on first class teacher. last week same teacher assign 2 classes @ same time. so question this: is there way make (on cell change) vba script checks if cell b29 has same value on other sheets, regardless of sheet's possition , name? ex: i assign teacher class 1 - monday 8.30 teacher name , date/hour cell b29, class cell d5 , sheet name. if assign, in class, same teacher b29 if display msgbox saying "there overlap". what have trouble every year classes , teachers chan...

creating board for 8 queen in python -

i trying create chess board 8 queen problem. challenge let user enter queens' positions , tell them if position wouldn't allowed due other queens. have board far this code have far: boardsize = input('board size: ') rows = [[0] * int(boardsize)] rows = str(rows).replace('[','').replace(']','').replace(',','') in range(int(boardsize)): print(i + 1, rows) this produces: board size: 8 1 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 i can't see way enter "q" (to symbolise queen) want enter it. reprint board q instead of 1 of zeros , repeat until 8 queens placed or there no space queen. must user controlled. i recommend instead of storing whole grid, store queen position in each row. because 1 queen can exist in each row, know enough store queen. makes life bit easier have di...

javascript - handle time picker with hour, minute, am, pm and time -

i creating time picker fun. create time picker can selected , show selected time. user can select or pm either. save time '09:30' format rather want show '09:30 am' or '09:30 pm' format. how handle am, pm, hour , minutes separately because in time picker have shown hour, minutes , am, pm separately , merged 1 shown title can use time sending server if want in future. how handle such? here workaround have created now can me @ this? https://codesandbox.io/s/lpyqy3mo99 here code too class timepicker extends react.purecomponent { constructor(props) { super(props); this.state = { time: this.converttime(props.time), hourtime: this.converttime(props.time), selectednumber: 1, meridian: "am", minutes: this.calculateminutes(props.time), haserror: false }; } converttime = time => { const splittedtime = time && time.split(":"); const hour = splittedtime && spl...

ruby on rails - Remove herokuapp sub domain -

i`m developing apps , hosting them on heroku there problem indexing website if publish top level domain there conflict between heroku sub domain , main one, search engines index both for example if domain something.com and heroku sub domain something.herokuapp.com what should delete heroku sub domain , make visible on main one? thank you it not possible right now. heroku proposes implement 301 redirect in such case. because don't have access configuration of web server or proxy on heroku side, option implement in application code. this information specified here : your app’s heroku domain remain active, if you’ve set custom domain. if want users use custom domain exclusively, app should send http status 301 moved permanently tell web browsers use custom domain. host http request header field show domain user trying access; send redirect if field example.herokuapp.com.

scala - Akka streams reduce to smaller stream -

i have ordered stream of data a a b b c c c c ... (very long) and want transform stream of aggregates in form (item, count): (a, 3) (b, 2) (c, 4) what operators use in akka streams this? source.frompublisher(publisher) .aggregatesomehow() // ? .runwith(sink) i've looked .groupby requires know number of categories in advance don't. believe keep groups in memory i'd avoid. should able discard (a, 3) after has been processed , free resources consumes. edit : this question ask similar functionality using subflows. using subflows doesn't seem required because have solution using statefulmapconcat combinator. one option use statefulmapconcat combinator: source(list("a", "a", "b", "b", "b", "c", "c", "")) .statefulmapconcat({ () => var lastchar = "" var count = 0 char => if(lastchar == char) { count...

javascript - Hello I want to make 4 objects move left to right in a loop but my code is not working -

this html code can see <!doctype> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="style.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> </head> <body> <div id="clouds"> <img border="0" alt="animated clouds" src="clouds.png" > <script> $(document).ready(function() { function loop() { $('#clouds').css({right:0}); $('#clouds').animate ({ right: '+=1400', }, 5000, 'linear', function() { loop(); }); } loop(); }); </script> </div> <div id="clouds2"> <img border="0" alt="animated clouds" src="clouds2.png" > <script> $(document).ready(function() { function loop() { $('#clouds').css({righ...

deep learning - Modify Decoder Cell Input in seq2seq during Inference in Tensorflow -

i trying implement deep fusion seq2seq architecture presented in paper . architecure nothing vanilla seq2seq + language model in decoder . in vanilla seq2seq during inference, input of decoder cell output of previous decoder cell. , in tensorflow, greedyembeddinghelper takes care of that. but in model, input of decoder cell f(prev_decoder_output, lm output) , f function, i.e., input of next cell dependent upon output of previous cell lm model @ point. my question is, how modify input of decoder cell in tensorflow api ? i using tf 1.2's seq2seq functions.

ios - Split TextField Data to HH : mm in Swift -

in application take user input alert time hour , minute. input user from @iboutlet weak var morninghour: uitextfield! @iboutlet weak var eveninghour: uitextfield! and implement hour : minute location var datecomponentsformorning = datecomponents() datecomponentsformorning.hour = 08 datecomponentsformorning.minute = 00 let triggerformorning = uncalendarnotificationtrigger(datematching: datecomponentsformorning, repeats: true) my question is: how can split input hh:mm , implement code in swift ?

java - How to handle auto complete suggestions on amazon.in using selenium webdriver? -

Image
i trying automate auto complete suggestions on amazon.in. unlike google search options, when right click on suggestions , not able inspect . please me in inspecting . lot i have trued following code list size returned zero screenshot: driver.get("https://www.amazon.in"); driver.findelement(by.xpath("//input[@id='twotabsearchtextbox']")).sendkeys("watch"); thread.sleep(9000); list<webelement> findelements = driver.findelements((by.xpath("//div[@id='srch_sggst']/div"))); system.out.println("size is"+findelements.size()); for(webelement a:findelements) { system.out.println(a.gettext()); } i found it. not easy (for me). open dev toolbar , find general area of think dropdown , start hovering things in dev toolbar until see dropdown light up. 1 buried in part of html. what saw lead me there was <div class="nav-fill"> <div class="nav-search-field "> <in...

node.js - Node Application Heroku Application Error -

i using heroku/nodejs build pack. this how scripts in package.json like: "scripts": { "build": "webpack --config webpack.prod.js", "server": "http-server public -p 3000 -a localhost -c 0", "prod": "npm run build && npm run server", "dev": "webpack-dev-server --config webpack.dev.js", "lint": "eslint . --fix" }, in procfile have 1 line of code: web: npm run prod any ideas why seeing application error? in regards error, think should using environment variable $port i.e. http-server public -p $port -c 0 make sure have http-server in deps , not devdeps. this might not causing error shouldn't build on run. instead add build step postinstall npm script below. "scripts": { "build": "webpack --config webpack.prod.js", "postinstall": "npm run build", "server": "h...

ios - UIWebView - get content height -

i need update height of uiview based on height of inner web view. problem is, web view height calculated based on anchors parent , incorrect. i have created custom uiview: class scrollablecontentview : uiview { var panelwebview: additionaldatawebview = { let web = additionaldatawebview() web.translatesautoresizingmaskintoconstraints = false return web }() var header: uilabel = { let fs = uilabel() fs.translatesautoresizingmaskintoconstraints = false return fs }() required init?(coder adecoder: nscoder) { super.init(coder: adecoder) initialize() } override init(frame: cgrect) { super.init(frame: frame) initialize() } private func initialize(){ panelwebview.parent = self self.addsubview(header) self.addsubview(panelwebview) setupconstraints() } private func setupconstraints(){ nslayoutconstraint.activate([ ...

javascript - Accessing HTML service form object -

Image
i'm working through https://developers.google.com/apps-script/guides/html/communication trying submit form info loaded google sheet. on client side have (based heavily on form example in article) : <!doctype html> <html> <head> <base target="_top"> <script> // prevent forms submitting. function preventformsubmit() { var forms = document.queryselectorall('form'); (var = 0; < forms.length; i++) { forms[i].addeventlistener('submit', function(event) { event.preventdefault(); }); } } // window.addeventlistener('load', preventformsubmit); function handleformsubmit(formobject) { google.script.run.withsuccesshandler(updateurl).processform(formobject); } // function updateurl(url) { // var div = document.getelementbyid('output'); // ...