Posts

Showing posts from July, 2015

Why are consistently balanced trees hard to implement and use in the "real world"? -

i'm taking algorithms , data structures course , 1 the slides informs "consistently balanced trees hard implement" , quotes following phrase: “the difficulty of implementing balanced trees restricts use; balanced trees implemented except part of programming assignment in data structures class.” -- w. pugh is true these data structures implemented in real world? using , applying balanced trees doesn't seem hard - missing? i know examples of difficulties can experienced in real applications make balanced trees hard implement. balanced trees hard right if don't have lot of experience in designing data structures, or can't details in text book. people never implement trees scratch. despite that, balanced trees popular, because programming environments can find library implements them. languages have them in standard library.

Android Studio : How to uninstall APK (or execute adb command) automatically before Run or Debug? -

now need uninstall app every time before run/ debug in android studio. because need re-create database before run \debug app. know can run command "adb uninstall [package_name]" in terminal clear files under /data/data/[package_name]. it's not convenient way if have execute command every time. hope "adb uninstall" command can executed automatically when click "run" \ "debug" button. adb uninstall <package_name> can used uninstall app via pc. if want happen automatically every time launch app via android studio, can this: in android studio, click drop down list left of run button, , select edit configurations... click on app under android application, , in general tab, find heading 'before launch' click + button, select run external tool, click + button in popup window. give name (eg adb uninstall) , description, , type adb in program: , uninstall <your-package-name> in parameters:. make sure new ite

Closure multiplate call function im javascript -

example write down myfunc('asdas') it's console.log me 'asdas' then after write down myfunc('as')('ds')('ko')....('other') function must console.log me "as ds ko .... other" i tried realize have many problems it. function me (str){ //var temp = str; return function mes(val) { val += ' '+ str; console.log(val); //return mes; } } how correctly realize function? well, bit funny, works: concat = function(x, val) { val = (val || "") + x; var p = function(y) { return concat(y, val) }; p.tostring = function() { return val }; return p } x = concat('a')('b')('c')('d'); document.write(x)

asp.net - dynamics CRM 2011 show form in aspx page / portal -

i wonder if there way show crm 2011 forms (like information form of contact entity) on aspx page? i want build customer portal (asp.net) shows fields configured in crm itself. any suggestions? cheers you have few options: put iframe aspx page , point crm form url. url has following format: http://myhost.com/orgname/main.aspx?etn={entityname}&pagetype=entityrecord&id={entityguid} use crm database views (or crm webservice ) directly application. configure datasource crm database downside of first solution users asked credentials (you want introduce sso ) , if crm running on different domain bit difficult ensure javascript communication between page , iframe. however, not impossible - http://easyxdm.net/wp/ . advantage it's pretty easy build. the second solution more work on other hand have under control.

java - how to fix this jpa/hibernate oracle error -

