Posts

Showing posts from February, 2010

c++ - Winsock invalid received byte number -

i'm facing winsock related problem when trying validate number of received bytes. in application i'm using non-blocking socket in order throw own timeout exception. here according code initialization of winsock : // initialize winsock wsadata winsockdata; word dllversion = makeword(2, 1); long iresult = wsastartup(dllversion, &winsockdata); if (iresult != no_error) return; addrinfo* serveraddress = nullptr; addrinfo* ptr = nullptr, hints; zeromemory(&hints, sizeof(hints)); hints.ai_family = af_inet; hints.ai_socktype = sock_stream; hints.ai_protocol = ipproto_tcp; iresult = getaddrinfo("127.0.0.1", "10011", &hints, &serveraddress); if (iresult != 0) return; // create communication socket socket connectsocket = socket(af_inet, sock_stream, /*ipproto_tcp*/0); if (connectsocket == invalid_socket) return; // establish connection server iresult = connect(connectsocket, serveraddress->ai_addr, (int)serveraddress->ai_

c# - DateTime with timezone in ASP MVC Web API + EF -

i using asp mvc web api + ef , clients getting datetime without information timezone. trying setup settings in webapiconfig without success: config.formatters.jsonformatter.serializersettings.datetimezonehandling = datetimezonehandling.local; the 1 way working me: create new instance of datetime datetimekind.local: public ienumerable<clientdto> execute() { var clients = this.dbcontext.clients.select( m => new clientdto { id = m.id, notificationsendingtime = m.notificationsendingtime, . . . }).tolist(); clients.foreach(m => m.notificationsendingtime = m.notificationsendingtime.hasvalue ? new datetime(m.notificationsendingtime.value.ticks, datetimekind.local) : m.notificationsendingtime); return clients; } but in case have use .tolist() , set each item new datetime timezone. how can setup webapi or ef add information timez

c++ - How to use GTK signals? -

i new gtk , i'm coming qt background. i'm trying figure out how signals work in gtk , i'm trying emit 1 doesn't work. found surprising couldn't find decent code example emits gtk signal works. code far(i'm using qt creator ): test_gtk.pro : #------------------------------------------------- # # project created qtcreator 2015-04-26t12:42:38 # #------------------------------------------------- qt += core gui greaterthan(qt_major_version, 4): qt += widgets target = test_gtk template = app sources += main.cpp \ myfirstobject.cpp \ mysecondobject.cpp headers += \ myfirstobject.h \ mysecondobject.h unix:!macx{ # make sure install libappindicator-dev includepath += /usr/include/glib-2.0 includepath += /usr/include/gtk-2.0 includepath += /usr/lib/x86_64-linux-gnu/glib-2.0/include includepath += /usr/lib/x86_64-linux-gnu/gtk-2.0/include includepath += /usr/include/cairo includepath += /usr/include/pango

php - Changing Yii folder locations -

using yii2 basic. trying tidy-up yii2 installation , wish place main working files , folders sub directory on co-hosted production server called, say, "yii2basic". need place files , folders web folder public_html on server. as far can ascertain, need change the following lines in index.php file so: require(__dir__ . '/../yii2basic/vendor/autoload.php'); require(__dir__ . '/../yii2basic/vendor/yiisoft/yii2/yii.php'); $config = require(__dir__ . '/../yii2basic/config/web.php'); is correct or have missed something? please note not have access httpd.conf file on co-hosted server cannot make changes it. i have searched answer on site , in manual cannot find one. it's possible question incorrectly phrased. if so, apologies. you need change number of files correct new url to start off need change following files index.php index-test.php yii.php //to able run yii on console/terminal requirements.php then

python - Exception while importing pymorphy2 -

