Posts

Showing posts from August, 2010

rspec - Rails 4 Paperclip FactoryGirl file uploading -

i have factorygirl :product factory uses fixture_file_upload set image , paperclip attachment. image { fixture_file_upload "#{rails.root}/spec/fixtures/images/product.png", 'image/png' } fixture_file_upload works fine, but every time test creates new product using factory, paperclip creates new file in publicproducts/<id>/original.png . this issue. . filling folder publicproducts on each test run not acceptable. the first workaround can think of solution mentioned in https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-cleanup-after-your-rspec-tests have solved problem in way? the solution, mentioned deep to: specify paperclip in test environment should upload files folder test_uploads , modify factory_girl factories upload fixture ex. spec/fixtures/images/filename.extension , add after cleanup block in rails_helper.rb in code: config/environments/test.rb ... config.paperclip_defaults = { path: ':r

javascript - Angular ng-click: $scope variable change followed by promise prevents scope from updating -

i have ng-click function should change button text , run asynchronous function. template <button ng-click="connect()">{{buttontextconnect}}</button> connect() $scope.connect = function() { console.log('try connecting'); $scope.buttontextconnect = 'connecting...'; thermprobe.connect().then( function() { $scope.connected = true; }, function() { $scope.connected = false; } ); } the console.log displayed. $scope.buttontextconnect not update text within button however. thermprobe.connect() angular promise. if comment out async call thermprobe.connect() button text updated expected. here working ionic play demo , works expected. button text changes when clicked , promise resolves later. why asynchronous call prevent $scope change updating in template?

java - Encounter images in between the text while parsing pdf using tika-server -

i able fetch images , coordinates pdf using pdfbox. when parse pdf using tika server, text only. how know when image occures can put image after text. using code given in following 1st answer: extract images pdf using pdfbox i using tika server 1.7 talking data of pdf in parser , using plain text version. want know while parsing, how know image encountered. i got html output using prasetohtml() @ link https://tika.apache.org/1.10/examples.html still not giving me images present in pdf. nor giving tag.

select - mysql get number between two field containig 20digit long decimal number -

Image
i have table 'serial' containing 2 field start_serial_no , end_serial_no have serials 20 digit longs(may vary). i have 3 entries in table as user enter serial number, have find in start , end pair belongs. using following returns 2 values output(1st , third) '899190150504778850' , third '899190150504778950'. instead should return third both. select * `serial` '899190150504778850' between `start_serial_no` , `end_serial_no` update: suggested in comment, seems longint can store numbers a range of 0 18446744073709551615 unsigned numbers , varchar can used achieve same number higher this. -- your code correct. outputs want - in case, return third set of data. i tried creating exact columns , inserting exact data table. running query gave me desired result. try again same query. if encounter problem, please follow up.

oop - Creating a custom object in PHP, that is sent to a SOAP service -

i trying build customer object in php , send asmx web service. works fine except build array inside php. when send web-service last order history appears. here contract specified web service. note pizza-code , not actual code contract contain sensitive data. public class customer { public int customerid { get; set;} public int name { get; set;} public int surname { get; set;} public orderhistory history { get; set;} } public class orderhistory { public int numberoforders { get;set;} public orders[] orders { get;set;} } public class orders { public int orderid { get;set;} public decimal total {get;set;} } here how build php object. $params_create_save = array("customer" => array("customerid" => "111", "name" => "joe", "surname" => "soap", "history" => array("numberoforders" => "10",

javascript - Printing Div with Images -

i working on mvc c# app wherein contents of div composed ajax call retrieves database fields , returned success message javascript. string (a trivial example): "<div style='background:yellow'>asdf<img src='myfile.jpg'></div>" is printed with: function printdivcontents(contents) { var printcontents = contents; var originalcontents = document.body.innerhtml; document.body.innerhtml = "<div style='margin:10px'>" + printcontents + "</div>"; window.print(); document.body.innerhtml = originalcontents; } everything prints in cases, there image in there prints if , if has been loaded previously. print. have tried adding preloading script content string. can use pure javascript, not jquery, , css has inline. options image load? should pause execution wait dom load, assign image hidden div background on calling page, or...? on page makes initial ajax call, create hidden di

how to handle nulls in date coulmn in teradata -

this sql , want handle nulls date coulmn . sql: insert r_intraday_netrev ( report_time, snapshot_time, prodtype, qty, yestasp, m2_cumpct, m2_predictedunits, m2_rev, m3_cumpct, m3_predictedunits, m3_rev) select current_time report_time, **max(ss_sb1.snapshot_time),**------want handle nulls date coulmn 'ztotal', null, null, null, null, sum(round( ( (ss_sb1.qty / ss_p2.cumpct) * ss_sb2.asp ) , 0)), null, null, sum(round( ( (ss_sb1.qty / ss_p3.cumpct) * ss_sb2.asp) , 0)) dw_core.ss_topline_a_v ss_sb1 left outer join dw_core.ss_topline_rsst_b_v ss_sb2 on ss_sb1.prodtype = ss_sb2.prodtype left outer join dw_core.ss_predict_p2_v ss_p2 on (ss_sb1.prodtype = ss_p2.prodtype , td_day_of_week(ss_sb1.snapshot_time) = ss_p2.dayofweek , substr(to_char(ss_sb1.snapshot_time, 'hh24mi' ),1,3)||'0' = ss_p2.timeofday) left outer join dw_core.ss_predict_p3_v ss_p3 on (ss_sb

authentication - How to verify user ios sing in with google plus account ? server side -

i build login button in ios app . have followed documentation . the login @ ios app work fine. , succeed receive auth object : {accesstoken="***********", refreshtoken="*****", code="*******", expirationdate="2015-07-27 11:00:07 +0000"} also succeed 1 time auth code [gppsignin sharedinstance].homeserverauthorizationcode; now should do. according document, should send homeserverauthorizationcode server. exchange access token. doesn't mention how that. i found article https://developers.google.com/identity/sign-in/web/server-side-flow describe how access token . doesn't show how ! also after succeed retrieve token. how call google plus api. retrieve user profile example ? first have install google client package in project "google/apiclient": "^2.0.0@rc" then ios authorized array, can find "server_code":"**********" . server code can new authenticate result (acees_tok

java - wso2:cep:Executing Time Window queries on Siddhi Engine -

i using java servlet has siddhi core,api , query jar libraries. using siddhimanager class create streams,queries , callbacks. servlet allows me run regular queries doesn't query time window based queries such - from statustime#window.time(4 min) select cid,sum(values) sum group cid having (sum>40) insert payt each time servlet called time window re initiated , result time based queries fail. how make siddhi manager use initiated time window. i don't think initialising , marinating siddhi instances (which state full engine) in servlet option. please move outside servlet , maintain separately.

android - AndroidManifest permission as displayed in Google Play -

where possible find mapping between android manifest specified permission group , text displayed user when downloading published application form google play store? example: <uses-permission android:name="android.permission.internet"/> translates into: network communication full network access is mean?manifest.permission http://developer.android.com/reference/android/manifest.permission.html app permission

Google Chrome developer tools element properties analysis -

can explain space colored in orange means? firstly, considered margin spacing saw margin equals zero. screenshot (sorry, can't yet post pictures on stackoverflow) thanks in advance. i think still margin. everywhere displayed correctly , chrome says margin. margin rare bug in there.

compiler construction - Implementing a game engine specific programming language -

sorry spelling mistakes or basic grammar faults, never @ english @ school... , of course in advance. my goal make game engine , editor easy use users, can still used develop quality 3d games. to facilitate users i'd implement custom programming language designing game logic, ai behavior, weapon systems , on. restricting them low level aspects of engine. eventually make game engine able support multiple platforms, don't have money buy platforms i'd include, can not implemented now... my first notion build scripting language, i'm worried system overhead of not running user code native. because user example able edit mesh vertices, creating custom path-finding system, or other more computation intensive tasks. so assumed compiling user code binary best option. , many questions start pop up. i prefer aware of going on in generated executable, , have full control of result. , not fond use existing tools such llvm generate executable in fear of losing control.

parallel processing - OpenMP not work with an array access indirect -

i'm trying optimize loop in parallel way openmp. double precision, intent(inout) :: x(13541) integer , intent(in) :: nelem,nelmax !nelmax = 25996 integer , intent(in) :: ikle(nelmax) double precision, intent(in) :: w(nelmax) !$omp parallel private(ielem) reduction(+:x) ielem = 1 , nelem x(ikle(ielem)) = x(ikle(ielem)) + w(ielem) enddo !$omp end parallel for , j different, it's possible ikle(i)=ikle(j) increasing number of threads, found takes longer run loop. use omp_get_wtime() time job. 1 t 0.21943306922912598 2 t 0.30610203742980957 3 t 0.43688893318176270 4 t 0.53783702850341797 5 t 0.61055016517639160 6 t 0.96715998649597168 7 t 0.89582014083862305 8 t 1.3073339462280273 i think problem caused array access indirect don't know how deal in openmp if it's possible ikle(i)=ikle(j) have worse problem irregular access trashing hopes of efficient use of cached dat

php - Using Curl in CodeIgniter : How to send data using post method -

not going succeed when trying send data using post method. never used before. this code of executing curl: $url = license_url."validate_system_key/validate_key/"; //url-ify data post $data['system_key']='a8z0-x1n7-s1v2-y1i5'; $data['domain']='http://example.com'; $fields_string = ''; foreach($data $key=>$value) { $fields_string .= $key.'='.$value.'&'; } $fields_string = rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set url, number of post vars, post data curl_setopt($ch,curlopt_url,$url); curl_setopt($ch,curlopt_post,count($data)); curl_setopt($ch,curlopt_postfields,$fields_string); curl_setopt($ch,curlopt_connecttimeout,10); # timeout after 10 seconds, can increase //curl_setopt($ch,curlopt_header,false);

python - Error Handling in Tornado -

i'm new tornado , writing basic application need add error handling. below code. import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web tornado import gen tornado.web import asynchronous tornado.options import define, options define("port", default=8888, help="run on given port", type=int) class application(tornado.web.application): def __init__(self): handlers = [ (r"/", homehandler), (r"/mycompany", mycustomhandler), (r"/mycompany/", mycustomhandler), ] super(application, self).__init__(handlers) class homehandler(tornado.web.requesthandler): def get(self): self.render("home.html") class mycustom(tornado.web.requesthandler): def get(self): self.write("processing....") self.clear() self.finish() def main(): tornado.optio

javascript - Using "filters" parameter in Google API request always results in an error? -

i'm experimenting querying google analaytics core reporting api. i've hit bug can't figure out. i'm in days i've copied example javascript implemtation quickstart guide . ran this, works, lovely. so started playing parameters , seemed fine until entered filter, so this worked // query core reporting api number sessions // past 7 days. gapi.client.analytics.data.ga.get({ 'ids': 'ga:' + profileid, 'start-date': '7daysago', 'end-date': 'today', 'dimensions':'ga:browser', 'metrics': 'ga:pageviews' }) doesn't work gapi.client.analytics.data.ga.get({ 'ids': 'ga:' + profileid, 'start-date': '7daysago', 'end-date': 'today', 'filters':'ga:city%3d%3dirvine', 'dimensions':'ga:browser', 'metrics': 'ga:pageviews' }) results in error:

mysql - How to take stored procedure backup as i already uninstalled wamp? -

i uninstalled wamp , reinstalled on drive . have taken folder c:\wamp\bin\mysql\mysql5.5.24\data d:\wamp\bin\mysql\mysql5.6.17\data database. takes tables , data not stored procedures. can 1 explain me location of stored procedures files restore again? you cannot copy databases between different versions of mysql database manager. things change when version numbers change. i think have reinstall d:\wamp version of wampserver undo mistake of copying mysql5.5 data mysql5.6 environment. do uninstall manually delete d:\wamp reinstall onto d: check basic stuff works stop wampserver now copy backup of c:\wamp\bin\mysql\mysql5.5.24\data d:\wamp\bin\mysql\mysql5.5.24\data note should have 2 folders under d:/wamp/bin/mysql so have 2 versions of mysql installed , available on new instance of wampserver. start wampserver switch old mysql version left click wampmanager->mysql->version , click on 5.5.24 take backup of databases want migrate new version

multithreading - C# Join() not return control after thread is over -

i have class this: class someclass { bool iswork; thread workthread; public void start() { iswork = true; workthread = new thread(new threadstart(dowork)); workthread.setapartmentstate(apartmentstate.sta); workthread.isbackground = true; workthread.start(); } public void stop() { iswork = false; workthread.join(); } } void dowork() { while (iswork) { // work thread.sleep(100); } } when application starting create instance of someclass , call start() method. call stop() method of instance ui thread and: iswork set "false"; main thread join workthread; workthread check isworked , finishet correctly; main thread freeze on workthread.join(). as understant joined thread should continue executing after workthread over, it's not true in situation. at moment when main thread call workthread.join() workthread alive , exists in debug thread wind

How to iterate through array of objects in Swift? -

i have objects var person1 = person() person1.name = "joe" person1.lastname = "doe" person1.age = 21 var person2 = person() person2.name = "julia" person2.lastname = "ivanova" person2.age = 22 var person3 = person() person3.name = "irina" person3.lastname = "petrova" person3.age = 25 var person9 = person() person9.name = "vova" person9.lastname = "vovin" person9.age = 32 var person10 = person() person10.name = "masha" person10.lastname = "golovanova" person10.age = 20 var person11 = person() person11.name = "petra" person11.lastname = "andreeva" person11.age = 27 and multi array var array = [[person1, person2, person3], [person9, person10, person11]] how can iterate through array example person name="masha" thanks in advance i try this: var array:[[person]] = [[person1, person2, person3], [person9, person10, person11]] /*casting

asp.net mvc 3 - Two different actions on same view in mvc3 with razor -

i have created 1 application mvc3 (razor) named studentapp. have 1 page index page. want add 2 actions on same page. action 1: insert new student. action 2: search student. so how should maintain 2 different actions on same view. you don't have actions on view. have action guides users index view, on view, have buttons or forms calls different actions (insertion, search). your controllers should able recognize action being called, process , call appropiate view. also, each view should able render appropiate info depending on situation.

c# - How can I avoid detection of second collision of same objects in Unity3d? -

i making game in style of old "lotus" games (player's car moves on bottom of screen left , right only, opponents car appear on top , "chased" move down towards player's car). have rigidbodies on cars , when player's car collides other 1 want detect but once . i use: void oncollisionenter (collision collision) { contactpoint contactpoint = collision.contacts [0]; gameobject cube = gameobject.createprimitive (primitivetype.cube); cube.transform.position = contactpoint.point; } with code cube created 1-5 times , means collision occures several times on same object. achieve after first collision 1 not reported (no cube collision should created) still 1 cube should created when collision opponent car occurs. in short: 1 cube each collision opponent cars. intend use kind of score calculations. any ideas? i think should create bool variable. private bool detectedcollision = false; , when detect collision @ first turn variabl

html - remove white border footer -

Image
how can remove white border on bottom of browser (google chrome)? this code have used: footer { color: white; width: 101%; margin-left: -8px; background-color: #343434; margin-left: -16px; width: 101.5%; margin-top: -8px; height: 40px; z-index: 100; } footer > div { width: 1000px; margin: 0 auto; } <main> <!--main things--> </main> <footer> <div> <p>fastcycle werdt gecreëerd door hp-programming vzw. copyright &copy; 2015</p> </div> </footer> i have try place margin-button set on 0 didn't help. have place margin-left -16px , width 101.5%? why? can me? thanks you can try adding following <body> tag: <body style="padding: 0; margin: 0;"> or alternatively, create new css class: body { padding: 0; margin: 0; } if doesn't work, in chrome, if press f12, bring panel allows view styles of elements. hover on element

Can you create polyfills in swift using availability checking? -

swift 2 lets check current platform , version make sure newer methods/properties available , allow write fallback code if not, writing conditional block #available . so example, in osx10.10, nstextfield has property called placeholderstring , in older versions, had access info via intermediate nstextfieldcell object. safely use new system fallback old 1 this: var placeholder : string if #available(osx 10.10, *) { placeholder = inputbox.placeholderstring! } else { placeholder = (inputbox.cell as! nstextfieldcell).placeholderstring! } swift allows extend existing classes extension for example, adding placeholder property nstextfield extension nstextfield { var placeholderstring: string? { return (self.cell as! nstextfieldcell).placeholderstring } } so... possible combine these 2 ideas , create polyfill, extend class conditionally on current platform, in order retrospectively add features of new api older platforms? so in example, want write t

swift2 - Why am I ALWAYS getting SSL error when contacting Parse.com? -

Image
environment: xcode 7.0/swift 2.0. connect parse via xcode 6.4/swift 1.2; after switching xcode 7.0/swift 2.0 i've been getting following runtime connection error: an ssl error has occurred , secure connection server cannot made. (code: 100, version: 1.7.5) [error]: network connection failed. making attempt 5 after sleeping 9.864530 seconds. nsurlsession/nsurlconnection http load failed (kcfstreamerrordomainssl, -9802) read may due ios 9's security setup . setting .plist value 'nsapptransportsecurity' turn off security check didn't change anything. problem occurs in simulation or device; every time. how can access parse.com i've done? i went apple's security doc site find didn't set plist correctly. following works: allows me access parse within ios9:

c - Use Parameter Name of #define in another #define -

is there way use name of #define parameter #define parameter? example: #define test 1 #define foo(x) foo_##x #define bar(x) foo(##x) bar(test) where results in: foo_test not: foo_1 this doesn't work gives: pasting "(" , "test" not give valid preprocessing token there 2 ways avoid evaluation of macro argument. use # (stringize) processing operator or ## (token pasting) operator on it. try following: #include <stdio.h> #define test 1 #define foo(x) foo ## x #define bar(x) foo(_ ## x) // prevent evaluation of x ## void foo_1() { printf("%s\n", __function__); } void foo_test() { printf("%s\n", __function__); } int main() { bar(test)(); return 0; }

javascript - jquery dialog widget not passing my form value -

Image
i have table image bellow create query databases, each row have button when onclick prompt dialog box (i use jquery dialog widget) this myform html code <form action="prodi_tampil_mhs.php" method="post" name="form_tambah_cl_wisudawan" id="form_tambah_cl_wisudawan"> this php code create table query database while ($fetch_dbsi_mhsw=mysql_fetch_array($query_dbsi_mhsw)) { $no++; echo" <tr> <td>$no</td> <td>$fetch_dbsi_mhsw[nim]</td> <td>$fetch_dbsi_mhsw[name]</td> <td style=\"text-align: center;\"><input name=\"bt_tambah_calon_wisudawan\" id=\"bt_tambah_calon_wisudawan\" type=\"image\" src=\"buttontambah.png\" alt=\"tambah\" align=\"middle\" width=\"20\" height=\"20\" class=\"bt_tambah_calon_wisudawan\" /></td></tr>";} and jquery code $(document).ready(

c# - Implicitly converting a generic to a wrapper -

i'd automatically wrap value in generic container on return (i aware not desirable, makes sense case). example, i'd write: public static wrapper<string> load() { return ""; } i'm able adding following wrapper class: public static implicit operator wrapper<t>(t val) { return new wrapper<t>(val); } unfortunately, fails when attempt convert ienumerable , complete code here (and at ideone ): public class test { public static void main() { string x = ""; wrapper<string> xx = x; string[] y = new[] { "" }; wrapper<string[]> yy = y; ienumerable<string> z = new[] { "" }; wrapper<ienumerable<string>> zz = z; // (!) } } public sealed class wrapper<t> { private readonly object _value; public wrapper(t value) { this._value = value; } public static implicit operator wrapper<t>(t val) {

sql server - How to extract strings between two special different characters in TSQL -

i using code following question: how extract strings between 2 special characters in tsql declare @c varchar(100) set @c = 'microsoft.systemcenter.useractionmanager:servername_1.domain.net;servername_2.domain.net' select substring(@c, charindex(':', @c) + 1, len(@c) - charindex('.', @c) - charindex(':', @c)) current result: servername_1.domain.net;servername_2. i want search column/string , extract string starting @ ':' , going first '.' . the result trying is: servername_1 the caveat server name vary in length. also, when try run following query: select substring(column_name, charindex(':', column_name) + 1, len(column_name) - charindex(':', column_name) - charindex(':', column_name)) [dbo].[servernametable] i following error: msg 537, level 16, state 3, line 1 invalid length parameter passed left or substring function. many in advance. sql fiddle this replace , incl

vba - How to add a picture to a powerpoint slide from excel [Solved] -

so have set macro saves charts excel spreadsheet pictures (as part of larger procedure), , need code paste these pictures, 1 per slide, slideshow. currently, have opened powerpoint presentation 4 blank slides, , have not managed import 1 picture. i have been using methods shape.addpicture("c:\users\restofpathname"), have not managed them work can help? thanks, btubnfj edit : solved following code : dim applpp powerpoint.application, prsntpp powerpoint.presentation, titlepage powerpoint.slide set applpp = new powerpoint.application applpp.visible = true set prsntpp = applpp.presentations.add set titlepage = prsntpp.slides.add(index:=1, layout:=pplayouttitle) prsntpp.saveas ("c:\users\...") dim oslide powerpoint.slide dim opicture powerpoint.shape set oslide = prsntpp.slides(1) set opicture = oslide.shapes.addpicture("c:\users\public\pictures\sample pictures\penguins.jpg", _ msofalse, msotrue, 1, 2, 3, 4) opict

java - Insert large JSON data from web service into mongodb -

i trying insert multiple records mongodb @ once return web service in json format. but got following error : info: monitor thread connected server description serverdescription{address=localhost:27017, type=standalone, state=connected, ok=true, version=serverversion{versionlist=[3, 0, 4]}, minwireversion=0, maxwireversion=3, electionid=null, maxdocumentsize=16777216, roundtriptimenanos=545196} exception in thread "main" java.lang.illegalargumentexception: basicbsonlist can work numeric keys, not: [_id] @ org.bson.types.basicbsonlist._getint(basicbsonlist.java:168) @ org.bson.types.basicbsonlist._getint(basicbsonlist.java:160) @ org.bson.types.basicbsonlist.get(basicbsonlist.java:105) @ com.mongodb.dbcollection.insert(dbcollection.java:309) @ com.mongodb.dbcollection.insert(dbcollection.java:284) @ com.mongodb.dbcollection.insert(dbcollection.java:250) @ com.mongodb.dbcollection.insert(dbcollection.java:18

javascript - How is .call supposed to work for ES6 Arrow Functions (according to the standards)? -

i using cross-compiler (babel, typescript) es6 , not support proper .call behavior functions made => syntax; when call them .call , this value still 1 inherited parent scope when first made them, instead of being first argument passed in .call . is intentional behavior, per es6 standards (which disappointing)? or limitation of cross-compiler? this the spec says: an arrowfunction not define local bindings arguments, super, this, or new.target. any reference arguments, super, this, or new.target within arrowfunction must resolve binding in lexically enclosing environment. i.e. it's fixed context in defined. can't dynamically change it. on function.prototype.call says: if func arrow function or bound function thisarg ignored function [[call]] in step 5.

asp.net mvc - Tabs in material desing lite like simple ActionLinks -

i have question regarding tabs in material desing lite. here sample usage of tabs in mdl. <div class="mdl-tabs mdl-js-tabs"> <div class="mdl-tabs__tab-bar"> <a href="#tab1" class="mdl-tabs__tab">tab one</a> <a href="#tab2" class="mdl-tabs__tab">tab two</a> </div> <div class="mdl-tabs__panel is-active" id="tab1"> <p>first tab's content.</p> </div> <div class="mdl-tabs__panel" id="tab2"> <p>second tab's content.</p> </div> </div> looks pretty straightforward tabs simple content if have many tabs each complex content. how can make tabs work simple actionlinks perks ripple animation , is-active class. solution put link tabs this. <div class="mdl-layout__tab-bar mdl-js-ripple-effect mdl-color--primary-dark"> @foreach (var tab in mod

microsoft band - Heart monitor sensor / Photoplethysmography -

i'm comparing several health monitor bands , sensors in market. what photoplethysmograph sensor, , how compare optical heart rate sensor in ms band? is there mvp microsoft band yet? the hr sensor on band ppg sensor.

How long can GET URL #anchor be? -

i'm trying encode state of webpage in #anchor base64 encoding json string. string gets long, 10kb example. i'm not can keep data in #anchor. does know if #anchor part of url length definition? if 2048? or 4096? there conflicting answers url length. if isn't how data can put in #anchor?

scala - java.lang.SecurityException:class "javax.servlet.FilterRegistration" information does not match signer information of other classes in same package -

i new programming in spark scala. trying run following program: import org.apache.spark.sparkcontext import org.apache.spark.sparkconf object testmain { def main(args: array[string]) { val logfile = "spark-1.4.1/readme.md" // should file on system val conf = new sparkconf().setappname("simple application") .setmaster("spark://myhost:7077") val sc = new sparkcontext(conf) val logdata = sc.textfile(logfile, 2).cache() val numas = logdata.filter(line => line.contains("a")).count() val numbs = logdata.filter(line => line.contains("b")).count() println("lines a: %s, lines b: %s".format(numas, numbs)) } } my build.sbt follows: name := "testspark" version := "1.0" scalaversion := "2.10.4" librarydependencies += "org.apache.spark" %% "spark-core" % "1.4.1" % "provided" librar

c# - How to deserialize an immutable data structure? -

how deserialize yaml immutable data structure? e.g. have yaml: value: somestring number: 99 and data structure: public class mydata { public mydata(string value, int number) { value = value; number = number; } public string value { get; } public int number { get; } } for i'd use constructor. somehow i'd need first retrieve dictionary<string, object> parsed yaml respecting class (so 99 int, not string), scan type appropriate constructor, use formatterservices.getuninitializedobject api (this not invoke constructors @ all) , use reflection set fields. code example: var instance = formatterservices.getuninitializedobject(typeof(mydata)); var flags = bindingflags.nonpublic | bindingflags.instance; var type = typeof(mydata); var stringfield = type.getfield("_value", flags); stringfield.setvalue(instance, "somestring"); var numberfield = type.getfield("_number", flags); numbe

cron - Cronjobs in Docker container how get them running? -

i've got cronjobs in debian docker container. don't start automatically why? do have workarounds? if running containers in docker, can add cron tasks on docker host machine execute commands in docker containers. for example, run 'stress' application in container every 5 minutes can add following (substituting container id of course) crontab: */5 * * * * docker exec c78ddbed4ad9 /bin/sh -c 'stress -d 1 --hdd-bytes 64m --cpu 1 --io 2 --vm 2 --vm-bytes 64m --timeout 60s' >> /tmp/cronstress.log 2>&1 i running root user on docker host. or run cron: root@dockerhost:cron

matlab write equation in MATLAB? -

i have data in x , y , , want solve the next equation using matlab . how can write matlab code equation ? y= y1, ...,y(n-1),yn; x=x1,...x(n-1),xn for example c= 0.2345+5.423*y(n-1)*x(n-3)+2*y(n-5)*x(n-4) ok, describing vector/matrix multiplication problem, can code as: c0 = 0.2345; % first constant use in c n = 6; % sake of argument, assume n=6; m = [ 0 2 0 0 0 0; 0 0 0 0 0 0; 0 0 0 0 0 0; 0 0 0 0 0 0; 0 0 5.423 0 0 0; 0 0 0 0 0 0]; c = c0 + y' * m * x; i assuming both vectors, x , y column vectors. matlab notation says y' transpose of vector y , row vector. when write c = c0 + y'*m*x , (using pseudo-code) c = c0 + sum(i=1:n)( sum(j=1:n)( m(i,j) * y(i) * x(j) ) ) please note approach allows store any factor multiplying y(i)*x(j) in position m(i,j) .

java - Delete JNLP file after it's get executed -

is there anyway delete jnlp file after it's executed. when application opens in browser, jnlp file downloaded. don't want keep duplicate jnlp files want delete jnlp file after it's executed the jnlp downloads jar java application. application delete jnlp file.

performance - What's the impact of insufficient space for shared memory file in Java HotSpot? -

i have run lot of experiments (months of cpu time) have following warning in log: java hotspot(tm) 64-bit server vm warning: insufficient space shared memory file the experiments terminated without error, wonder may , may not evaluate them. so: what's impact of insufficient space shared memory file in java hotspot? details: all have found shared memory file http://openjdk.java.net/groups/hotspot/docs/serviceability.html . this, seem lack of shared memory file has little effect on experiments :) not use profiler or evaluating experiments, log file have created successfully. i measure how function foo() called. can lack of shared memory file change functional behaviour of program, should not evaluate experiments? furthermore, measure runtime , memory requirements. did jvm's performance change, should not evaluate experiments? finally, have experiments run distributed version of algorithm. jvm's performance change strongly, parallel functional beh

c++ - How many sig figs in a double? -

as know, floating point numbers can't represent numbers. i'm not asking question precision of floats or doubles. in program, floating point numbers "come somewhere". might originate promoting integer, others numeric literals. int x = 3; double xd = x; float xf = 3.0f; double xd2 = 3.0; of course, floating point numbers come calculations involving other numbers. double yd = std::cos(4.0); in problem, read in floating point numbers text file, , other times, receive them complex function must treat black box. creator of text file may choose enter many significant figures -- might use three, or perhaps eight. i perform computations using these numbers , know how many significant figures implied when created. for argument, consider performing adaptive piecewise least squares fit input points. continue splitting piecewise segments until tolerance achieved. want (in part) base tolerance on significant figures of input data -- don't fit 10^-8 if dat

javascript - AngularJS: objects, arrays, JSON, API issues -

create: i using $scope.services storing list of services. array of objects: $scope.services = [{ title : undefined, quantity : undefined, priceperunit : undefined, pricecalculated : undefined, order : undefined }]; i can push object array. $scope.services.push({ title : undefined, quantity : undefined, priceperunit : undefined, pricecalculated : undefined, order : undefined }); so far, good. using object model within angular, show content. update: i calling api , getting json in format: { somedata: "some data", services: { 0: { id: 101, offer_id: 101, title: "some title", ... }, 1: { ... } } } appending received data $scope.services = data.services , when calling $scope.services.push console error typeerror: $scope.services.push

git - Branches diverged after pull instead of push -

i accidentally did git pull instead of git push , got merge conflict. surprised git tried merge @ all, because remote branch didn't receive commits since last pull/push. since didn't want pull/merge, did git reset --hard followed git merge --abort . tried push, got message: on branch my_branch branch , 'origin/my_branch' have diverged, , have 17 , 1 different commit each, respectively. (use "git pull" merge remote branch yours) nothing commit, working directory clean how can state before accidental pull able push local commits remote branch? your remote did commit pushed. can have @ git tree using command: git log --all --graph --decorate --oneline maybe did git commit --amend or on 1 commit on remote. analyse output of command above (and post maybe in question) see commit want keep. since working on personal branch, might consider (note not ideal) crush (1) remote commit (17) local commits, using git push -f warning: in case

php - How to Handle a great number of rows with SQL Queries and take only small amount of data efficiently? -

i'm coding site in php, , site contain messages(like 100.000 , 200.000 or more) users post on site. problem is, messages stored on table called 'site_messages' it's id. means, messages aren't grouped poster, it's grouped id. if want fetch messages posted user 'foo', have query lot of rows, , slow think. or want fetch messages post subject(yes, contain post subject column too, , maybe more column add), must query table again, , unfortunately, less efficient. there speedy solutions that? i'm using php , mysql(and phpmyadmin). edit: example, table this: messageid: 1 messagecontent(varchar, message user posts): hi site. bye! messageposter(varchar): crazyuser messagepostdate: 12/12/09 messagepostedin(varchar, post subject): how make pizza messageid: 2 messagecontent(varchar): site reallllly sucks. messageposter(varchar): top_lel messagepostdate: 12/12/09 messagepostedin(varchar): hello, have question! messageid: 3 mess

c# - Linq - complex query - list in a list -

i have class: public class recipeline { public list<string> possiblenames { get; set; } public string name { get; set; } public int index { get; set; } } i have list of multiple recipeline objects. example, 1 of them looks this: name: apple possiblenames: {red delicious, yellow delicious, ... } index = 3 i have table in db called tblfruit , has 2 columns: name , id. id isn't same index in class. what want this: whole list of recipeline objects, find records in tblfruit name in possiblenames, , give me index of class , id in table. have list in list (a list of recipeline objects have list of strings). how can linq in c#? i'm pretty sure there isn't going linq statement can construct create sql query data how want. assuming tblfruit doesn't have too data, pull down whole table , process in memory like... var result = tblfruitlist.select((f) => new {id = f.id, index = recipelinelist.where((r) => r.possiblenames.contains(f

sql server - sql replication error - record exists on Publisher but it's trying to delete/insert that on Subscriber, so Foreign Key/Primary Key violation -

we have transactional one-way replication running, , today started getting error : the delete statement conflicted reference constraint "fk_branchdetail_branch". conflict occurred in database "locationdb", table "dbo.branchdetail", column 'branchnumber'. message: row not found @ subscriber when applying replicated command. violation of primary key constraint 'pk_branch'. cannot insert duplicate key in object 'dbo.branch'. duplicate key value (23456) disconnecting subscriber 'sqldb03' publisher - sqldb02.locationdb subscriber - sqldb03.locationdb tables on both servers: branch (branchnumber primarykey) branchdetail (branchnumber foreignkey references previous table) select * sqldb02.locationdb.branch -- contains : 23456,'texas',... select * sqldb03.locationdb.branch -- contains : 23456,'null',... the problem - branchnumber in question '23456' exists in 4 tables (publisher..bran

c# - Binding RadioButton to Enum -

problem: binding property of type enum radiobuttons, using parameterized converter. no exception thrown, radiobutton might have validation problems (not sure). red box around radiobuttons shown when testing. info: trying use solution given in how bind radiobuttons enum? i've got enum this: namespace crmverwaltungstools.models { public enum crmsystemtype { training = 0, live = 1 } } booleantoenumconverter: public object convert(object value, type targettype, object parameter, system.globalization.cultureinfo culture) { return value.equals(parameter); } public object convertback(object value, type targettype, object parameter, system.globalization.cultureinfo culture) { return value.equals(true) ? (crmsystemtype)parameter : binding.donothing; } and inside window: xmlns:models="clr-namespace:crmverwaltungstool.models" <stackpanel grid.column="0" grid.columnspan="2" grid

c# - Invalid Path while processing Font with MGCB -

Image
i'm playing around monogame , can't add font. when adding font monogame pipeline tool can't build project anymore. visual studio stopps following error: der befehl ""c:\program files (x86)\msbuild\monogame\v3.0\tools\mgcb.exe" /@:"c:\dev\mini\mini\content\content.mgcb" /platform:windows /outputdir:"c:\dev\mini\mini\content\bin\windows" /intermediatedir:"c:\dev\mini\mini\content\obj\windows" /quiet" wurde mit dem code 1 beendet. 'fontdescriptionprocessor' had unexpected (sorry, german, think can understand problem ; ) ) when execute error throwing command more helping error: c:\dev\mini\mini\content>"c:\program files (x86)\msbuild\monogame\v3.0\tools\mgcb.exe" /@:"c:\dev\mini\mini\content\content.mgcb" /platform:windows /outputdir:"c:\dev\mini\mini\content\bin\windows" /intermediatedir:"c:\dev\mini\mini\content\obj\windows" build start

Database on a personal github page -

is possible have data stored somewhere on personal github page? for example button triggers counter. when click on button , counter increments 1. when other user visits page , clicks button , counter gets incremented 1 once again. so sum of click across visitors displayed on page. github pages allow static content, you'd have use firebase in order database.

javascript - AngularJS with ngMessages: skip pattern while length is invalid -

i have such part of form: <div ng-messages="submittedfrgpwd && forgotform.username.$error" multiple> <div ng-message="pattern">{{ 'invalid_email' | translate }}</div> <div ng-message="required">{{ 'empty_email' | translate }}</div> <div ng-message="minlength">{{ 'short_email' | translate }}</div> <div ng-message="maxlength">{{ 'long_email' | translate }}</div> </div> <input type="email" id="username-remember" name="username" ng-model="username" ng-minlength="8" ng-maxlength="200" required ng-pattern="email_regexp" ng-class="{ 'has-error': submittedfrgpwd && forgotform.username.$invalid || submittederror}"/> and example: when enter email of normal length, invalid pattern see only: {{ 'invalid_email' | translate

c# - add migration failed when DbContext in sperate project -

i have project different layers: web, services, model, data each 1 has different project in same solution. application, compiles , runs ok. when tried implement migration got following error dnx . ef migration add migrationfile system.invalidoperationexception: no dbcontext found. ensure you're using correct assembly , type neither abstract nor generic. @ microsoft.data.entity.commands.contexttool.selecttype(ienumerable`1 types, string name) @ microsoft.data.entity.commands.migrationtool.getcontexttype(string name) @ microsoft.data.entity.commands.migrationtool.addmigration(string migrationname, string contexttypename, string startupassemblyname, string rootnamespace,string projectdir) @ microsoft.data.entity.commands.program.<>c__displayclass12_0.<addmigration>b__0() @ microsoft.data.entity.commands.program.execute(string startupproject, func`1 invoke) @ microsoft.framework.runtime.common.commandline.commandlineapplication.execute(string[] arg

java - How to overlay a Jbutton over a JprogressBar -

Image
i'm working on swing gui, , i'd overlay button on progressbar. have wrote code update progress bar , button event, don't know how manage layout! currently panel code following: public static void main(string[] args) throws ioexception { jframe myframe = new jframe("myjftitle"); myframe.setlayout(new borderlayout()); jpanel mypanel = new jpanel(); jbutton mybutton = new jbutton("click me"); jprogressbar mybar = new jprogressbar(); mybar.setvalue(50); mypanel.add(mybutton); mypanel.add(mybar); myframe.add(mypanel,borderlayout.center); myframe.setvisible(true); } which gives following result: i'm trying unsuccesfully obtain this: can explain me kind of layout (or whatever) should use, or link me same reference can read how it?? update: by adding following code, managed overly 2 components, m still not able enlarge progress bar fit panel size: layoutm