Posts

Showing posts from July, 2014

c# - Set Properties Dynamically WPF Application -

i have property as: button1 system.windows.thickness 10,10,10,10 , button name button1 . i'm able set same as propertis.setting.default.button1 = _margin; i have many buttons similar xaml name n property name same, want set margin dynamically button option = sender button; properties.settings.default.option = _margin; is achievable? if how? as values stored in settings key value pairs, can set property has same name of button control as button option = sender button; properties.settings.default[option.name] = _margin;

unity3d - Unity: How to make multiple agents circle the building when I click to atk it in my rts game -

i have tried initiate several point arround building attack. way not flexible enough, agents may have different radius, therefore attack point shouldn't even. have ideas? they should flock/swarm. basically: agents should go nearest attack position while keeping distance form friendly agent.

resize - Android change size buttons programatically generic -

i have next problem, need resize buttons in layout depending on screen size. know how write code each button , problem have 50 buttons. there way change size of buttons using something, , not write 100 line codes? here example of button: <button android:id.... android:layout_width="wrap content" android:layout_height="wrap_content" android:layout_marginbottom="4dp" android:layout_marginright="30dp" android:layout_margintop="4dp" android:background="@drawable/..." android:minheight="0dp" android:minwidth="0dp" android:onclick= ... /> thanks

c# - Use Regex to remove outer parentheses from nested expression, but leave inner parentheses? -

i'm working on figuring out regular expression take value such as: transformer winding connections (wye (star) or delta) and match: wye (star) or delta what have far is: string longname = "transformer winding connections (wye (star) or delta)"; // match until first parentheses regex nameregex = new regex(@"([^(]*)"); match namematch = nameregex.match(longname); // match first parentheses on regex valueregex = new regex(@"\(.+\)"); match valuematch = valueregex.match(longname); valuematch returning: (wye (star) or delta) is there clever way remove first set of parentheses in c#? if want deal 1 level fine. @"\((?:\([^()]*\)|[^()])*\)" or if don't want match outer paranthesis. @"(?<=\()(?:\([^()]*\)|[^()])*(?=\))" demo

javascript - Angular - How to work with HTTPS using $http -