i use following code build query in jpa hibernate 4.1.9.final implementation: if (!stringutils.isblank(filtertext)) { string search = "%" + request.getpaging().getfilter().getfiltertext().trim().tolowercase() + "%"; string datesearch = search; try { datesearch = "%" + datetimeformatutils.formatdateonlyfordb(filtertext) + "%"; } catch (illegalargumentexception exception) { // no-op, it's okay if filtertext not date } predicate textpredicate = criteriabuilder.or( buildlikepredicate(criteriabuilder, deposit, deposit_.id, search), buildlikepredicate(criteriabuilder, deposit, deposit_.date, datesearch), buildlikepredicate(criteriabuilder, deposit, deposit_.bankaccountnumber, search), buildlikepredicate(criteriabuilder, deposit, deposit_.amount, search), buildlikepredicate(criteriabuilder, mer

ssl - Twisted Python and TLS - what does the client code need for handshaking? (I thought just public key!) -

forgive me here - despite best efforts rather non-precise way of asking precise question! i pointed towards following website on generating server side key/cert (pem file) twisted python tls server: https://twistedmatrix.com/trac/browser/trunk/twisted/test/server.pem as can see, code here generates pem file contains python source (subsequently removed!) , certificate, , private key. from here, used following generate public key (since pyopenssl apparently has no way of exporting it) openssl x509 -pubkey -noout -in server.pem > public.key i used server.pem file generated above in "starttls_server.py" sample found here: https://twistedmatrix.com/documents/14.0.0/core/howto/ssl.html however, corresponding starttls_client.py example seems want use same "server.pem" file. surely wrong? (limited!) understand of tls client given copy of public key, , used handshaking. nontheless tried it, , wasn't overly surprised when didn't work: failure: tw

plot - How to reshape data for a stacked barchart using R lattice -

Image
this question has answer here: reshaping data.frame wide long format 4 answers i have bunch of data in table (imported csv) in following format: date classes score 9/1/11 french 34 9/1/11 english 34 9/1/11 french 34 9/1/11 spanish 34 9/2/11 french 34 9/2/11 english 34 9/3/11 spanish 34 9/3/11 spanish 34 9/5/11 spanish 34 9/5/11 english 34 9/5/11 french 34 9/5/11 english 34 ignore score column, it's not important. i need tally of total number of students taking english or spanish or french class based on date, ie. need first group date , divide each day further blocks based on language , plot stacked bar chart looks following. each bar represents date , each cross section o

ruby - Why is (10..20).last the same as (10...20).last -

this question has answer here: ruby 'range.last' not give last value. why? 2 answers why these 2 equivalent? (10..20).last #=> 20 (10...20).last #=> 20 this sounds duplicate of ruby 'range.last' not give last value. why? , answers question it's design. why designed that? purpose of .. , ... returning same values last when else different? i'll answer question question: last value of 0.0...1.0 ? in general, not every range enumerable . such ranges excluded end, there no meaningful last value other value used define end of range. note can enumerate inclusive ranges last is not last value enumerated! (0..3.2).to_a.last # 3 (0..3.2).last # 3.2 (0..float::infinity).to_a.last # don't wait 1 the motivation of design "the value used define end of range" not identical "the last value enumerated

javascript - get top offset of a div on window scroll -

i'm trying top offset of element using code it's not working it's getting same position every time 108 , not changing though margin-top 100px only http://jsfiddle.net/np16jm3o/1/ $(function() { $(window).scroll(function() { var container= $("#container"); console.log(container.offset().top); }); }); html code: <div id="container" style="float: left; width: 100%; background: #ccc; height: 1200px; margin-top: 100px;"> the offset function returns position relative document, not offset of element itself, parent(s). when @ example in fiddle, can see body has margin of 8 px, resulting in 108px saw. if want offset relative parent, substract offset of parent. use .scrolltop function height scrolled if want position relative page.

java - Why isn't my program using the variables? -

i trying make object orientated javafx program have encountered problem can't seem fix, window variables set , when print them console set when come use them in start method doesn't seem acknowledge there. main class: import com.mersey.ui.window; public class main { public static void main(string[] args) { window win = new window(); win.create("mersey", 980, 640, false); window.launch(window.class, args); } } window class: package com.mersey.ui; import javafx.application.application; import javafx.scene.scene; import javafx.scene.layout.pane; import javafx.stage.stage; public class window extends application { protected stage windowstage; protected pane windowroot; protected scene windowscene; protected string windowtitle; protected int windowwidth; protected int windowheight; protected boolean windowresizable; public void create(string title, int width, int height,

famo.us - how to do loops, and callbacks using $timeline? -

are these functionalities built service somewhere? here's sample context: html <fa-modifier fa-opacity="opacitymod(testtimeline.get())">... js $scope.testtimeline = new transitionable(0); $scope.opacitymod = $testtimeline([ [0, 0, easing.inoutexpo], [1, 1] ]); $scope.testtimeline.set(1, { duration: 500, curver: 'easeinout' }); couldn't find these in docs or reading src. ideas had were: loops - setinterval or re-run animation on callback callback - settimeout @ same time testtimeline.set called same duration within same scope ended doing callback on transitionable's 'set' , re-running function afterwards. here's sample: function runloop(){ $scope.testtimeline.set(1, {duration:...,curve:...}, function() { $scope.testtimeline.set(0, {duration:....,curve....}, runloop); }); } runloop(); note runs loop again backwards. (i wanted affect). still open other solutions

javascript - How to Add New Row/Column -

i'm working on game , i've been having bit of trouble. i'm trying once blocks turn purple, want create new row , column. trying achieve removing of blocks after blocks purple, , create 1 more row , column last time, using variable rowval. i've been working on jsfiddle , link http://jsfiddle.net/jaredasch1/6dhc240q/ . i'll post code down below can quickly the html <!doctype html> <body> <div id="button" class="on hover"></div> <br> <div class="block hover"></div> <div class="block hover"></div> <div class="block hover"></div> <div class="block hover"></div> <br> <div class="block hover"></div> <div class="block hover"></div> <div class="block hover"></div> <div class="block hover"></div>

Idiomatic way to combine different monads with for in Scala -

suppose have 2 values wrapped in different monads (e.g. try , option): val x: option[int] = some(10) val y: try[int] = success(4) and want have sum of values. 1 write val z = { xval <- x yval <- y } yield xval + yval but won't compiled because of type error. there idiomatic scala way deal this? the scala standard library missing useful functions / abstractions, fortunately there complementing library called scalaz provides of need. in particular, suggested, looking monad transformers. see these 2 following posts: http://eed3si9n.com/learning-scalaz/monad+transformers.html http://underscoreconsulting.com/blog/posts/2013/12/20/scalaz-monad-transformers.html

javascript - Jquery Declarative way with HTML5 data-* -

would know way use jquery in declarative way? some of tell me use angularjs isn't there more lightweight, view side (no need routing , complex features because i'm using symfony) is there framework or library replace (i know it's bad practice it's example): <button onclick="myfunction()">click me</button> by : <any data-xx-event="click" data-xx-action="..."> </any> are trying register new html elements ? extracted page : goal : <hangout-module> <hangout-chat from="paul, addy"> <hangout-discussion> <hangout-message from="paul" profile="profile.png" profile="118075919496626375791" datetime="2013-07-17t12:02"> <p>feelin' web components thing.</p> <p>heard of it?</p> </hangout-message> </hangout-discussion> </hangout-chat>

Python - regex with Japanese letters matches only one character -

i'm trying find words in japanese addresses can scrub them. if there single character, regex works fine, don't seem find strings 2 characters or more: import re add = u"埼玉県川口市金山町12丁目1-104番地" test = re.search(ur'["番地"|"丁目"]',add) print test.group(0) 丁 i can use re.findall instead of re.search , puts of findings tuple, have parse tuple. if that's best way can live figure i'm missing something. in example above, want swap "丁目" dash , remove trailing "番地", address reads thusly: 埼玉県川口市金山町12-1-104 you're using | inside character classes ( [....] ). match characters listed there; not want. specify pattern without character classes. (also without " ) >>> import re >>> add = u"埼玉県川口市金山町12丁目1-104番地" >>> test = re.search(ur'番地|丁目', add) >>> test.group(0) u'\u4e01\u76ee' >>> print test.group(0) 丁目 to want, use str.r

Slice each string-valued element of an array in Javascript -

i have following array: var arr = ["toyota", "hyundai", "honda", "mazda"]; i want slice each element backwards, like: var arr = ["toyota", "hyundai", "honda", "mazda"].slice(-2); so return: arr = ["toyo", "hyund", "hon", "maz"]; is possible? or there anyway of doing this? you can't use slice directly, has different meaning array , return list of array elements. var arr = ["toyota", "hyundai", "honda", "mazda"]; arr.slice(0, -2) // returns elements ["toyota", "hyundai"] in order slice on each element, can use .map() (on ie9+): var out = arr.map(function(v) { return v.slice(0, -2) }) // or using underscore.js wider compatibility var out = _.map(arr, function(v) { return v.slice(0, -2) }) alternatively, use loop: var i, out = []; (i = 0; < arr.length; ++i) { out.p

javascript - Select every div inside another div and check it's class with jQuery -

i have chat system , i'm showing messages using jquery + json + php. problem is: have select each div inside div "#chatmessages", contains messages, , check it's class see if exists, ajax code: var data = {}; $.ajax({ type: "get", datatype: "json", url: "../room/a.php", async: true, cache: false, data: data, success: function(response) { if(response.error) { alert(response.msg); } else { for(var = 0; < response.length; ++) { if($("#chatscreen > *").hasclass("message" + i) == false) $("#chatscreen").append($("<div>",{ class : 'message' + response[i][1], html : response[i][0] + ' ' + response[i][4] })); } } }, error: function (response) { }, complete: function () {

c# - Inserting Scraped Results Into SQL Server -

any ideas why getting "an unhandled exception of type 'system.data.sqlclient.sqlexception' occurred in system.data.dll" when try insert results of sccraping sql server? this code using: public void scrape(string url) { using (sqlconnection opencon = new sqlconnection("connection string")) { string savestaff = "insert principale ((name) values (@name)"; opencon.open(); httpwebrequest request = (httpwebrequest)webrequest.create(url); request.useragent = "mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; .net clr 1.1.4322; .net clr 2.0.50727)"; request.allowautoredirect = false; webresponse response = request.getresponse(); streamreader streamreader = new streamreader(response.getresponsestream()); string html = streamreader.readtoend(); htmldocument page = new htmldocument(); page.loadhtml(html); var document = page.documentnode.s

swift - Compiler error: could not find member 'subscript' with && -

var card:[[int]] = bank[numberofmarked].card; if ((card[0][0] == 0) && (card[1][1] == 0) && (card[2][2] == 0) && (card[3][3] == 0) && (card[4][4] == 0)) { return true; } i getting error "could not find member 'subscript' , compiler pointing last &&. i'd file bug -- i'm getting error well: note: expression complex solved in reasonable time; consider breaking expression distinct sub-expressions . nothing wrong expression, use in swift right you'll need break couple bool variables: let firsttwo = card[0][0] == 0 && card[1][1] == 0 let lastthree = card[2][2] == 0 && card[3][3] == 0 && card[4][4] == 0 if firsttwo && lastthree { return true }

java - Spring load velocity template from string -

i'm using velocityengineutils.mergetemplateintostring() method read velocity templates file send emails. created editor(something ckeditor or cleditor) allow users create own templates , save template content string in database, can freely create own email templates , use them. but can't find equivalent way velocityengineutils.mergetemplateintostring can load template string. or maybe can suggest me correct way feature. thanks spring: 4.06 velocity: 1.7 velocity tool: 2.0 i don't think there's way spring's velocityengineutils you'll need use velocity directly. take @ velocityengine.evaluate . can pass template in string. docs: renders input string using context output writer. used when template dynamically constructed, or want use velocity token replacer.

linux - Memory usage of processes -

asked question in operating systems class , after hours of searching, cannot seem come proper answer: "assume have 3 processes running on computer. how many text, heap, , stack segments there , contain" we doing of our work in 64-bit linux environment. thank you!

vb.net - String issues. Format "First Last" to format "Last, First" with a twist -

i need change string contains name in "first last" format "last, first" format. problem is, string may "john smith", or may "mr. john smith" or "mr. john a. smith". how can eliminate "mr." part , middle name/initial part, , make "smith, john"? hate strings btw...i foresee lot of trim(right), trim(left) crap... please make easier! my goal select records database field name first letter of last name. field name contains names "john smith" "mr. roger a. smith" "mr. jones" etc. need search function returns smith's not jones. does fulfill requirements? dim samples string() = { "john smith", "john a. smith", "mr. john smith", "mr. john a. smith", "jean-claude van damme" } dim regex new regex("(?:(?:mr\.|miss|mrs|ms)\s+)?(\s+).*(?<=\s)(\s+)$", regexoptions.ignorecase) each sample in s

php - Convert Number to Words in Indian currency format with paise value -

this question has answer here: how convert decimal number words (money format) using php? 8 answers using php how convert number indian currency word format paise (decimal value) input 190908100.25 output need nineteen crores 9 lakh 8 thousand 1 hundred rupees .two 5 paise i need conversion method in php . convert currency number word format using php <?php /** * created phpstorm. * user: sakthikarthi * date: 9/22/14 * time: 11:26 * converting currency numbers words currency format */ $number = 190908100.25; $no = round($number); $point = round($number - $no, 2) * 100; $hundred = null; $digits_1 = strlen($no); $i = 0; $str = array(); $words = array('0' => '', '1' => 'one', '2' => 'two', '3' => 'three', '4' => '

javascript - 0 + integer is weird in JS -

this question has answer here: leading 0 in javascript 3 answers go browser's js console , try these: -14 // -14 -014 // -12 -24 // -24 -024 // -20 -0024 // -20 012 // 10 why 0-integer construct giving me results 2 smaller in absolute value? "never write number leading 0 (like 07). javascript versions interpret numbers octal if written leading zero." (see: http://www.w3schools.com/js/js_numbers.asp )

PHP auto_prepend_file define a constant -

i have configured auto_prepend_file in .htaccess. works fine! wanted know how make string globally without using globals. i have this: define('www_url', 'http://www.xyz.de'); define('static_url', 'http://static.xyz.de'); how www_url or static_url in index.php loaded right after prepend , before append file? thanks in advance, daniel like superglobals, scope of constant global. can access constants anywhere in script without regard scope. from php manual so can access constants inside index.php using www_url / static_url . beware constants read-only: won't able change value after " define() " them, unlike globals variables.

swift - Regarding playground feature in Xcode 6 -

can use xcode 6 play ground feature objective-c code or existing applications developed in objective c. no. it's not possible write objective-c code in playground. playground accepts swift.

linux - unable to send mail from server usiong php mail in html format -

i trying send mail using php mail function works below code: <?php $to = "abhwebdesign@gmail.com"; $subject = "subject"; $password="xxxxx"; $message = " <html> <head> <title>html email</title> </head> <body > <div style='width:670px;height:450px;padding:50px;background-color:#efefeb;'> <div style='width:600px;height:450px;background-color:#ffffff;color:#105b94;font-size:20px;padding:10px'> <img src='http://www.example.com/images/index/logo.png' /> <p>hi,</p> <table style='color:#105b94;font-size:20px;'> <tr> <td><p>thank registering us.</p></td> </tr> <tr> <td><br>your password :$password<br><br>we appreciate interest. </td> </tr> <tr> <td><hr>contact <br>office :9999999999<br>www.example.com </td> </tr> </table> <

node.js - Javascript asynchronous calls chaining -

given array contains objects of type , b, b can transformed set of type objects, via asynchronous call, best way of transforming array objects array (transforming each b object in set of corresponding objects) , execute callback when bs transformed? list = [a, b, a, b, a, a, b, a]; function transform (b, callback) { //transform b type object type objects array [a, a, a]..... callback([a, a, a]); } transformbobjectsintoaobjects(list, callback) { // ????????? callback(list); // should type objects } well, need execute final callbacks after callbacks transformbtolist have returned result. there multiple ways it: count how many callbacks have passed away , decrement when call back, , know you're finished when counter has reached 0 again. however, cumbersome, , there libraries it: async.js well-known , easy use: function transform(b, callback) { … } function transformbobjectsintoaobjects(list, callback) { async.

Sencha touch list is not refreshing -

Image
i using 'list' child component on view. not using store data, instead i'm using simple 'data' property of list layout list items. my requirement update same list taping button on same view. updating data setdata method of list, new items appended list instead of replacing old ones. list is not behaving well. event listeners ( itemtap ) old data records seems intact. this view contains list http://jsfiddle.net/xer1es0w/ here controller using view http://jsfiddle.net/6gwwes0p/ note: have truncated lines of code reason of code security in example not doing think doing. here code of happends once setdata(bla). function(data) { var store = this.getstore(); if (!store) { this.setstore(ext.create('ext.data.store', { data: data, autodestroy: true })); } else { store.add(data); } } sencha looks if there store data. if not creates one. on first run adds store , adds data sto

javascript - alert letters by name on pressing keyboard buttons without using a switch statement -

here have simple piece of code.i want alert letters [a-z] on pressing buttons on keyboard representing letters.till alerting keycodes.i know can whit switch statement.but large piece of switch statement. questions are: 1.is there way can alert every letters name on keypress without switch statement? 2.left,right,up,down arrow keys not alerting keycode numbers.why so??how can overcome problem?? (function(){ document.body.addeventlistener('keypress',function(e){ alert(e.keycode); }); })(); to show letters keycode: alert (string.fromcharcode(e.keycode)); to address problems arrow-keys not showing keycode s (37 - 40): (function(){ document.body.addeventlistener('keyup',function(e){ // keycodes of arrow keys, matched appropriate // unicode arrow symbol: var directionals = { '38' : 8593, // string.fromcharcode(38) => & '39' : 8594, // string.fromcharcode(39) =

php - ERROR: 8 - CURL error: GnuTLS recv error (-9): A TLS packet with unexpected length was received -

i have infusionsoft api lib running on server. in code, have find contacts in infusionsoft using method dsfind . if use 5 limit fetch no of contacts, working fine when make more 10, throwing below error: error: 8 - curl error: gnutls recv error (-9): tls packet unexpected length received . the same code working fine on other server. the problem relies on fact gnutls deals tls protocol. nikos mavrogiannopoulos explains fact in message on gnutls-devel mailling list : several sites terminate tls connection without following tls protocol (i.e. sending closure alerts), rather terminate tcp connection directly. relic of sslv2 , seems other implementations ignore error. gnutls doesn't , prints error. ignore it, not distinguish between premature connection termination (i.e. injecting stray tcp termination packet) , normal termination.

php - Composer hook to fix package version -

i need hook in composer installation process fix versions of second level dependencies of root package. i.e. package depends on packages (with correct versions) these packages depends on other packages , versions "wrong". try use pre-package-install hook patch such versions not working me, code inside installer::prepackageinstall not executed. root package composer.json looks this: { "name": "***/root-package", "repositories": [ { "type": "composer", "url": "http://***/packages.json" } ], "require": { "***/first-level-dep-1": "dev-release-xx", "***/first-level-dep-2": "dev-release-xx" }, "scripts": { "pre-package-install": [ "root-package\\installer::prepackageinstall" ] } } first level dependency composer.json looks this: { "name":

android - Facebook SDK: not "opened" session state while creating WebDialog.FeedDialogBuilder -

i faced such wierd bug while implementing facebook share info. made stages described on facebook tutorial facebook tutorial - share info but while trying create example of webdialog.feeddialog private void publishfeeddialog() { bundle params = new bundle(); params.putstring("name", getstring(r.string.name_fb)); params.putstring("description", getstring(r.string.description_fb)); params.putstring("link", getstring(r.string.share_link_fb)); params.putstring("picture", getstring(r.string.pictute_url_fb)); session session = session.getactivesession(); log.i(tag, "session = " + session + " isopen = " + session.isopened() + " isclosed = " + session.isclosed()); webdialog feeddialog = (new webdialog.feeddialogbuilder(this, session.getactivesession(), params)) .setoncompletelistener(new oncomplete

gtk - Screen change event on Linux desktop -

i need conceptual guide on particular task: i want able select particular rectangle on linux desktop using 2 points. then want create 1 event listener wait graphical change in particular rectangle log change what quick , dirty way achieve if there 1 of course? can done using bash script, shell , particular gtk interface (i'm targeting gnome3 desktop environment testing purposes)? i implement in c or java latter , need basic hints on native level first linux desktop learning step.

php - Error On Wordpress Plugin (WooCommerce) When Clicking Save On Adding a New Category -

recently installed wordpress plugin called woocommerce on our website. has installed correctly when trying add product category woocommerce getting error when click "save" button: fatal error: cannot redeclare woocommerce_output_related_products() (previously declared in /home/judgefuels/public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php:1091) in /home/judgefuels/public_html/wp-content/themes/dt-presscore/inc/woocommerce-support.php on line 55 i running wordpress 4.0 , latest version of woocommerce. any appreciated. @alliterativealice - solution issue! i removed same line of code in theme folder conflicted woocommerce files , has solved issue , working fine now! thanks again

SSIS - Event Handler - Email Error Code and Description -

i trying create ssis package consumes text file , places contents in table. have main flow working correctly looking @ error handling. created event handler "onerror" event. put mail task in there , configured send text , worked properly. want configure send variable. changed message source type variable , created string variable. variable expression this: "the process load data failed. please see logs: error code: " + (dt_wstr, 20) @[system::errorcode] but when handler grabs error sits there processing , never finishes. can please give me advice on how configure this? thanks in advance, craig

python - Why does this take so long to match? Is it a bug? -

i need match urls in web application, i.e. /123,456,789 , , wrote regex match pattern: r'(\d+(,)?)+/$' i noticed not seem evaluate, after several minutes when testing pattern: re.findall(r'(\d+(,)?)+/$', '12345121,223456,123123,3234,4523,523523') the expected result there no matches. this expression, however, executes (note trailing slash): re.findall(r'(\d+(,)?)+/$', '12345121,223456,123123,3234,4523,523523/') is bug? there catastrophic backtracking going on cause exponential amount of processing depending on how long non-match string is. has nested repetitions , optional comma (even though regex engines can determine wouldn't match attempting of extraneous repetition). solved optimizing expression. the easiest way accomplish 1+ digits or commas followed slash , end of string: [\d,]+/$ . however, not perfect since allow ,123,,4,5/ . for can use optimized version of initial try: (?:\d,?)+/$ . first, made repe

unix - "head" command for aws s3 to view file contents -

on linux, use head/tail commands preview contents of file. helps in viewing part of file (to inspect format instance), rather open whole file. in case of amazon s3, seems there ls, cp, mv etc. commands wanted know if possible view part of file without downloading entire file on local machine using cp/get. you can specify byte range when retrieving data s3 first n bytes, last n bytes or in between. (this helpful since allows download files in parallel – just start multiple threads or processes, each of retrieves part of total file.) i don't know of various cli tools support directly range retrieval want. the aws cli tools ("aws s3 cp" precise) not allow range retrieval s3curl ( http://aws.amazon.com/code/128 ) should trick.(so plain curl, e.g., using --range parameter have request signing on own.)

c# - Identity 2.0 Web API generate token for client -

i developing asp.net web api application. need authenticate users login , password , return string token in response. need have attribute [authorize] working. i tried investigate, how using bearertoken mechanism, without success. please provide working code example. you need configure authorization server (in case authorization server , resource server) issue access tokens , consume them. can done using owin middle-ware defining , end point should sent user credentials (resource owner flow) grant_type = password. validate credentials , provide access token tied expire date configure. public class startup { public void configuration(iappbuilder app) { configureoauth(app); //rest of code here; } public void configureoauth(iappbuilder app) { oauthauthorizationserveroptions oauthserveroptions = new oauthauthorizationserveroptions() { allowinsecurehttp = true, tokenendpointpath = new pathstring(&q

html - nth Child in CSS -

i have used nth child before reason can not target correct div: <div class='main'>...</div> <div class='color'>...</div> <div class='number'>...</div> <div class='target_div'>...</div> <div class='target_me_one'>...</div> <div class='target_me_two'>...</div> <div class='main'>...</div> <div class='main'>...</div> <div class='main'>...</div> <div class='main'>...</div> <div class='main'>...</div> <div class='main'>...</div> i hoping first occurrence of main, second child of main (number), first child of number (target_div) , both of children of target_div. the whole objective of alter target_me_one / target_me_two first occurrence of main. can not target these 2 individually through selectors (due plug in i'm using).

What's the simplest way to print a Java array? -

in java, arrays don't override tostring() , if try print 1 directly, weird output including memory location: int[] intarray = new int[] {1, 2, 3, 4, 5}; system.out.println(intarray); // prints '[i@3343c8b3' but we'd want more [1, 2, 3, 4, 5] . what's simplest way of doing that? here example inputs , outputs: // array of primitives: int[] intarray = new int[] {1, 2, 3, 4, 5}; //output: [1, 2, 3, 4, 5] // array of object references: string[] strarray = new string[] {"john", "mary", "bob"}; //output: [john, mary, bob] since java 5 can use arrays.tostring(arr) or arrays.deeptostring(arr) arrays within arrays. note object[] version calls .tostring() on each object in array. output decorated in exact way you're asking. examples: simple array: string[] array = new string[] {"john", "mary", "bob"}; system.out.println(arrays.tostring(array)); output: [john, mary, bob] nest

windows installer - Installing MS SQL Server 2012 during application installation -

there financial application man executive file written delphi language. im working on setup project. has many steps. confusing required step installing ms sql server custom condition. im wondering if doable install ms sql server 2012 ( standard edition or higher ) during application setup? yes, can install express edition of sql server alongside application setup. should add prerequisite setup package.

php - how to tie mssql table on jqgrid -

i want make jqgrid , want put there 2 tables mssql database. made .php didn't work, can watch sec why dosen't work? i'm neewbie on thing.. code> <?php $myserver = "localhost"; $myuser = "root"; $mypass = ""; $mydb = "test"; //connection database $dbhandle = mssql_connect($myserver, $myuser, $mypass) or die("couldn't connect sql server on $myserver"); //select database work $selected = mssql_select_db($mydb, $dbhandle) or die("couldn't open database $mydb"); // declare sql query database $query = "select [column 1]"; $query = "from table_test1"; //execute sql query , return records $result = mssql_query($query); //display results while($row = mssql_fetch_array($result)) //close connection mssql_close($dbhandle); ?> and jqgrid code> <html> <head> <title id='description'>expedio weekly tickets</title> <script sr

asp.net - Kentico: Exclude specific pages from Breadcrumbs -

just simple question on kentico: possible exclude pages rendering cms breadcrumbs? specifically, our users want homepage not render breadcrumbs i'm trying exclude that. this kinda tricky. if ensure breadcrumb control has no data can hide via 'hide if no record found' settings. set condition of breadcrumb web part following macro: {% if(currentdocument.nodealiaspath == "/homepage"){"1=0"}else{"1=1"} #%} obviously, have use node alias path of homepage. set 'hide if no record found' true .

oop - How abstraction is achieved using interfaces in java -

i know abstraction process of hiding implementation details , showing functionality. but using interfaces can not implement thing.we need implemented class develop applications.for example in java have list interface has sub classes linkedlist , arraylist.they provided code classes also.we able see code implemented code.can 1 give me example abstraction. if give interface someone, can achieve abstraction.but example this? hiding here means making client of code independent of underlying implementation. interfaces specify what can do. implementations specify how it. as how tos improve/change time, client (another piece of code) using interfaces continues work without modification. client still gets wants, in more efficient manner now. abstraction style of programming aimed @ easing lives of programmers , consumers. has nothing hiding source code others. there other ways it.

in app purchase - Android In App Billing to OpenIAB migration -

i publish app on google play in-app purchase,i want publish app on different stores,for using openiab , unable understand official document of openiab, please me following points 1. have create in app purchase item same sku on every store? 2. line of code need change replace google iab openiab ? no, can map skus if different supported stores this: openiabhelper.mapsku(sku_premium, openiabhelper.name_google, "org.onepf.trivialdrive.gp.premium"); openiabhelper.mapsku(sku_gas, openiabhelper.name_google, "org.onepf.trivialdrive.gp.gas"); openiabhelper.mapsku(sku_infinite_gas, openiabhelper.name_google, "org.onepf.trivialdrive.gp.infinite_gas"); all have change in code can found here .

rubymine - Ruby: Undefined method -

i having issue first ruby program hashes. error saying 'throw': undefined local variable or method 'directions' ....... here code: class die directions = { north: 1, south: 2, east: 3, west: 4 } def throw direction = directions.select{ |key ,value | value == rand(4)+1} puts direction end end dice = die.new dice.throw question 1 how how fix error? question 2 ruby-mine has zig-zag line under hash directions , gives option remove assigment why this? question 3 there zig-zag under 'key' , offers convert "to block" why ? it has scopes. method body runs in scope/context of instance, class definition runs in own scope. use instance variables , initialize hash @directions in initialize method, in case hash not change, recommend using constant. in ruby these declared variables, when first character uppercase, constants. probably because variable never used, reasons deta

html - Is it possible to use JQuery to load a url into an iframe when a link is clicked on the same page? -

is possible using jquery load src of <a> tag iframe on same page linked clicked if can not edit html? something similar instead of getting value input src value src of link person clicks on? http://jsfiddle.net/kbwood/dlprk/ is want? $('#url').click(function(e) { e.preventdefault(); $('#display').attr('src', $('#url').attr('href')); }); iframe { width: 100%; height: 50%; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <iframe id="display"></iframe> <br> <a type="text" id="url" href="http://jquery.com">test</a>

asynchronous - Accessing spray request from spray response -

i'm calling function every 50 ms : def send() = { val mydata = generaterandomdata() val response = pipeline(post("http://slow-website.com/send", mydata)) response oncomplete { case success(r) => ? how access mydata ? case failure(error) => print(error.getmessage) } } i know data sent in successfull request. how can achieve this? just refer mydata . what happens behind scenes scala compiler creates closure oncomplete handler argument captures reference mydata can use it.

javascript - How to collect multiple asynchronous results with JQuery AJAX call to MVC app -

i want able log series of events when doing server side background work in mvc web app. basically, have jquery ajax call triggering server side action. while asynchronous, action returns data once, when has completed (of if exception thrown example). need log messages on client side generated on server side. considering this, there way post multiple log messages calling site while work still being done on server side ? ajax push way considering in context of ajax get/post ? there way not have asynchronous get/post, asynchronous results through same call using jquery ?

symfony - How to use php json_encode options in twig file with json_encode twig function -

i trying use twig json_encode function when this var packagedetails = {{(packagedetails|json_encode)}}; and packagedetails array of array passed controller it gives me error saying invalid property id because of &quot; want use escape filter; how use it? is because not wrapping output in quotes? var variable = '{{{reference}}}'; update: the actual answer solve question adding |raw tag per comments var packagedetails = {{(packagedetails|json_encode|raw)}};

ios - Center titleView in navigationBar -

i've added uipagecontrol titleview in navigationitem , issue is not centered due have leftbarbutton . possible create rightbarbuttonitem hidden uipagecontrol centered?

graph - Using BOTH error bars and upper/lower limits in python -

warning: new @ python , know little. i trying graph (x,y) error bars in both directions. able achieve this, using: from matplotlib import pyplot pyplot.errorbar(x,y,yerr=y_error,xerr=xerror) however, error in either x or y zero. in case, want program create upper (x) , lower (y) limit data points. actual value of limit doesn't matter; needs show such. i've found things suggesting add 'lolim' , 'uplim' pyplot.errorbar, it's not working. need loop or add in lower/upper limits? thanks. suggest simple solution so: all non-limits: ind1 = y_error*x_error!=0 pyplot.errorbar(x[ind1],y[ind1],yerr=y_error[ind1],xerr=xerror[ind1],fmt='k+') x-limits: ind2 = x_error==0 pyplot.errorbar(x[ind2],y[ind2],yerr=y_error[ind2],fmt='k<') y-limits: ind3 = y_error==0 pyplot.errorbar(x[ind3],y[ind3],xerr=x_error[ind3],fmt='kv') i'll leave decide cases both x , y limits.

excel vba - how to select dynamic cell based on numeric value -

i looking code selecting cell based on numeric value. i have constant column name i.e q , dynamic numeric value in a2 cell vary every time 5, 10 or 22. if a2 contain 5 wanna go q5 if a2 contain 99 wanna go q99 . i have tried offset not succeed. suggestion welcome. thanks in advance. consider: sub qwerty() if range("a2").value > 0 , range("a2").value < rows.count + 1 range("q" & range("a2").value).select end if end sub

html - functions of javascript "return" -

in javascript, can return used "kill" variable speak (as in, stop functioning past point throughout code)? working on piece of code , want variable "msg" stop working if value empty avoid alert box popping up. correct, or alert still pop up? if(msg==””){ return result; } { alert(msg) return result; } return used allow functions hand control, can not used outside of function. think looking else if(msg==""){ // } else { alert(msg); } if want "kill" variable, can delete variable_name make undefined

javascript - object HTMLInputElement error when trying to display random task -

so trying display , random string array created. counting portion of message works, second part should display , random task array shows error. did not use parseint , math.random function correctly? dont have round number since parseint converts integer right? var tasks = []; // function called when form submitted. // function adds task global array. function addtask() { 'use strict'; // task: var task = document.getelementbyid('task'); // reference output goes: var output = document.getelementbyid('output'); // output: var message = ''; if (task.value) { // add item array: tasks[tasks.length] = task; var randomnum = tasks.length; var randomtask = parseint((math.random() * randomnum), 10); var randommsg = tasks[randomtask]; // update page: message = 'you have ' + tasks.length + ' task(s) in to-do list.\n'; message += 'random