Posts

Showing posts from April, 2015

Converting .BAK file of SQL Server DB to .CSV -

ok have .bak file backup of our old crm data. has come backup of sql server database (not sure version). trying achieve converting data file contains in .csv can use import data different crm. i have tried obvious things, renaming file .csv , trying various text editors , applications claim able view these kind of files. ever ton of gibberish, mean ton of characters , symbols not represent in data backup. from have obtained already, need restore file sql server database, , export .csv. have managed set trial version of sql server 2012, when try import file (import flat file option), when preview, appears gibberish populating fields again, , if run anyway, fails , returns errors. can confirm crm company had managed restore , extract needed, sadly decided not continue them, based on that, .bak file not corrupted. i assume doing wrong. question correct way import / restore .bak file ms sql 2012? is there alternative have missed or not right approach begin with? any appreciat

Cloudera Hadoop Extended Acl's not working -

have been working on week now, here issue. have setup cluster cdh5 security enabled using mit kerberos. trying extended acl's , has done necessary changes responsible set doesn't work , here summary in commands. [root@dn01 ~]# kinit hdfs password hdfs@vt2.hadoop.ba.ssa.gov: [root@dn01 ~]# hdfs dfs -ls /vt2/testdata/dcus found 2 items -rwxr----- 3 hdfs systems 3949 2016-03-16 16:13 /vt2/testdata/dcus/xxxx.jsonseq drwxr-----+ - hdfs systems 0 2016-03-18 15:57 /vt2/testdata/dcus/nn [root@dn01 ~]# hdfs dfs -getfacl /vt2/testdata/dcus # file: /vt2/testdata/dcus # owner: hdfs # group: systems user::rwx group::r-- group:developers:r-- mask::r-- other::--- [root@dn01 ~]# kdestroy [root@dn01 ~]# kinit 419650 password 419650@vt2.hadoop.ba.ssa.gov: [root@dn01 ~]# hdfs dfs -ls /vt2/testdata/dcus ls: permissio

javascript - How to call script via ajax crossdomain -

can me make request via ajax crossdomain? what have: $.ajax({ type: "post", url: "/login.php", data: { email: document.loginform.email.value, password: document.loginform.password.value, } }).done(function(msg){}); i'm calling https://m.domain.com/login.php - works. but, want call same script login.php on domain.com. as guess i'm working on mobile version of website. want make post requests m.domain.com scripts situated on domain.com using absolute address like: url: "https://domain.com/login.php", - no success.. i tried make url "/home/admin/web/domain.com/public_html/" ajax request.. still no result.. you should allow cors https://m.domain.com on https://domain.com/login.php . like here

php - Download from Laravel storage without loading whole file in memory -

i using laravel storage , want serve users (larger memory limit) files. code inspired post in , goes this: $fs = storage::getdriver(); $stream = $fs->readstream($file->path); return response()->stream( function() use($stream) { fpassthru($stream); }, 200, [ 'content-type' => $file->mime, 'content-disposition' => 'attachment; filename="'.$file->original_name.'"', ]); unfourtunately, run error large files: [2016-04-21 13:37:13] production.error: exception 'symfony\component\debug\exception\fatalerrorexception' message 'allowed memory size of 134217728 bytes exhausted (tried allocate 201740288 bytes)' in /path/app/http/controllers/filecontroller.php:131 stack trace: #0 /path/vendor/laravel/framework/src/illuminate/foundation/bootstrap/handleexceptions.php(133): symfony\component\debug\exception\fatalerrorexception->__construct() #1 /path/vendor/laravel

Google Maps in Swift - Camera not updating -

i'm using google maps in swift , in viewdidload . i providing code: let camera: gmscameraposition = gmscameraposition.camerawithlatitude(48.857165, longitude: 2.354613, zoom: 8.0) mapview1.camera = camera however, when executing program, camera not updating. using @iboutlet weak var mapview1: gmsmapview and have hooked outlet correctly you need implement mapview1.animatetocameraposition(camera)

asp.net mvc - How to view the code of an ADO.NET Entity Data Model -

Image
i created ado.net entity data model. can go check actual class? want check data types , add displayname attributes. here model solution explorer: thanks. when generate model database (which appears case here), few different code files created. code context, expand programmasterlist.context.tt . you'll see .cs file in there context class. then, each table selected database part of model, entity class created. can find expanding programmasterlist.tt . instance, if have table called person, might have entity class file person.cs person class defined in it. now, mentioned wanting modify classes add properties. if modify class files under programmasterlist.tt , dynamically generated entity framework, next time update model database (such add new table db model), changes you've made overwritten. fortunately, there's better way. each class under programmasterlist.tt partial class. so, can add class without modifying file entity framework automatically g