i've installed pymorphy2 using pip: requirement satisfied (use --upgrade upgrade): pymorphy2 in /usr/local/lib/python2.7/site-packages requirement satisfied (use --upgrade upgrade): docopt>=0.6 in /usr/local/lib/python2.7/site-packages (from pymorphy2) requirement satisfied (use --upgrade upgrade): pymorphy2-dicts<3.0,>=2.4 in /usr/local/lib/python2.7/site-packages (from pymorphy2) but when i'm trying import library in python interactive shell this: >>> import pymorphy2 traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/local/lib/python2.7/site-packages/pymorphy2/__init__.py", line 3, in <module> .analyzer import morphanalyzer file "/usr/local/lib/python2.7/site-packages/pymorphy2/analyzer.py", line 10, in <module> pymorphy2 import opencorpora_dict file "/usr/local/lib/python2.7/site-packages/pymorphy2/opencorpora_dict/__init__.py", line 4,

PHP Illegal Offset Type when creating array -

i trying make fake data in form of array in php , keep getting illegal offset type error when running line, explain why? i looked reasons illegal offset errors , doesn't seem accessing data via offset, attempting create array, , no see spot using object association array. $fake_data = array( ["game_id"] => "1", ["turn_number"] => "1", ["host_user"] => array( ["units"] => array( array("row"=> "1", "col" => "1", "hp" => "100", "armor" => "100", "is_dead" => "0", "direction_facing" => "1", "name" => "assaultalpha"), arra

Cannot include Accelerate Header in iOS C++ code -

Image
i have code want call vdsp upon. c++ file, in xcode project. main project in objective c. whenever #include <accelerate/accelerate.h> it gives me lot of errors. #if defined(__cplusplus) #pragma once #include <accelerate/accelerate.h> // <-- error #include "oscillator.h" namespace synth { class cqblimitedoscillator : public coscillator { float douts[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; public: cqblimitedoscillator(void); ~cqblimitedoscillator(void); // --- init globals inline virtual void initglobalparameters(globaloscillatorparams* pglobaloscparams) { // --- call base class first store pointer coscillator::initglobalparameters(pglobaloscparams); // --- add qbl specifics here } // -- parallel proqcess 4 sawteeth inline void dosawteeth(float* doutsin, float dmodulo, float dinc) { float scalar2val = 2.0f; float scalar1val = -1.0f; // -- 2.0f*dvalue - 1.0f

Avoid merge commits in gerrit/git -

here scenario. developer pushes commit c1 gerrit based on commit c developer b pushes commit c2 gerrit based on commit c reviewer merges commits c1 , c2 in gerrit. when reviewer pulls repo (using git pull --rebase), he/she sees 3 commits. (last shown on top, shown in git log) merge "log_message_of_commit_c2" master (this not have change id) log_message_of_commit_c2 log_message_of_commit_c1 was merge commit created gerrit when c2 merged after c1? there way avoid this? (other developer b rebasing , resubmitting c2, involves synchronization between , b, not possible) thanks, sameer the merge-commit created gerrit. you can avoid merge commits using cherry-pick strategy in gerrit. see: https://gerrit-review.googlesource.com/documentation/project-configuration.html#submit_type

javascript - How do I get an instance of a controller that was created by AngularJS? -