Image
just wanted ask on how deal https + cross-domain url using $http ? i've used $.ajax solve problem, reason why wanted use $http more because have $http interceptor since using $.ajax takes lot more line of codes rather having interceptor automate process. i've read similar posts [ link1 , link2 , link3 ] neither of them have solved problem. i have attached screenshot of console, hope makes sense: . the weird thing option method being used $http have set post here's code snapshot: $http({ method: 'post', url: '/hearingcentre', data: { type: ['p', 'v'] }, success: function (res) { console.log(res); d.resolve(res); }, error: function (res) { console.log(res); d.reject(res); } }); note: i'm using $http interceptor here url appended base api url $.ajax version $.ajax({ method: 'post', crossdomain: true, url: 'https://ahts...

c - Socket programming port number -

there tutorial not understand. hope can explain me. http://www.tidytutorials.com/2009/12/c-winsock-example-using-client-server.html in server program, it's port initialised 1101 (line 14) 13. //the port want server listen on 14. int host_port= 1101; and in client program it's port 1101 12. //the port , address want connect 13. int host_port= 1101; 14. char* host_name="127.0.0.1"; now here's question. is int host_port in client program same int host_port inside server program? why port number 1101? (i error 111 when change port number 80 or other number 1234) isnt char* host_name="127.0.0.1"; supposed refer client ip address? why must use loopback address , not 192.x.x.x. thank you i realise mistake, run client before server program......... , in client program did not put serv_addr.sin_addr.s_addr = inaddr_any; <<<<<< the server , client port numbers must match. port number part of...

php - How to Create Color Status When Pending/Approval/Disapprove -

i'm planning create status notification. example, whenever information "pending", turns color orange. when "approved" turns color green , when "disapproved", turns color red i've created "status" column in every data submitted. so, when call value. here's code while($objstat = $query->fetch_object()){ echo "status: ".$objstat->status; } i want put bootstrap danger,success,info etc color of status. please there. :) you need add if/else condition it. btw returning in $objstat->status ? try sample below <?php while($objstat = $query->fetch_object()) { //echo "status: ".$objstat->status; if($objstat->status == "approved") { echo '<div class="alert alert-success" role="alert"> done! pending message. </div>'; } else if($objstat->status == "pending") {...

limits - Mysql start dropping connection when peak hours -

our database start dropping connection during peak hours. there 3% connection dropped , mysql return message "mysqli::mysqli(): (hy000/2003): can't connect mysql server on '10.88.***' (99)" . have tuned several mysql , kernel parameters, not help: -/etc/sysctl.conf: net.ipv4.tcp_max_tw_buckets = 524288 net.core.somaxconn = 2048 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_backlog=30000 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_synack_retries = 2 -/etc/my.cnf: open_files_limit = 65536 max_connections=3600 connect_timeout=60 wait_timeout=2400 back_log=4096 -/etc/security/limits.conf mysql soft nofile 65536 mysql hard nofile 65536 mysql soft nproc 65536 mysql hard nproc 65536 our database handle >40000 query , > 8000 connection per second 1 database machine, no sharding , connection pool. missing? 1 know may cause bottleneck? thanks. here content in my.cnf: [mysqld] datadir=/var/lib/m...

java - OSGI and different mail.jar send plain text attachement, throw exception: "text/plain" DataContentHandler requires String object, -

Image
in env, 2 different mail jars exist in 2 different classloaders, since our requirement keep 2 version of mail jar work together. but when sending plain-text attachment, throws exception: caused by: java.io.ioexception: "text/plain" datacontenthandler requires string object, given object of type class [b @ com.sun.mail.handlers.text_plain.writeto(text_plain.java:152) @ javax.activation.objectdatacontenthandler.writeto(unknown source) @ javax.activation.datahandler.writeto(unknown source) @ javax.mail.internet.mimebodypart.writeto(mimebodypart.java:1476) @ javax.mail.internet.mimebodypart.writeto(mimebodypart.java:865) @ iaik.smime.smimebodypart.writeto(unknown source) @ javax.mail.internet.mimemultipart.writeto(mimemultipart.java:462) @ com.tibco.ax.fw.mime.bcmimemultipart.writeto(bcmimemultipart.java:186) @ com.tibco.ax.fw.mime.bcmultipartmixed.writeto(bcmultipartmixed.java:77) @ javax.activation.objectdatacontenthandler.writeto...

text mining - R-Project no applicable method for 'meta' applied to an object of class "character" -

i trying run code (ubuntu 12.04, r 3.1.1) # load requisite packages library(tm) library(ggplot2) library(lsa) # place enron email snippets single vector. text <- c( "to mr. ken lay, i’m writing urge donate millions of dollars made selling enron stock before company declared bankruptcy.", "while netted on $100 million, many of enron's employees financially devastated when company declared bankruptcy , retirement plans wiped out", "you sold $101 million worth of enron stock while aggressively urging company’s employees keep buying it", "this reminder of enron’s email retention policy. email retention policy provides follows . . .", "furthermore, against policy store email outside of outlook mailbox and/or public folders. please not copy email onto floppy disks, zip disks, cds or network.", "based on our receipt of various subpoenas, preserving past , future email. please prudent in circulation of email relat...

java - Re-using top level models with gson -

i using gson parse json response. if have json structure looks this: "x" : { "y" : [ { "a" : "x", "b" : "y" }, .... ] }, "a" : { "y" : [ { "c" : "1", "d" : "2" }, .... ] } i want able re-use "y" , have contents of y parsed different models @ runtime. if define top level model topjson.java , define fields as private modelx x; private modela a; and define modelx.java as: private modely y; and modela.java : private modely y; and modely.java : private list<something> results; how can use generics ensure modely can contain different types of models? how can handle case when don't know structure of json looks like?

c# - Should all controls in a complex software inherit from a self written interface -

is idea, create interface controls should used in complex software (wirtten c#/wpf)? have problem, use controls microsoft , third party companies. our problem is, if want change third party components, don't want change howle software, because lot of customizing our customer. so idea, create abstract class every control use, , use member abstract class/interface provides? maybe bad solution reasons, , don't it. thank you! this deep question try give response. i start saying separate presentation logic ui controls. generally, should peek design pattern derived mvp or use current trend pattern, called "presentation model" invented martin fowler. i highly recommend read every information software design , best practices. start read here: http://martinfowler.com/eaadev/organizingpresentations.html from experience, best gain of doing separation between ui , presentation logic not changing ui technology rather gives freedom test easy presentation lo...

linux - opencv installation is not creating jar file in java -

while installing opencv3.0 not creating jar file .when iam running opencv.sh saying in console ant: /usr/bin/ant jni: no java wrappers: no -- java tests: no iam thinking because of not creating jar file .please tell me how provide path above statements answer question. thing did in bashrc file have added java path.thats .it creating jar file .

c++ - Recursive Func call in Halide -

i'm using halide , trying calculate size of maximum connected cells given 2-dimensional input. idea use recursive function don't know how write in halide language. refernece python script , expected results follows. import random n = 4 data = [[0 in range(n)] j in range(n)] index in range(n*n): data[index/n][index%n] = (random.randint(0,100) & 1) print "input" d in data: print d def ret(x, y): if x < 0 or y < 0 or x >= n or y >= n: return 0 if data[y][x] == 0: return 0 data[y][x] = 0 return ret(x, y-1) + ret(x, y+1) + ret(x-1, y) + ret(x+1, y) + 1 result = [[0 in range(n)] j in range(n)] y in range(4): x in range(4): result[y][x] = ret(x, y) print "output" r in result: print r """ input [1, 0, 1, 0] [0, 0, 1, 1] [0, 0, 1, 1] [1, 1, 0, 1] output [1, 0, 6, 0] [0, 0, 0, 0] [0, 0, 0, 0] [2, 0, 0, 0] """ halide implementation here, i'...

Getting SQL server exception when executing connection java file through ant build.xml file -

i have java file connect sql server database , retrieve data it. when execute java file eclipse connects database , retrieve data db. but when call same java file ant build.xml file, throwing sql server exception while creating connection object. not able may issue. please help!! sql exception thrown: - com.microsoft.sqlserver.jdbc.sqlserverexception: tcp/ip connection host 10.6.1.67, port 1433 has failed. error: "null. verify connection properties, check instance of sql server running on host , accepting tcp/ip connections @ port, , no firewall blocking tcp connections port.". [java] @ org.apache.tools.ant.taskdefs.executejava.execute(executejava.java:194) [java] @ org.apache.tools.ant.taskdefs.java.run(java.java:771) [java] @ org.apache.tools.ant.taskdefs.java.executejava(java.java:221) [java] @ org.apache.tools.ant.taskdefs.java.executejava(java.java:135) [java] @ org.apache.tools.ant.taskdefs.java.execute(java.jav...

c++ - Data type to store more than 20 digits of value -

‪#‎include‬ <iostream> #include <conio.h> using namespace std; int main() { double n,m,a, count=0; cin>>n>>m>>a; double length=n; while(m>0) { while(n>0) { count=count+1; n=n-a; } m=m-a; n=length; } cout<<count; getch(); return 0; } sample input 6 6 4 output 4 (working fine) sample input 1000000000 1000000000 13 output ___ no output means working fine small range of "count" value. if value exceeds limit not printing anything. have tried range of values. please me the reason getting no output sample input of 1000000000 1000000000 13 because takes far long. the inner loop runs 76923077 times, , outer loop runs 76923077 times. means inner code count=count+1 running 5.91 x 10^15 times. if inner code run in picosecond (it can't), take more 98 hours complete.

R optional subset in function -

i have dataframe follows individual species pdays ... gdays 1 alpha opuntia 4 9 2 alpha physalis 4 10 3 beta opuntia 3 9 4 beta physalis 5 8 where individual , species categorical factors. attempting write function can @ effects of species, , optionally individual. cannot figure out how optionally subset individual. far have: seed_germination <- function (dataframe, species, individual) { mydata <- read.table(dataframe, header = true, sep = ",") attach(mydata) subset_mydata <- mydata[mydata$species == species, ] subset_ind <- subset_mydata[subset_mydata$individual == individual, ] #ignored if individual not specified } test <- seed_germination(dataframe = 'test.csv', species = 'opuntia', individual = 'alpha') i have played around with if(missing(individual)) return() ...

sql server - SSRS 2005 to 2012 migration - microcharts -

we have reports created in ssrs 2005, uses bonavista microcharts plugin show microcharts. we upgrade reports ssrs 2012 now, couldnot add xlcubed dll ssrs report toolbox(which worked perfect in ssrs 2008). throwing error saying "there no components in dll can placed on toolbox". i can't go sparkline in ssrs 2012, because require complete restructure of dataset. dataset designed bonavista plugin, microchart data combined pipe (eg, 500|200|300 etc). any change in ds means have make changes in around 300 reports, have 3rd party microchart tool available ssrs 2012, similar xlcubed microcharts/bonavista microcharts? you should take at: nevron chart ssrs full disclosure: i'm in no way affiliated nevron

javascript - Download text/csv content as files from server in Angular not working in Mozilla FireFox -

download text/csv content files server in angular answered - https://stackoverflow.com/users/2064206/dcodesmith $http({method: 'get', url: '/someurl'}). success(function(data, status, headers, config) { var anchor = angular.element('<a/>'); anchor.attr({ href: 'data:attachment/csv;charset=utf-8,' + encodeuri(data), target: '_blank', download: 'filename.csv' })[0].click(); }). error(function(data, status, headers, config) { // if there's error should see here }); i implemented solution downloading files server client using angular. working fine in google chrome . solution not working in mozilla firefox . thanks you have attach anchor created document first. add followings: var anchor = angular.element('<a/>'); anchor.css({display: 'none'}); // make sure it's not visible angular.element(document.body).append(anchor); // attach d...

c# - Linq to Excel - Object must implement IConvertible error -

the following code showing error object must implement iconvertible when adding clause in linq expression compare datetime field. i tried use convert.todatetime(c.etc) >= startday still same error. var excel = new excelqueryfactory(excelfilename); excel.addmapping<bulkmovementitem>(x => x.etc, "etc"); var newrailtruckmovements = (from c in excel.worksheet<bulkmovementitem>(sheetname) c.etc > new datetime(2015, 7, 1) select c); definition of bulkmovementitem : public class bulkmovementitem { public string schedulename { get; set; } public string dealheadername { get; set; } public string dealdetailname { get; set; } public string etc { get; set; } public string railcarname { get; set; } public string location { get; set; } public string originlocation { get; set; } public string functiontype { get; set; } public string productname { get; set; } public str...

sql - How to change number of digits after decimal point? -

i have line in query: case when count(n.counter) <> 0 (cast(count(n.counter) float)/count(t.counter)) * 100 else 0 end percent i'm getting results 79.565974946. want result 80% (with no digits after decimal point , '%' sign). how can that? you need round , then, because you're trying formatting, convert string before adding % : convert(varchar(20), round( case when count(n.counter) <> 0 (cast(count(n.counter) float)/count(t.counter)) * 100 else 0 end ,0)) + '%' percent also, there may typo here - looks you're trying avoid divide 0 error, you're testing wrong operand ( n.counter rather t.counter ) may still division 0 code.

C# Dllimport - pointer to a pointer receiving array -

i trying dllimport function simxgetobjects remoteapi.dll of v-rep software. here link function description: http://www.coppeliarobotics.com/helpfiles/en/remoteapifunctions.htm#simxgetobjects and here brief description function above link: description: retrieves object handles of given type, or of types (i.e. object handles) c synopsis: simxint simxgetobjects(simxint clientid,simxint objecttype,simxint* objectcount,simxint** objecthandles,simxint operationmode) c parameters: clientid: client id. refer simxstart. objecttype: object type (sim_object_shape_type, sim_object_joint_type, etc., or sim_handle_all type of object objectcount: pointer value receive number of retrieved handles objecthandles: pointer pointer receive object handle array. array remains valid until next remote api function called. operationmode: remote api function operation mode. recommended operation mode function simx_opmode_oneshot_wait here way importing ( simxgetobjects function): ...

objective c - Why does replaceObjectAtIndex depend on whether or not I use a new definition in the loop? -

i have 2 codes. not working following: nsmutablearray *tmparray = [[nsmutablearray alloc] init]; (int i=0; i<[datasetarray count]; i++) { tmparray = (nsmutablearray *) [datasetarray objectatindex:i]; // or use: tmparray = datasetarray[i] ... doing stuff [tmparray replaceobjectatindex:0 withobject:tmpstr]; } while works: for (int i=0; i<[datasetarray count]; i++) { nsmutablearray *tmparray = [[nsmutablearray alloc] initwitharray:[datasetarray objectatindex:i]]; ... doing stuff [tmparray replaceobjectatindex:0 withobject:tmpstr]; } two questions: the first code doesn't yield nsmutablearray . why? declare above. is there better way obtain same result. dislike defining variables in loop. makes code unreadable. --- edit: here full code: datatypes are: datasetarray: nsmutablearray. however, contents (i.e. datasetarray[i]) nsarrays (i read them program excel file). nsstring *tmpstr = [[nsstring alloc] init]; (i...

mysql - My OOP PHP method not execute -

i have file 'class_reg.php' contains class 'reg', , methon 'registration' in it, recive input value , insert database via pdo. , have 'dbconfig.php' file, connect database, include 'class_reg.php' file , create object '$user'. , have 'registration.php' file include 'dbconfig.php' file , try run method 'registration' not work. here files: class_reg.php <?php class reg{ public $db; function __construct($con){ $this->db = $con; //$con содержит подключение к базе данных } public function registration($username, $pass){ try{ $sql = $this->db->prepare("insert websiteusers ( username, pass, fullname, email ) values ( :username, :pass )"); $sql->bindparam(":username", $username); $sql->bindparam(":pass", $pass); $sql->execute()...

fileapi - Copying a file using Cordova -

i've been trying copy file named versions.txt applicationdirectory externalapplicationstoragedirectory using cordova code fails. here code var path = cordova.file.applicationdirectory + "www/data/versions.txt"; window.resolvelocalfilesystemurl(path, function gotfile(fileentry) { window.requestfilesystem(localfilesystem.persistent, 0, function onsuccess(filesystem) { var directory = new directoryentry("versions.txt", path); fileentry.copyto(directory, 'versions.txt', function() { alert('copying successful') }, function() { alert('unsuccessful copying') }); }, null); },null); any help? n...

Can I Download & Use Microsoft Edge in Windows 8.1? -

how can download , use microsoft edge in windows 8.1 ? no. can't. microsoft edge not standalone browser (as of now). i've tried many times alternative no.. i've tried finding setup file of browser windows 10 installed os couldn't. ps. in future might available. for more info, can join this conversation on quora

javascript - How do I re-initialize datatables AFTER data has loaded via AJAX in AngularJS? -

i using angularjs , datatables server-side script obtain data via ajax. my controller looks like: var currentjobid = $stateparams.jobid; var selectedjobid = $rootscope.currentjob; if (currentjobid !== selectedjobid) { $rootscope.currentjob=$stateparams.jobid; var data = { id: $stateparams.jobid } $http.post('http://localhost/angular/scripts/getjob.php', data).success(function (thedata) { $scope.job = thedata.information; $scope.jobnotes = thedata.notes; $scope.jobmaterialusage = thedata.materialusage; $scope.jobitems = thedata.jobitems; $scope.jobsubcontractorcosts = thedata.subcontractorcosts; $scope.jobbondmisccosts = thedata.bondmisccosts; $scope.jobemployeetime = thedata.employeetime; }); } an example table looks like: <table class="table table-striped table-hover row-links" id="employeetimetable" ui-jq="datatable" ui-options="tableoptions...

html - Replace img to background-image div with php -

is there way replace img tag div tag below? original html: <div class="article"> <img src="/images/img-1.jpg" alt="alt image"> </div> replaced html: <div class="article"> <div style="background: transparent url(/images/img-1.jpg) no-repeat; background-position: center center; background-size: cover; width: 566px; height: 576px;">alt image</div> </div> (optional) possible use width , height parent div i.e. article class in example instead of defining fixed width: 566px; height: 576px; ? if it's possible, want use str_replace function. str_replace('?????', '?????', $article); edit: there may multiple elements class article , there may other elements inside article class div , need change img div. edit2: i meaning if may have content inside article div , want replace img div. i may have: <div class="article"> <h1>head...

math - Probability and Frequency -

i in process of creating program , have run issue involves probability. question involves trying predict number using probability , frequency. have done plenty of research on matter not find example suits personal question. question: frequency affect probability? let's example, going flip coin 5 times. goal heads every single time. if heads first time, lower probability heads second time? or, if heads 4 times in row; lower probability heads fifth time? safer have higher chance of getting tails fifth time after getting 4 heads in row? no, each flip independent of subsequent flips. can x heads in row , probability of fair coin coming heads next time still 0.50. you might want read this: https://stats.stackexchange.com/questions/21825/probability-over-multiple-blocks-of-events