ios - CGFloat in Swift 2.0 -

Image
after updating swift 2.0 need fix code. automatic correction doesn't work. func getvalueforkey(key: string) -> cgfloat { var inch = "" if screensize.height == 480 { // iphone 4, 4s , below inch = "3.5" } else if screensize.height == 568 { // iphone 5, 5s inch = "4" } else if screensize.width == 375 { // iphone 6 inch = "4.7" } else if screensize.width == 414 { // iphone 6+ inch = "5.5" } else if screensize.width == 768 { // ipad inch = "5.5+" } let result = values["\(key)\(inch)"]! // println("\(key) - \(result)") return result } i have changed it. nothing happens , appears again! how fix it? to elaborate on why importing uikit fixes problem: the cgfloat struct part of

ruby - Rspec; verifying an element state when the attribute that doesn't have a value -

i doing automation testing using rspec , watir. verify presence of button element's attribute titled hidden . in pseudo-code this: find button element; press click verify button element has attribute titled "hidden" perform further actions is possible find attributes of nature, or need hidden=hidden ? you can use built-in hidden? method: <input type="submit" value="button"> browser.button.hidden? #=> false <input type="submit" value="button" hidden> browser.button.hidden? #=> true then, can create rspec example uses expectation validate: describe "button" "should hidden" expect(browser.button.hidden?).to true end end and expect(browser.button.hidden?).to true clunky. justin ko astutely points out, rspec provides syntactic sugar in form of predicate matchers make cleaner: expect(browser.button).to be_hidden .

Dynamic patterns for the Case Statement in Shell Scripting -

the code below rough outline of trying do. don't worry code doing after each case evaluated. my question in case *','* ) trying recognize dynamic pattern of files separated commas. ex: getfile.sh -fileextension file1,file2,file3,file4 input. how go recognizing input $2(this equal var2) follows *','* pattern * represents file? if [ $flag -eq 1 ]; case $var2 in #lists files if option selected list | l | list | l | ls | ls) stuff here | | | a) stuff here *','* ) stuff here * ) stuff here esac fi i should add program supposed list set of files based on extension , allow user either files, or select mutliple (or single) file. because not know user going input i'm trying match pattern instead of static input. so here new code looks , closer i&#

Preallocation of Array that is storing histograms in Matlab -

x = []; y = []; = 1:m qimg = imread(fullfile(dir2, queryframes(i).name),fmt); image1 = rgb2gray(qimg); x = [x, imhist(image1)]; end j= 1:n rimg = imread(fullfile(dir1, refframes(j).name),fmt); image2 = rgb2gray(rimg); y = [y, imhist(image2)]; end can show me how can preallocate x , y, 2 arrays storing histograms. matlab suggests preallocation both arrays speed. help. by default grayscale images (which have), imhist creates histogram using 256 bins (docs here ) , outputs column vector. therefore, unless change number of bins in iterations want x have 256 rows. number of columns dictated number of images processing, here m images x variable , n images y variable. therefore want initialize both variables follows: x = double(256,m); y = double(256,n); also, not recommended use i or j loop iterators since can confused imaginary unit.

python - How to read just words, not full phrases -

i have code reads text file, , prints out each line containing keyword (entered input). however, whole phrase entered gets searched, not words them selves. e.g. enter i have fast car the whole phrase searched in file, not keywords, such fast, or car. file = open("file.txt", "r") search= input("what searched? ") line in file: if search in line: print ("found" +line) file.close() try this: search = input("what searched? ").split() open("file.txt", "r") f: line in f: if any(word in line word in search): print ("found" + line)

2D array to table in c#? -

i need put data table array , make array print formatted table in console. here's table got data http://puu.sh/oqv8f/7d982f2665.jpg ; need make array output rows , columns instead of list. have far: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace zumba1 { class zumba { static void main(string[] args) { //recreated data in table zumba section, added each row, , each column. string[,] schedule = new string [8, 6] { { "1:00", "3:00", "5:00", "7:00", "total", "", }, {"monday", "12", "10", "17", "22", "244", }, {"tuesday", "11", "13", "17", "22", "252",}, {"wednesday", "12&q

c# - There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'CompanyID' -