i have app based on angular initialize this: myapp.init = (function () { 'use strict'; var angularapp = angular.module('myapp', []) .directive('homeiterationdirective', function () { return function (scope, element, attrs) { var istopcard = scope.$last ? true : false; cards.initsingleswipe(element.get(0), function (event) { // want call indexpagecontroller.onswiped(event) here! }, istopcard); }; }) .directive('homedirective', function () { return function (scope, element, attrs) { cards.initpanel(element, function (event) { // want call indexpagecontroller.onbuttonpressed(event) here! }); }; }); angularapp.factory('ajaxservice', myapp.services.ajaxservice); angularapp.controller('indexpagecontroller', ['$scope', '$http', '$sce', 'ajaxservice', myapp.pages.indexpagecontroller]); }()); my c

sql - The data types varchar and int are incompatible in the concat operator -

i've been stuck past 2 days execute give error: the data types varchar , int incompatible in concat operator here table: create table salestable ( id int identity(1,1) not null primary key, empid char(5), datesold date, monthonly varchar(50), amount money ) this code inserts dummy record dbo.salestable working in salestable, debug , step code give debug , understanding code declare @outercounter int = 1 declare @innercounter int = 1 while @outercounter <= (select count(name) namestable) begin while @innercounter <= datediff(day, getdate() -datepart(day, getdate()), {fn concat('12/31/',datepart(year,getdate()))}) begin insert salestable (empid, datesold, monthonly, amount) values (@outercounter, getdate() - datepart(day, getdate()) + @innercounter, datename(month, getdate() - datepart(day, getdate()) + @innercounter), rand() * 10000) set

php - SQL Variable Inserting INSIDE mysql_query -

i trying make price slider php , sql , have problem when have problem in code $query = mysql_query("select * price phone_price between" .$from. "and" .$to. ); while($row = mysql_fetch_array($query)){ print $row['phone_name']; print $row['phone_price']; print ''; } i want run sql query select * price phone_price between 300 , 500 i making beta version therefore accepting $from , $to values <input> , think making error in inserting variable in mysql_query . the error - warning: mysql_fetch_array() expects parameter 1 resource, boolean given in c:\xampp\htdocs\login\slide\slide.php on line 28 you have mistake in query. spaces needed after between , and. otherwise php reads query ...between123and1234... . , should better use quotes place vars: $query = mysql_query("select * `price` `phone_price` between '".$from."' , '".$to."'");

algorithm - Time Complexity of Dependent for loop -

string str = "abcdefghijklmnopqrstuvwxyz"; int sum = 0; for(int i=0; i<str.length; i++) { int val = str[i]; while(val > 0) { sum = val % 62; val = val / 62; } } i know parent loop executes n+1 time , child loop executes (val)^(1/62) times. parent loop time complexity o(n) don't find way calculate child loop. so, time complexity of above program ?. thanks in advance. let length of string written n. n = str.length(); now, outer for-loop iterates whole length of string,i.e., n times. hence,outer for-loop complexity o(n). talking child loop, inner while loop executes (val)^(1/62) times. so, can consider inner while-loop complexity o(log 62 val) . all other statements take constant time-complexity. therefore,net time complexity = o(n * log 62 val) . last step because of :- if f1(n) = o(g1(n)) , f2(n) = o(g2(n)),then f1(n) * f2(n) = o(g1(n) * g2(n)) as mentioned edward doolittle in comment, reduce o

java - Up to what extent can you prevent modifying existing code when using design patterns? -

i taking design patterns class in school, , have read through chapters of head first design patterns. i'd find out extent can design patterns prevent rewriting of existing code. let take duck classes , flybehavior classes example. have in public static void main(string[] args) following code: duck mallard = new mallardduck(new flywithwings()); am right in saying inevitable you'll have modify main() method when want add new strategy? in way, are modifying existing code, right? referring part concrete strategy class mentioned: new flywithwings(). if implemented factory method pattern in code, prevent having concrete class ( flywithwings ) being mentioned @ all: public flybehavior returnbehavior(flybehaviorfactory factory, string behaviortype) { return factory.getflybehavior(behaviortype); } and thus, have following line of code: duck mallard = new mallardduck(returnbehavior(flyfactory, "wings")); this way, portion of program not have know fl

erlang - Elixir File.read returns empty data when accessing /proc/cpuinfo -

when running thing file.read "/proc/cpuinfo" >> {:ok, ""} same equivalent erlang function. there reason pattern? like @josé mentioned proc fs special since file contents generated on fly. if @ file sizes in /proc you'll see have size 0 . i believe why read function fails return anything, file empty! the workaround force-read number of bytes anyway, in erlang can do: {ok, fd} = file:open("/proc/cpuinfo", [read]). file:read(fd, 1024). to read content keep reading fixed number of bytes until eof returned read .

SQL Query works in SQL Developer, but not on the Java side -

i'm trying figure without success. i'm trying find every row in specific table contains value. for example, let's consider employee table: | id | first_name | last_name | date_of_birth | car_number | |------------------|------------|------------|---------------|------------| | 10001 | john | washington | 28-aug-43 | 5 | | 10083 | arvid | sharma | 24-nov-54 | null | | 10034 | david | johnson | 12-may-76 | | i'm building query on java side (this print in log): select * employee id ? or first_name ? or last_name ? or date_of_birth ? or car_number ? then use prepared statement that, if search string 'oh' becomes: select * employee id '%oh%' or first_name '%oh%' or last_name '%oh%' or date_of_birth '%oh%' or car_number '%oh%' here's corresponding code: string wantedquery = "select * " +

html - Open SWF file within browser from a tag? -

i want able open .swf file within browser clicking link, eg: <a target="_blank" href="https://s3-ap-southeast-2.amazonaws.com/myswf.swf">link</a> but clicking link nothing. if right click , select 'open in new tab' .swf downloads. does know way can open new page/tab , play file within browser?

emulation - 6502 and little-endian conversion -

for fun i'm implementing nes emulator. i'm reading through documentation 6502 cpu , i'm little confused. i've seen documentation stating because 6502 little-endian when using absolute addressing mode need swap bytes. i'm writing on x86 machine little-endian, don't understand why couldn't cast uint16_t*, dereference that, , let compiler work out details. i've written simple tests in google test , seem agree me. // implementation of read16 #define read16(addr) (*(uint16_t*)addr) test(memmacro, read16) { uint8_t arr[] = {0xff,0xcc}; uint8_t *mem = (&arr[0]); expect_eq(0xccff, read16(mem)); } this passes, appears supposition correct, thought i'd ask more experience i. is correct pulling out operand in 6502 absolute addressing mode? possibly missing something? it work simple cases on little-endian systems, tying implementation feels unnecessary when corresponding portable implementation simple. sticking macro, instead

c++ - Would Rewriting It Using Regex Shorten/Beautify The Code? -

the problem little challenging because want code using std::regex believing easier read , faster write. but seems can code 1 way (shown below). somehow mind not see solution using std::regex . how code it? would using std::regex_search job? /* input: data coming in: /product/country/123456/city/7890/g.json input: url parameter format: /product/country/<id1:[0-9]+>/city/<id2:[0-9]+>/g.json output: std::vector<std::string> urlparams sample output: urlparams[0] = "123456" urlparams[1] = "7890" */ bool parseit(const char *path, const char* urlroute, std::vector<std::string> *urlparams) { const dword bufsz = 2000; char buf[bufsz]; dword dwsize = strlen(urlroute); urlparams.clear(); int j = 0; int = 0; bool = false; (i = 0; < dwsize; i++) { char c1 = path[j++]; char c2 = urlroute[i]; if (c2 == '<') { = true; while (c2 != '/')

service worker - navigator.serviceWorker is never ready -

i registered service worker successfully, code navigator.serviceworker.ready.then(function(serviceworkerregistration) { // have push message subscription? .... hangs -- function never called. why? the problem service-worker.js file stored in assets sub-directory. don't that: store service-worker.js in root of app (or higher). way app can access service-worker. see html5rocks article -- one subtlety register method location of service worker file. you'll notice in case service worker file @ root of domain. means service worker's scope entire origin. in other words, service worker receive fetch events on domain. if register service worker file @ /example/sw.js, service worker see fetch events pages url starts /example/ (i.e. /example/page1/, /example/page2/). added a new problem serviceworker never ready if page hard-reloaded. subsequent soft page reloads work fine. google's own sample code fails. see chrome bug report. the bug

html - Range input (slider) with markings for intermediate points -

Image
i want slider using html5 this: can display value. have tried below code: <input type=range min=0 max=100 value=50 step=1 list=tickmarks> <datalist id=tickmarks> <option value="0 20">0</option> <option>20</option> <option>40</option> <option>60</option> <option>80</option> <option>100</option> </datalist> but nothing seems work. idea? you can sort of achieve want using below code. doing here is: use linear-gradient (repeating) generate lines @ required intervals add text using pseudo-element , give required space in between them using word-spacing property. chrome (webkit browsers) container not required , commented code in sample alone enough firefox requires container. think behavior in ff correct 1 because input elements aren't expected support pseudo-elements , hence better retain container future-pro

ruby on rails - Messaging app using angularjs $watch and $interval -

i trying add messaging angular app has rails backend. make messaging feel 'real time' using $interval directive make calls server , conversation between 2 users every 5 seconds. using $watch @ messages , see if object has change , if has display new conversation. code: $scope.messages = messages.messages getnewmessage = -> conversation.getconverationbetweentwousers($stateparams.userid).then ((messages) -> $scope.messages = messages.messages ), (error) -> $state.reload() checkfornewmessages = -> $interval(getnewmessage, 5000) $scope.$watch('messages.messages', checkfornewmessages, true) can please explain me why need use websocket instead of approach? also, if doing bad idea can please explain why , better approach. please keep in mind have users conversations , solution accommodate existing conversations. websockets allows real time. don't have fetch data client side. websockets open connection between server , clien

YII2 add colspan in gridview header -

Image
how add colspan in header in gridview?? normally header looks this... <table class="table"> <thead> <tr> <th>header1</th> <th>header2</th> <th>header3</th> <th>header4</th> <th>headera1</th> <th>headera2</th> <th>headera3</th> <th>headerb1</th> <th>headerb2</th> <th>headerb3</th> </tr> </thead> <tbody> <tr> <td>body1</td> <td>body2</td> <td>body3</td> <td>body4</td> <td>body5</td> <td>body6</td> <td>body7</td>

.net - How to Add data to Dropdown in windows forms applications in C# -

i trying create windows form application. create .zip file password , sending .zip file clients email address in 1 email , email send password of .zip file client... i using dropdown box enter "to:" email address... , want user not write entire email address if used email id.. want whole email id display if entered starting part of it... (like intellisense) , if new 1 make new entry.. not sure how implement this.. looks dropdown not this.. any 1 please me or suggest how achieve functionality.. thanks in advance! you can tell use items in combobox sort of "suggestion" list user. it'll display nearest match type, think you're looking for. set these properties on combobox , either in code-behind or @ design time: combobox1.autocompletesource = autocompletesource.listitems; combobox1.autocompletemode = autocompletemode.suggestappend;

android - SupportMapFragment.getMap() on a null object reference -

after trying everything, cannot seem getmap without pulling null object reference. trying inflate google mapfragment fragment, each time keep getmap null object . here code i'm desperate @ point, i've tried everything. error java.lang.nullpointerexception: attempt invoke virtual method 'com.google.android.gms.maps.googlemap com.google.android.gms.maps.supportmapfragment.getmap()' on null object reference @ com.gnumbu.errolgreen.importedapplication.viewmapfragment.onviewcreated(viewmapfragment.java:122) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:971) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1136) @ android.support.v4.app.backstackrecord.run(backstackrecord.java:739) @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1499) @ android.support.v4.app.fragmentmanagerimpl.executependi

c++ - How to create a wrapper that would work for multiple languages at the same time? -

i have simple c api ( n simple functions). want wrap c#, java , python @ same time. how call swig create wrapper multiple languages @ same time? something this swig.exe -c++ -csharp -java -namespace bla outdir ./ -o ./blaapiwrapper.cxx blaapi.i results in swig application crush assertion failed: !this_, file modules/lang.cxx, line 332 application has requested runtime terminate in unusual way. please contact application's support team more information. works fine each language sepratly. just call multiple times different parameters, 1 java, 1 c# etc.. you need shell script automate that, once create script generates wrapper call script. that's easiest solution if swig don't allow multiple languages @ 1 go, or if feature present bugged (or if present undocumented , not able use because missing important information).

javascript - Refactoring animation code into a class, receiving error on accessing class variable -

a similar different issue recent post of mine - i'm experiencing error "cannot set property 'globalcompositeoperation' of undefined" when i'm trying access class variable inside prototype call. here code - var drawslinky = function() { this.c = document.getelementbyid("c"), this.w = c.width, this.h = c.height, this.ctx = c.getcontext('2d'), this.prob = .7, this.minsparks = 3, this.maxsparks = 10, this.minarea = 5, this.maxarea = 40, this.minvel = 10, this.maxvel = 50, this.particles = [], this.frame = 0; }; drawslinky.prototype.anim = function(){ this.c.requestanimationframe(this.anim); this.ctx.globalcompositeoperation = 'source-over'; this.ctx.fillstyle = 'rgba(0, 0, 0, .04)'; this.ctx.shadowblur = 0; this.ctx.fillrect(0, 0, w, h); this.ctx.globalcompositeoperation = 'lighter'; ++frame;

javascript - Get JSON Result from popup window. Angular.JS -

i've got pop-up window calls restful backend oauth authentication, when result returned, displays json in popup window rather closing popup window , storing json in model. how fix this? this.sociallogin = function(provider) { var url = urlbase + '/' + provider, width = 1000, height = 650, top = (window.outerheight - height) / 2, left = (window.outerwidth - width) / 2, socialpopup = null; $window.open(url, 'social login', 'width=' + width + ',height=' + height + ',scrollbars=0,top=' + top + ',left=' + left); }; the situation described not best way solve problem in angular. assuming written inside of controller. if so, making call backend service best done $http service. so, controller.js angular.module('example') .controller(['$scope', '$http', '$window', function($scope, $http, $window) { $scope.sociallogin = function(urlend) { $http.get(ur

java - Delete a node from a binary search tree -

i new binary search trees , deleting node giving me problems. tried draw out problem see doing wrong , still cannot seem see problem , not want copy code website. i understand how delete node 1 child or no children , think code correct methods. problem deleting node 2 children. cannot work properly. or advice appreciated. public void deletenode(int number) { if (root == null) { joptionpane.showmessagedialog(null," tree empty, can not delete ", joptionpane.warning_message); return; } node child = root; node parent = root; while (number != child.data) { if (number < child.data) { parent = child; child = child.left; } else if (number > child.data) { parent = child; child = child.right; } if(child == null){ joptionpane

Would this be the correct syntax for Swift 1.2? -

i have seen method: func sum(x:int, y: int) -> int { return x+y } would need call via: let x1 = sum(4, y:11) because doesn't seem work: let x1 = sum(4, 11) in method, y labelled y both internally , externally. therefore, call method, must name parameter. if want call sum method way you're describing, add underscore before y so: func sum(x:int, _ y: int) -> int { var j = x*y return j }

matlab - Find a regional maximum with imregionalmax -

i'm trying find regional maximum within data. started function imregionalmax can't results want. i'm getting data csv file , column have 5.2 ,5.6 , 5.3 surrounded low values compared these, imregionalmax labels 3 of these values 1 (since output binary), want select 5.6. is there way scan whole grid check neighbouring cells each cell , compare them if bigger surroundings?

php - Accessing an Amazon RDS MySQL database from CodeIgniter leads a blank display -

this related this previous question . i'm making new question because @ point believe it's database access issue. essentially, i've switched database mysql sever amazon rds mysql server, due server migration. summarize, i'm attempting migrate php site based on codeigniter (version 1.7.2) new server has amazonlinux os. previous server ubuntu, running php 5.3.3-1ubuntu9.5 on apache2. php version on new amazonlinux server 5.3.29, running on httpd. the problem is, when try access url in new server, blank display. code stopping in system/core/codeigniter.php @ line: $ci = new $class(); the last line of application log this: debug - 2015-04-25 17:17:58 --> database driver class initialized so, it's happening around database. i've read blank display if it's database issue due "@" being used database-related messages. these settings in database.php: $active_group = "default"; $active_record = true; $db['default'][&

php - Wordpress: checkboxes in plugin -

i have code... $wpdb->update( $table_name_employee, array( 'id' => $_post["user"], 'role' => $_post["role"], 'seniority' => $_post["seniority"], 'payroll' => $_post["payroll"], 'reportto' => $_post["reportto"], 'tasks' => $_post["tasks"], ), array( 'id' => $_post["user"], ) ); the value of $_post["tasks"] array , not string. derived checkbox code... ... <input type=checkbox name="tasks[]" value="38"> task 38 <input type=checkbox name="tasks[]" value="39"> task 39 <input type=checkbox name="tasks[]" value="40"> task 40 ... many more if change tasks[] task check value of 1 checkbox. if leave tasks

scala - Play Framework how to sort collection in repeat() form helper? -

based on the play (java) documentation , let's have following example: public class userform { public string name; public list<myclass> itmes; } and @helper.inputtext(userform("name")) @helper.repeat(userform("items"), min = 1) { itemfield => @helper.inputtext(itemfield) } however, in myclass have overridden implementation of compareto() . have getter getsorteditems() return list in proper sorted order. currently, using repeat() helper does not list of items in ordering want. is there way specify ordering repeat() helper? or can give list parameter? seems possible in scala. any appreciated, thanks! you replace list<myclass> sorted set: case class myclass(id: int, name: string) val sorted = new mutable.treeset[myclass]()(new ordering[myclass] { def compare(a: myclass, b: myclass): int = { ordering.int.compare(a.id,b.id) } }) sorted.add(myclass(2,"bob")) sorted.add(myclass(1,"b

bash - How do you source a shell script with dart.io in the current process? -

process.run (and variants) complain using '.' , 'source' commands. there built-in way run methods or there particular executable can try calling mimic bash's source command? all these commands have runinshell argument. if doesn't fix use shell -c ". xxx" if process.run('. somescript.sh, runinshell: true); , process.run('someexecutable'); gained nothing because when first call ends created environment dies it. assume want process.run('. somescript.sh && someexecutable', runinshell: true);

java - Searching a MySQL database for values within radius (lat/long) -

this question has answer here: mysql great circle distance (haversine formula) 8 answers i don't have sql experience , don't have clue go here, people ask question using ms server or something, , can use bunch of parameters/values can't. i'm using mysql. here's code in java use create random location within x miles. public static geoposition randomlocation(geoposition location, double radius) { random random = new random(); // convert radius miles meters double meters = radius * 1609.34; // convert radius meters degrees double radiusindegrees = meters / 111300f; double u = random.nextdouble(); double v = random.nextdouble(); double w = radiusindegrees * math.sqrt(u); double t = 2 * math.pi * v; double x = w * math.cos(t); double y = w * math.sin(t);

ios - how to save dictionary to cloudkit -

i'm trying create database sports games , instance, in soccer games save not how many goals scored, time's in scored. easiest way of course use key value pairs i'm using cloudkit , don't see way save dictionary. possible this? i think solution give flexability in app create other recordtype. besides recordtype 'games' have recordtype 'goals'. in 'goals' recordtype create ckreference field points 'games' belongs to. able create query 'goals' recordtype reference points specific game. calculate score based on results of query. one other solution easier maintain convert dictionary string , put entire dictionary in 1 text field. instance convert json string nsjsonserialization.

Android listview background -

Image
i implementing list view android. without worrying selectors , thin strip on left of each item, background layout drawable list items be: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="1dp" android:color="#000000" /> <corners android:bottomrightradius="27dp" android:toprightradius="27dp" /> </shape> and i'm calling list_border.xml , resides in drawable folder. i have tried set background listview <?xml version="1.0" encoding="utf-8"?> <listview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/list_pad

fortran - Do sum with alternating sign in argument -

i'm doing numerical exercises in fortran 90. when trying sum alternating sign in argument noticed (in manner did it) fortran don't know how that. for example want sum on k 1 10 of ((-1)^k)/2k did was sumk = 0 k = 1,10 sumk = ((-1)**k)/(2*k) + sumk end but output sumk = 1. did wrong? if k integer, performing integer operations. these might not expect, e.g. 1/2 = 0 . using floats result in 0.5 , of course, conversion integers result in 0 . so, basically, part add sumk 0 in case, leading sumk=0 in end. prevent this, need take quotient floats: sumk = real(((-1)**k))/real(2*k) + sumk then, result -0.322817445 (which verified using wolfram alpha). of course, there several ways improve this, such computing (-1)**k iteratively, or replacing modulo operation.