this question has answer here: the viewdata item has key 'xxx' of type 'system.int32' must of type 'ienumerable<selectlistitem>' 1 answer i've been reading stackoverflow nothing has been able me this. i'm working on position model has selectlists fields couple other models, yet every time try , save error: "an exception of type 'system.invalidoperationexception' occurred in system.web.mvc.dll not handled in user code additional information: there no viewdata item of type 'ienumerable' has key 'companyid'." here's relevant code view: views/position/create.cshtml <div class="form-group"> <label class="control-label col-md-2">company</label> <div class="col-md-10"> @html.dropdownlist("companyid", (selectl

Specific CanCan Abilities for Rails Admin -

Image
i trying manage permission in railsadmin, having trouble getting want to. using ability file have set up. want able allow specific kind of user create, read, trash, export particular model. i decided change: can :manage, terms, company_id: company_id to: can [:create, :read, :trash, :export], terms, company_id: company_id thinking still show little "info" , "delete" icons removing "edit" icon. instead shows "info" icon. i want pencil gone. or guidance appreciated. looked @ cancan page , didn't help. original: after: below: can :manage, terms, company_id: company_id i added: cannnot :update, terms, company_id: company_id which seemed work properly

elixir - Port messages returning to an unexpected process -

i have simple ports app (literally example erlang -- ports documentation ) , genserver controlling use. the genserver can communicate c app fine doesn't receive responses, iex or supervisor does. if call flush iex, see expected message. if create separate module , spawn receive loop it, still doesn't receive port response messages. i have feeling i'm incorrectly opening port cannot prove it. there obvious i'm screwing up? port = port.open({:spawn, "./extprg"}, [{:packet, 2}, :exit_status]) collect = fun () -> collect_results(port) end spawn(collect) def collect_results(port) receive {^port, {:data, data}} -> #never gets called despite matching messages in flush {^port, {:exit_status, status}} -> #never gets called... {:increment, value} -> port.command(port, [1, value]) collect_results(port) end end when opening port module uses genserver , ensure calling po

android - How can i create .setTicker in my notifications bar -

my notifications bar structure in way: notification notification = new notification(r.drawable.full,+level+"%",system.currenttimemillis()); notification.flags = notification.flag_ongoing_event; intent = new intent(context, mainactivity.class); pendingintent penint = pendingintent.getactivity(getapplicationcontext(), 0 , , 0); notification.setlatesteventinfo(getapplicationcontext(), "batteria al"+" "+level+"%", "clicca per aprire l'applicazione", penint); notifi.notify(215,notification); } but don't know how set .setticker structure. how can it? thanks notification notification = new notification(r.drawable.full,+level+"%",system.currenttimemillis()); in line second parameter ticker text. dont need set using other method. btw constructor deprecated. use notification.builder instead by using that not

Printing JavaFX tableview with PrinterJob -

i want print tableview onto a4 in landscape format. want tableview scale itselfe on a4 page. i managed this: printer printer = printer.getdefaultprinter(); printerjob printerjob = printerjob.createprinterjob(); //set layout a4 , landscape pagelayout pagelayout = printer.createpagelayout(paper.a4, pageorientation.landscape, printer.margintype.default); printerjob.getjobsettings().setpagelayout(pagelayout); system.out.println(pagelayout.getprintablewidth()); system.out.println(pagelayout.getprintableheight()); final double scalex = pagelayout.getprintablewidth() / _menuplantable.getboundsinparent().getwidth(); final double scaley = pagelayout.getprintableheight() / _menuplantable.getboundsinparent().getheight(); _menuplantable.gettransforms().add(new scale(scalex, scaley)); if(printerjob.showprintdialog(_controlstage) && printerjob.printpage(_menuplantable)) { _menuplantable.gettransforms().remove(gettransforms().size()); printerjob.endjob();

F# Equivalent of Python range -

i've started learning f#, , 1 thing i've run don't know way express equivalent of range function in python. know [1..12] equivalent of range(1,13). want able range(3, 20, 2) (i know haskell has [3,5..19] ). how can express this? seq { 3 .. 2 .. 20 } results in 3 5 7 9 11 13 15 17 19 https://msdn.microsoft.com/en-us/library/dd233209.aspx

google api - Customization of Form Background Size -

Image
basically, want increase form background size. i've 5 choices in 1 question , 1 of them cut format of google forms. how can remove bottom scroll bar , make static form ? at time new google forms themes feature allows select predefined themes , change theme image. old google forms themes feature have more customization options doesn't include 1 changing grid question box size. if using old google forms try changing font settings question options. another alternative split column headers words (replace moderadamente modera- mente or shorter synonym) a third alternative use code 1,2,3,4,5 instead of category names.

excel - If statement with VLookup -

Image
i having trouble setting function joins 2 sheets on multiple criteria. i want following happen in flight column: if sheet1.product = sheet2.product , sheet1.date >= sheet2.start date , sheet1.date <= sheet2.end date sheet2.flight i cannot concatenate , vlookup off because looking range of dates , cannot use if(and( because need 'value_if_true' dynamic. what best formula achieve have tried explain? sheet1 flight column row 1 =if(and(d2=sheet2!a2,sheet1!a2>=sheet2!b2,sheet1!a2<=sheet2!c2),sheet2!d2) date start date end date product flight 11/29/2015 11/29/2015 12/5/2015 product1 1 11/29/2015 11/29/2015 12/5/2015 product1 11/30/2015 11/29/2015 12/5/2015 product1 11/30/2015 11/29/2015 12/5/2015 product1 12/1/2015 11/29/2015 12/5/2015 product1 12/1/2015 11/29/2015 12/5/2015 product1 12/2/2015 11/29/2015 12/5/2015 product1 12/3/2015 11/29/2015 12/5/2015 product1 12/3/2015 11/29

computer vision - Edge following with camera -

Image
i want follow rightmost edge in following picture line following robot. i tried simple "thresholding", unfortunately, includes blurry white halo: the reason threshold obtain clean line sobel edge detector: is there algorithm can use isolate edge/move along edge? 1 using seems error prone, it's best 1 i've been able figure out far. note: edge may curve or aligned in direction, point on edge lie close center of image. here's video of i'm trying do. doesn't follow edge after (1:35) due halo screwing thresholding. here's sample: here, floodfill centermost edge separate little bump in bottom right corner: simplest method (vertical line) if know image have black on right side of line, here's simple method: 1) apply sobel operator find first derivative in x direction. result image negative gradient strongest. (use large kernel size average out halo effect. can apply gaussian blur image first, more averaging

Ruby on Rails creating multiple children in one parent form -

i have parent has multiple children. want when submit form, parent generated in parent model, , multiple records created in child model, 1 each child. when try , submit, following error: activerecord::associationtypemismatch in parentscontroller#create child(#) expected, got array(#) when uncomment accepts_nested_attributes_for :children , change f.fields_for :children f.fields_for :children_attributes, different error: typeerror in parentscontroller#create can't convert symbol integer i @ loss do. have checked out nested model forms railscasts, dealing generating children fields inside form, , learned railscasts didn't seem work. pretty doing builder.text_field :cname's in form wrong, i'm not aware of proper way it. my code: parent.rb class parent < activerecord::base has_many :children #accepts_nested_attributes_for :children attr_protected :id child.rb class child < activerecord::base belongs_to :parent attr_protected

cron - Crontab CD to Directory -

all of cronjob scripts run specific directory. can add cd /folder/path @ top of crontab file , expect scripts run directory? currently crontab functions (ignore lack of specific run frequencies) * * * * * cd /folder/path && python3 file.py * * * * * cd /folder/path && python3 file2.py * * * * * cd /folder/path && python3 file3.py i rather like cd /folder/path * * * * * python3 file.py * * * * * python3 file2.py * * * * * python3 file3.py since crontab file not running when task being triggered not work since cron tasks run cron daemon. solution beautify commands bit add path actual scripts path env variable on crontab file path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/path/to/scripts and this: * * * * * /folder/path/file.py * * * * * /folder/path/file2.py * * * * * /folder/path/file3.py note name.py files should have interpreter defined @ top of file work.

http - Is there a way to be notified when a client has unsubscribe from server sent events? -

as understand when request event emitter on server arrives, request never closed , need res.write() every time send message. there way notified when client performed request has left? there property on request object? suppose have following route app.get('/event',function(req,res){ //set response headers //how check if req object still active send message , perform other actions? }) the basic sequence of events should similar in other frameworks, example grails 3.3. first set endpoints subscribe, , close connection. def index() { // handler /api/subscribe rx.stream { observer observer -> // grails event bus. background tasks, // services , other controllers can post these // events, client_hangup, send_msg, // string constants. eventbus.subscribe(client_hangup) {string msg -> // code handle when grails event bus // posts client_hangup // side effects here, up

c - Setting an Array of Integer Pointers -

i trying set array of integer pointers. programs supposed set pointers @ index point integer of value 2*i. programs should print out pointees of first 5 pointer elements, should 0,2,4,6,8. for reason getting segmentation fault. tell me why happens , can fix it? i attempted replace final line " arr[index] = &i; ", not give me segmentation fault still gives me wrong results. help appreciated, starting off array of pointers. #include <stdio.h> void setarr (int); int * arr[10]; // array of 10 int pointers int main(int argc, char *argv[]) { int i; setarr(0); setarr(1); setarr(2); setarr(3); setarr(4); for(i=0; i<5;i++) printf("arr [%d] = %d\n", i, *arr[i]); /* should 0, 2, 4, 6, 8 */ return 0; } /* set arr[index], pointer, point integer of value 2*index */ void setarr (int index){ int = 2 * index; * arr[index] = i; } the problem not allocating memory each ite

ruby on rails - Using Paginate on Certain Users in Database -

i using kaminari paginate traverse through users , give them evaluation. however, users can evaluate users, not of them, confused on how go this. tried creating array of users want display, did not work correctly since new ruby. understand that <% @users.each |user| %> is traversing through entire list, not sure how edit needs. example, have role attribute each user. users each role evaluate other users same role. have tried doing like <% @users.each |user| if @user.role == 1 %> but know that exact code verbatum won't work way i'd like, that's example of want if it's possible. in summary, choose in paginated list. below code trying do. each user has form. <h2>back of house evaluation</h2> <br> </br> <% @users.each |user| %> <h4> <%= user.name %> </h4> <h3> have heart?</h3> <%= form_for(user) |f| %> <% begin %> <div class="form-group"> &

sockets - Wireshark conversation list sides -

when wireshark conversation list opened (statistics ->conversation list) wireshark showing column of "packets a->b" , column of "packets b->a". when i'm sniffing on 1 side of traffic (physically) can see half mac addresses have traffic on "a->b" , not on "b->a" , other half other way around, makes sense, because sniffed on 1 side of conversations. the question is: how wireshark decide address call "side a" , address call "side b"? it's easy see described above doesn't depend on side sent more packets/sent first packet , find hard believe decided randomally. any appreciated. looking @ the code fills list ( ui/gtk/conversations_table.c:1726 ) : gtk_list_store_insert_with_values(store, &iter, g_maxint, conv_column_src_addr, src_addr, conv_column_src_port, src_port, conv_column_dst_addr, dst_addr, conv_column_dst_port, dst_port, conv_column

java - Whats the best way to design DELETE for a restful resource -

trying find out way design delete. trying explain using example: i have resource employee. employee has following fields employee{ string firstname string lastname string emailid string manageremployeeid string employeeid } i want ability delete employee using of fields e.g. firstname , lastname , employeeid , or manageremployeeid how should resource paths ideally option1: option ? yes ? no ? why ? /employee/id/{employeeid} /employee/firstname/{firstname} /employee/lastname/{lastname} /employee/managerid/{managerid} option2: use of query params /employee?id=100 ( delete employee id 100) /employee?firstname=tom&lastname=winn (to delete employee named tom winn) /employee?manageremployeeid=400 (delete employees having manager id 400) option 1 looks rpc-ish me i second option find error prone since fields have specified. in 2nd option don't idea of having param named firstname , mapping firstname field in java clas

javascript - Basic Jquery - If Text exists in a TD then Make a DIV Visible -

i'm trying make div on page appear if word exists later on page? , i'd display if words in list of 10 appear on page? place want them inside of td class "sku nobr" after span class "td-title" i'm total rookie @ this, got work h1 value code don't know how 4523 now?? thanks!!!!! <script type="text/javascript"> $(document).ready(function(){ if ($(".sku nobr:contains('4523')").length) { $("#thingtohide").removeattr("style").none(); } }); </script> <div id="thingtohide" style="display: none;">cool text display</div> <tr class="cart-item-row"> <td class="sku nobr"> <span class="td-title">sku:</span> 4523 </td> </tr> first, html not valid. you're missing <table></table> tags. <div id="thin

python - Collecting tweets using screen names and saving them using Tweepy -

i have list of twitter screen names , want collect 3200 tweets per screen name. below codes have adapted https://gist.github.com/yanofsky/5436496 #initialize list hold tweepy tweets alltweets = [] #screen names r=['user_a', 'user_b', 'user_c'] #saving tweets writefile=open("tweets.csv", "wb") w=csv.writer(writefile) in r: #make initial request recent tweets (200 maximum allowed count) new_tweets = api.user_timeline(screen_name = i, count=200) #save recent tweets alltweets.extend(new_tweets) #save id of oldest tweet less 1 oldest = alltweets[-1].id - 1 #keep grabbing tweets until there no tweets left grab while len(new_tweets) > 0: print "getting tweets before %s" % (oldest) #all subsiquent requests use max_id param prevent duplicates new_tweets = api.user_timeline(screen_name = i[0],count=200,max_id=oldest) #save recent tweets alltweets.extend(

random - Randomize TODO list? -

i have noticed when @ todo list, things done top half of portion since read top bottom, , time half way bottom, find todo done. wondering, there way mix todo list ordering randomized? as mentioned org-sort let's specify function sort by: if sorting-type ?f or ?f, getkey-func specifies function called point @ beginning of record. must return either string or number should serve sorting key record. as happens random function returns random number. m-x org-sort f random randomize sort order in org file. however instead of changing file use org-agenda view todos in randomized order. setting org-agenda-cmp-user-defined can customize sort order. function take 2 arguments (the agenda entries compare) , should return -1,1 or 0 depending on of entries "smaller". here such function: (defun org-random-cmp (a b) "return -1,0 or 1 randomly" (- (mod (random) 3) 1)) and here agenda view shows todo items in random order: (add-to-li

xpath - Checking if attribute exits if only then select element -

my xpath works file when there attribute name test. <a> <b test="added"> <c>test</c> </b> </a> xpath //b[@test !='deleted']/c/text() but same xpath not work when there no attribute name test. <a> <b> <c>test</c> </b> </a> xpath //b[@test!='deleted']/c/text() what should make work if there no attribute name test. try using not(@test ='deleted') instead : //b[not(@test ='deleted')]/c/text() this xpath matches b elements test attribute doesn't equal 'deleted' , including case when attribute test not present. demo: xpathtester , xpatheval xml: <root> <a> <b test="added"> <c>test</c> </b> </a> <a> <b> <c>test</c> </b> </a> </root> output : test test

Insert if DNE else update Mysql row -

i trying `on duplicate key update' keeps adding new row instead of updating. insert favorites (userid, topicid) values ('2', '50') on duplicate key update active = 0; my favorites table set follows: favoritesid (ai) userid topicid active (boolean) if userid , topicid exist (both of them in same row), want change active 0. is possible? in order hit on duplicate key key has exists prior of insert. if there aren't unique keys in there, won't tu use it. either add unique key or have query first find out if value exists in table before inserting.

sed - append text after match from multiple file locations -

am noob when comes coding bear me... trying write script input data 3 separate files 3 specific locations within text file - example: edited read easier #start of script start_of_line1_text "$1" end_of_line1_text start_of_line2_text "$2" end_of_line2_text start_of_line3_text "$3" end_of_line3_text #output text when done $1 value in text1 $2 value in text2 $3 value in text3 i thinking of using sed cant quite work out how done... or insert word @ $1 after matching random_text? ie: sed '/start_of_line1_text/ middle_of_line1_text' input also on larger scale - if text1,2 , 3 had multiple values in how import these values 1 @ time , save new file each time? example: text1 = b c text2 = e f g text3 = h j #start of script start_of_line1_text "line 1 of text1" end_of_line1_text start_of_line2_text "line 1 of text2" end_of_line2_text start_of_line3_text "line 1 of text3" end_of_line3_text #output text

c++ - JNI - Java exits before native threads finish executing -

i'm in stages of developing api in c++, i'm wrapping in java using jni. native code creates socket listener thread using winapi should run indefinitely, thereby keeping program open indefinitely (tested , works fine). however, when try invoke code in java, jvm still terminates when reaches end of main, ignoring running thread. little research has hinted java might think thread daemon rather "user thread". if that's case, can't quite figure out how convince java user thread. does have clue this? you need call attachcurrentthread() native threads, ensure java knows them, wait them finish.

Git Pull opens VIM even with --no-edit -

Image
the "vim opens asking commit message after implicit non-conflicting merge" seems relatively common issue, seems relatively simple answer : git config --global core.mergeoptions --no-edit . unfortunately doesn't seem work me or @ least 8 of other 15 people in class, , our instructor bit baffled (though fair hasn't had time beyond quick google search or two). isn't that big of issue, can escape out enough :q , we'd know answer to, , google searches return stack overflow questions --no-edit solution (either via core or every time pull done). my .gitconfig (minus personal info): [mergetool "kdiff3"] path = "/c/program files/kdiff3/kdiff3.exe" [merge] tool = kdiff3 [core] mergeoptions = --no-edit [mergetool] keepbackup = false and yet: . does know why fix isn't working (ie: "ya dun goofed in spelling 'options'"), or if there better/more reliable way fix this? you ne

Python Pandas: Plotting 100% stacked graph issue -

Image
i got dataframe df5 following table read in read_csv, week_days,category,total_products_sold,total_profit 0.monday,a,3221,9999.53 0.monday,b,1038,26070.33 0.monday,c,699,13779.56 0.monday,e,3055,18157.26 0.monday,f,47569,215868.15 0.monday,g,2348,23695.25 0.monday,h,6,57 0.monday,i,14033,64594.24 0.monday,j,13876,47890.91 0.monday,k,3878,14119.74 0.monday,l,243,2649.6 0.monday,m,2992,16757.38 1.tuesday,a,2839,8864.78 1.tuesday,b,1013,26254.69 1.tuesday,c,656,13206.98 1.tuesday,e,2696,15872.45 1.tuesday,f,43039,197621.18 1.tuesday,g,2107,21048.72 1.tuesday,h,3,17 1.tuesday,i,12297,56942.99 1.tuesday,j,12095,40724.2 1.tuesday,k,3418,12551.26 1.tuesday,l,243,2520.3 1.tuesday,m,2375,13268.28 2.wednesday,a,2936,9119.93 2.wednesday,b,1061,26927.86 2.wednesday,c,634,10424.05 2.wednesday,e,2835,16627.35 2.wednesday,f,46128,218014.59 2.wednesday,g,1986,19173.64 4.friday,h,24,233 4.friday,i,17576,81648.75 4.friday,j,16468,55820.9 4.friday,k,4294,16603.39 4.friday,l,440,4258.51 4.friday,m,3

How to write a Filter ( using DB ) with Highland.js -

i'm trying design workflow using highland.js. have not able figure out how highland.js can used it. i have stream based workflow below (pseudo code), read //fs.createreadstream(...) .pipe(parse) //jsonstream.parse(...) .pipe(filterduplicate) //mongoclient.db.collection.count({}) > 0 .pipe(transform) //fn(item) { return tranform(item); } .pipe(write); //mongoclient.db.collection.insert(doc) the filterduplicate looks database check if read record exists (using condition) , returns boolean result. filter work, needs active db connection, want reuse till stream complete. 1 way have open connection before read , close on 'finish' event of write; means need pass connection param filter , write, work if both methods use same database. in above workflow, filterduplicate , write may use different databases. expect connection contained , managed with-in each function, makes self-contained reusable unit. i'

getting text from textfield java fxml -

here fxml code , java controller file code. trying text textfield tf in handle event using "string s = tf.gettext().tostring();" not getting executed. <?xml version="1.0" encoding="utf-8"?> <?import javafx.geometry.*?> <?import javafx.scene.control.*?> <?import java.lang.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.layout.anchorpane?> <anchorpane fx:id = "apane" prefheight="268.0" prefwidth="379.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="sample.searchcontroller"> <children> <vbox layoutx="20.0" layouty="36.0" prefheight="232.0" prefwidth="333.0"> <children> <hbox prefheight="36.0" prefwidth="333.0"> <children> <label fx:id= "kw" text="key wor

ios - How to let the user upload images - how can I test this feature properly? -

my code works , lets me pick image kind of default saved camera roll apple has built in on computer. if understand right - whenever person use app of course have connect personal phone. my question is: i'm trying test app using photos computer instead of default photos apple provides (landscapes , pictures of waterfalls). there way can directly access folder on desktop when click browse files button ( btnclicked ) , pull picture out of there? here i'm using right now. how can manipulate need? // custom image var imagepicker = uiimagepickercontroller(); @iboutlet weak var imageview: uiimageview! // button clicked image @ibaction func btnclicked(sender: anyobject) { if uiimagepickercontroller.issourcetypeavailable(uiimagepickercontrollersourcetype.savedphotosalbum){ print("button capture") imagepicker.delegate = self imagepicker.sourcetype = uiimagepickercontrollersourcetype.savedphotosalbum;

scala - How to flatmap a nested Dataframe in Spark -

i have nested string shown below. want flat map them produce unique rows in spark my dataframe has a,b,"x,y,z",d i want convert produce output like a,b,x,d a,b,y,d a,b,z,d how can that. basically how can flat map , apply function inside dataframe thanks spark 2.0+ dataset.flatmap : val ds = df.as[(string, string, string, string)] ds.flatmap { case (x1, x2, x3, x4) => x3.split(",").map((x1, x2, _, x4)) }.todf spark 1.3+ . use split , explode functions : val df = seq(("a", "b", "x,y,z", "d")).todf("x1", "x2", "x3", "x4") df.withcolumn("x3", explode(split($"x3", ","))) spark 1.x dataframe.explode (deprecated in spark 2.x) df.explode($"x3")(_.getas[string](0).split(",").map(tuple1(_)))

django get all running/pending celery task for current django user -

is there pythonic way running/pending celery tasks current loggedin django user? pseudo code trying: @celery.task def process_task(user, task_to_do): #get running or pending(queued) task current user user_tasks = user.get_task(status=pending or status=started) if not user_task: #allow user schedule additional task process.... else: return "your previous tasks running" that's in general tricky task. first need implement inspecting of workers inspector = app.control.inspect() scheduled = inspector.scheduled() reserved = inspector.reserved() active = inspector.active() celery them broker. point - broker not store information user, need add user task kwargs . user_task.delay(user=user) than you'll able filter results thees functions kwarg user in result: [{'worker1.example.com': [{'eta': '2010-06-07 09:07:52', 'priority':

wsdl - SOAP Response error -must not contain the < character -

getting error java.lang.runtimeexception: exception in preinvoke : javax.xml.soap.soapexception: org.xml.sax.saxparseexception; linenumber: 6; columnnumber: 47; value of attribute "arasaml" associated element type "tcin:applyamlintcinputdata" must not contain '&lt;' character. i testing webservice in soap ui , below soap request. <soapenv:envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/"; xmlns:tcin="de4.com/schemas/tcintgn/2013-05/tcintegration">; <soapenv:header/> <soapenv:body> <tcin:applyamlintcinput> <tcin:applyamlintcinputdata arasaml="<xml><revisions><item_revision><itemno>000147</itemno><type>pdf,directm‌​odel,mspowerpointx</type></item_revision></revisions></xml>" message="downloaddatasetfile" > </tcin:applyamlintcinputdata> </tcin:applyamlintcinput> </soapenv:body> </soapenv

python 2.7 - how to get return response from AWS Lambda function -

i have simple lambda function returns dict response , lambda function invokes function , prints response. lambda function a def handler(event,context): params = event['list'] return {"params" : params + ["abc"]} lambda function b invoking a a=[1,2,3] x = {"list" : a} invoke_response = lambda_client.invoke(functionname="monitor-workspaces-status", invocationtype='event', payload=json.dumps(x)) print (invoke_response) invoke_response {u'payload': <botocore.response.streamingbody object @ 0x7f47c58a1e90>, 'responsemetadata': {'httpstatuscode': 202, 'requestid': '9a6a6820-0841-11e6-ba22-ad11a929daea'}, u'statuscode': 202} why response status 202? also, how response data invoke_response? not find clear documentation of how it. a 202 response means accepted . successful

python - Searching unique web links -

i wrote program extract web links http://www.stevens.edu/ . facing following problems program. 1- want links starting http , https 2 - getting parser warning bs4 concerning lack of specification on parser - solved how can fix problems? not getting proper direction solve problem. my code - import urllib2 bs4 import beautifulsoup bs url = raw_input('please enter url want see unique web links -') print "\n" urls (mostly http) in complex world req = urllib2.request(url, headers={'user-agent': 'mozilla/5.0'}) html = urllib2.urlopen(req).read() soup = bs(html) tags = soup('a') count = 0 web_link = [] tag in tags: count = count + 1 store = tag.get('href', none) web_link.append(store) print "total no. of extracted web links are",count,"\n" print web_link print "\n" unique_list = set(web_link) unique_list = list(unique_list) print "no. of unique web links after using set me

javascript - div display:none when 'word' is in the url -

tried googling around , can't seem able find if possible. use ipboard , due recent ips4 update can no longer change homepage have add divs global layout meaning appear on every page, aren’t i’m wanting. so wondering if possible via javascript of jquery hide div when url contains word. example div appear on home 'domain.com/’, not on 'domain/hidden/' if isn’t possible let me know , i’ll remove it, i’m reasonably new javascript , jquery know html/css please patient. if(window.location.href.indexof("my-word") !== -1) { $("#my-div").hide() }

.net - Specify one parameter for Func at declaration time and another at invoke/execution time -

from research have not found evidence possible, wondering if there way or next cleanest solution? i want avoid having pass argument generic function keep clean , improve modularity. consider following generic looping function invokes predicate function check condition while looping collection: private sub loopandapplycondition(of t)(byval collection idatacollection, byval condition func(of t, string, boolean), byref result list(of t)) if not collection.activeitems nothing , collection.count > 0 each record in collection '*** '*** pass in record predicate function here *** '*** dim meetscondition boolean = condition.invoke(ctype(record, t)) if meetscondition result.add(ctype(record, t)) next end if end sub this defines predicate function(condition) , calls generic looping function, has attributename field pass predicate function. public function alleditablerecords(of t)(byval collection idataobjectcollection, byval attrib