Posts

Showing posts from April, 2012

elapsed + aggregate passing custom fields in Logstash -

i using elapsed plugin calculate time , aggregate plugin display it. added custom fields elapsed filter can see below: add_field => { "status" => "status" "user" => "%{byuser}" } one static other 1 dynamic coming event. on output of logstash display static values not dynamic one.. it displays %{byuser} dynamic one. task id , status fields works fine , got right values. any idea why? little bit more code elapsed { unique_id_field => "assetid" start_tag => "tag1:tag2" end_tag => "tag3:tag4" add_field => { "wasinstatus" => "tag3" "user" => "%{byuser}" } add_tag => ["customtag"] } grok input: grok { match => [ "message", "%{timestamp_iso8601:timestamp} %{number:assetid} %{word:event}:%{word:event1} user:%{username:byuser}&q

java - Valid values for setFields in Google Drive API -

i've taken following code google documentation . public static void detectdrivechanges() throws ioexception { startpagetoken response = drive.changes() .getstartpagetoken().execute(); string savedstartpagetoken = response.getstartpagetoken(); system.out.println("start token: " + savedstartpagetoken); // begin our last saved start token user or // current token getstartpagetoken() string pagetoken = savedstartpagetoken; while (pagetoken != null) { changelist changes = drive.changes().list(pagetoken) .setfields("*") .execute(); (change change : changes.getchanges()) { // process change system.out.println("change found file: " + change.getfileid()); } if (changes.getnewstartpagetoken() != null) { // last page, save token next polling interval savedstartpagetoken = changes.getnewstartpagetoken();

html - Scrapping using codeigniter and i need title and custom link -

<div id="archive_content_block"> <div class="row"> <div class="col-md-6 col-sm-6"> <div class="archive_cat_caption"> <h4>অর্থনীতি</h4> </div> <ul> <li><i class="fa fa-square-o"></i>&nbsp; <a href="http://67.227.189.112/~rtvnews24/economy/2126/বাধ্যতামূলক-করারোপের-প্রস্তাব-অর্থমন্ত্রীর"> <font style="color:rgb(33, 33, 33)">বাধ্যতামূলক করারোপের প্রস্তাব অর্থমন্ত্রীর</font> </a> </li> </ul> </div> <div class="col-md-6 col-sm-6"> <div class="archive_cat_caption"> <h4>খেলাধুলা</h4> </div> <ul> <li><i class="fa fa-square-o"></i>&nbsp;<a href="http://67.227.189.112/~rtvnews24/sports/2096/অস্

batch file - Visual Studio Hangs After Adding Post-Build-Event -

i following this tutorial explains how attached post-build events project. this .bat file (tried , without d: rem d out): cmd echo parameter=%1 cd %1 rem d: copy wpffiledeleter.exe temp.exe "..\..\ilmerge.exe" /out:"wpffiledeleter.exe" "temp.exe" "microsoft.windowsapicodepack.dll" "microsoft.windowsapicodepack.extendedlinguisticservices.dll" "microsoft.windowsapicodepack.sensors.dll" "microsoft.windowsapicodepack.shell.dll" "microsoft.windowsapicodepack.shellextensions.dll" del temp.exe and added ilmerge.exe.config per tutorial (i getting unresolved assembly reference not allowed error): <configuration> <startup uselegacyv2runtimeactivationpolicy="true"> <requiredruntime safemode="true" imageversion="v4.0.30319" version="v4.0.30319"/> </startup> </configuration> but when build project in vs hangs messag

php - remove unnecessary words from string -

i want remove words string make image alt tag more relevant. the problem is, if have phase this: barack obama @ restaurant in venice i want exit be: barack obama restaurant venice but had is: barack obamaa restaurantvenice code:- $a = array( ' @ ', ' in ', ' arriving ', ' ', ' leaving ', ' walks ', ' walking ', ' ' ); $str = 'barack obama @ restaurant in venice'; echo str_replace($a,"",$str); if use words without space in array result horrible: brck obm resturnt venice any ideas? you have add 1 space inside "" like below:- echo str_replace($a," ",$str); check here:- <?php $a = array( ' @ ', ' in ', ' arriving ', ' ', ' leaving ', ' walks ', ' walking ', ' ' ); $str = 'barack obama @ restaurant in venice'; echo str_replace($a," ",$str); output:- https://eval.i

javascript - jQuery conflict causing woocommerce product images not to load -

i have script hide navigation @ point on homepage: jquery(document).ready(function() { jquery("#dot-nav").show(); //show div var topofothdiv = jquery("#hidedn").offset().top; jquery(window).scroll(function() { if(jquery(window).scrolltop() > topofothdiv) { //scrolled past other div? jquery("#dot-nav").hide(100); //reached desired point -- hide div } if(jquery(window).scrolltop() < topofothdiv) { //hide div jquery("#dot-nav").show(100); } }); }); however it's causing woocommerce product images not load. don't need script on woocommerce pages before attempt mess functions.php enqueue on homepage know how can solve this? i'm little more jquery novice apologise if need more context etc! the error raised, because cannot offset of hidden element, or element not exist. jquery not support getting offset coordinates of hidden elements or accou

javascript - How to increase a variable"s value by 1 eveytime I fire a function -

this question has answer here: count functions calls javascript 4 answers how do have pos=0 , each time fire function pos+=10 , how store how many times fire in var you can following: var count = pos/10 thanks

java - Do files compiled for armeabi have some problems with armeabi-v7a -

i using library in project play videos. library comes demo project . demo project working fine. the library has few .jar files, library classes, , lot of .so files. demo project put jar files in lib folder , .so files in armeabi , x86 folder. i did same, start giving me following error message. unsatisfiedlinkerror (can't find dependent libraries) then put these .so files in armeabi-v7a folder, , error gone. but still not working fine. its not giving me error message, still not initializing class available in decompiled.class file. same class initializing in demo project. found out problem after debugging both projects. i have checked each , everything, difference can see in demo , project armeabi-v7a , armeabi . so files compiled armeabi have problems armeabi-v7a, or can other problem. arm-eabi vs armeabi-v7a should not problem. @ low level, armeabi-v7a compatible armeabi, but not vice versa . can add more debug , give more info?

asp.net - Usermanager.DbContext already disposed in Middleware -

i have below middleware in asp.net core application require usermanager injected in it. when try query user findbyidasync , following exception: objectdisposedexception: cannot access disposed object. common cause of error disposing context resolved dependency injection , later trying use same context instance elsewhere in application. may occur calling dispose() on context, or wrapping context in using statement. if using dependency injection, should let dependency injection container take care of disposing context instances. object name: 'applicationdbcontext'. my middleware: namespace myapp { using system.threading.tasks; using microsoft.aspnetcore.builder; using microsoft.aspnetcore.http; using microsoft.aspnetcore.identity; using microsoft.extensions.options; public class mymiddleware<tuser, trole> tuser : class trole : class { private readonly requestdelegate _next; private readonly usermanager<t

office365 - Getting HTML selection from document in a Word add-in -

i'm creating office word add-in needs fetch text , show in task pane. since preferred show text same formatting in host document, i'm using getselecteddataasync() function , specifying office.coerciontype.html coercion type. works in word online; unfortunately not in word 2013 , 2016 clients. looking @ documentation ( http://dev.office.com/reference/add-ins/shared/document.getselecteddataasync ), says office.coerciontype.html supported word not explicitly mention word online. judging behaviour, seems documentation maybe faulty , should other way around. but maybe i'm missing something. ideas on why it's not working or how can proceed working? prefer minimal processing after getting selection, why fetching in html seemed best solution. fetching plain text not seem take paragraphs account absolute minimum requirement of formatting. the similar question i've found, apps office 365 - return selected text styling , formatted , related not answer question.

database - How to catch in trigger what changes caused by foreign key integrity in Postgres PL/PGSQL? -

case example: table "user" has fields id , total , table purchase has user_id (as foreign key "user".id on update cascade , on delete cascade ) , cost . i auto-update total on changes in purchase (so total equal sum of purchases given user). via row trigger after insert or update or delete on purchase . technically possible purchase.user_id changed, , there 2 cases: this change caused changing "user".id 1 user another. in case decrease total old user , increase new user. this change caused changing id in table "user" (and on update cascade changes corresponding user_id s in purchase ). in case should nothing own trigger. how catch second case in trigger? there analogous question catching deletion in purchase caused deletion in "user" . for case of cascading delete there nothing do; update s trigger on purchase nothing matching row in "user" not exist more. to handle update of "u

c++ - VC++ preprocessor parameters-count limit -

what vc++ preprocessor parameters-count limit? i'm using vs2013 i found doc. linux: https://gcc.gnu.org/onlinedocs/cpp/implementation-limits.html https://msdn.microsoft.com/en-us/library/ft39hh4x.aspx says maximumm number of parameters in 1 macro definition 127.

c++ - GStreamer memory leak issue -

i have object generate videos gstreamer. each time want generate new video y create 1 new object , add frames. after video finished, delete object gstreamer internal memory looks not released. after several videos generated ram allocated , linux kills process. why happening? how can solve issue? there other way it? gvideo.h: #ifndef gvideo_h #define gvideo_h #include <gst/gst.h> #include <string> class gvideo { public: gvideo(); ~gvideo(); void startvideo(std::string filename); void endvideo(); void addframe(gstsample* element); bool isrecording(){return _isrecording;} bool isdataneed(){return _dataneed;} private: void setdataneed(bool dataneed){_dataneed = dataneed;} protected: bool _isrecording; bool _dataneed; int _framerate; int _duration; gstclocktime _timestamp; gstelement *_pipeline; gstelement *_source; }; #endif //gvideo_h gvideo.cpp #include "gvideo.h" #include <gst/

osx - Homebrew won't update, but no error occurs -

i'm using homebrew on os x el capitan. worked long time, doesn't want update nor packages. when run brew update says already up-to-date. , though it's not newest version. brew --version is: homebrew 0.9.9 (git revision 06fe3; last commit 2016-08-10) homebrew/homebrew-core (git revision a059; last commit 2016-08-10) this 1 month old, , of packages got updates since then, homebrew doesn't want update them. when run brew doctor , says: your system ready brew. why won't homebrew update?

Activity Stack Android -

i understand how activity stack works , how use intent flags (single_top, etc etc) in correct way. example, if want avoid instantiate new activity if instantiated, how do? thanks lot in advance guys. well there good official documentation it. if need bad solution backstacking until have needed activity backstack can using method getrunningtasks in activitymanager , position of activity searching , backstack multiple times.

jquery - How to add dynamically class to single < li> when using in Loop -

i have created pagination using for-loop, using jquery how add dynamically class < li>. here code: echo "<ul class='pagination'>"; for($i=1; $i<=$number_of_pages; $i++) { echo "<li id='add_class'>"."<a href='first_year.php?p=$i'>".$i."</a>"; } echo "</ul>"; you can below. consider want add active class add class first li element $("ul.pagination > li:first").addclass("active"); add class nth position element (for example position 5, need pass 4 index) $("ul.pagination > li:eq(4)").addclass("active"); if want add class element $("ul.pagination > li").addclass("active");

How to write a query that uses variables in sqlalchemy? -

i have query works in mysql write using sqlalchemy. simplified version of query looks like: set @num = null, @val = null; select group_name, count(*) (select @num := if(@last=id, @num+1, 1) num, @last := id last, group_name order group_name) num<=100 group group_name; my problem setting variables @num , @last , using them in query. know can using execute (something this ), prefer use sqlalchemy tools building queries instead of row sql (for maintainance , compatibility reasons). possible?

javascript - How to add parameters to jqgrid using setGridParam? -

this code working properly: $("#list").jqgrid({ ... postdata: { filters:'{"groupop":"and","rules":[{"field":"category_id","op":"eq","data":"mydata"}]}' }, search: true, ... }); i tried add these parameters using setgridparam method: jquery("#list").setgridparam({ postdata: { filters:'{"groupop":"and","rules":[{"field":"category_id","op":"eq","data":"mydata"}]}' }, search: true, }).trigger('reloadgrid'); but doesn't work

sql - what is the alternative of giving a nested query in where clause returning more than 1 values in mysql -

what alternative of giving nested query in clause returning more 1 values in mysql? the query iam using single value select * libertymutual.echi_filtered anslogid = 2984012 , calltime not null order calltime limit 2,1; and need multiple anslogids other query select anslogid libertymutual.echi_filtered group anslogid which should return 3rd call every agent when sorted calltime. any appreciated.

Faster way of writing out to excel in powershell -

i have powershell script reads in csv , appends excel worksheet. runs quite painfully slow. have searched , seems limitation of using com write excel. suggestions have found speed write out entire ranges instead of cell cell. need format cells , doesn't seem possible when writing out ranges. suggestions on how optimize below code welcome. not have option use db. $csvpath = "z:\script_test\" $outputfile = "z:\script_test\exceltest.xlsx" foreach($csvfile in get-childitem $csvpath -filter "stats*.txt" ){ $csvfilepath = [io.path]::combine($csvpath, $csvfile) $rawcsvdata = import-csv -delimiter ";" -path $csvfilepath $excel = new-object -comobject excel.application $excel.visible = $false $workbook = $excel.workbooks.open($outputfile) $excelworksheet = $excel.worksheets.item("2016") $excelworksheet.activate() $excel.cells.item(1,1) = “pex” $excel.cells.item(1,2) = “run date” $excel.cells.item(1,3) = “execs” $excel.cells.i

php - Managing a new page in tcpdf -

i'm generating pdf reports in php using tcpdf. first page positions textbox correctly down page, textboxes in subsequent pages placed in header(one textbox per page) making document long. //code require_once('../report/header.php'); // add page $pdf->addpage(); $p=30; ($i = 30; $i < 1000; $i = $i + 20) { $pdf->createtextbox('patient card' . $i, 30, $p, 120, 40, 20); $p=$p+20; } i have made solution detects if have reached bottom of page try , fix above not usable incase of dynamic text(where text database). solution adds new page in case have reached value in y axis , resets y axis //code require_once('../report/header.php'); // add page $pdf->addpage(); $p=30; ($i = 30; $i < 1000; $i = $i + 20) { $pdf->createtextbox('patient card' . $i, 30, $p, 120, 40, 20); if ($i == 230 || $i == 430 || $i==......){ $pdf->addpage(); $p=30; } $p=$p+20; } is there way new pages can added

nclam - How change limit file size of Clamd service in Window? -

default limits: file size limit set 26214400 bytes. if scan file size > 25mb, occur error. the maximum stream size of 26214400 bytes has been exceeded. i try change: public clamclient(string server, int port) { maxchunksize = 131072; //128k maxstreamsize = 209715200; //200mb ,- 26214400; //25mb server = server; port = port; } but occur error when scan file: unable write data transport connection: existing connection forcibly closed remote host. how change limit file size of clamd service in window? thanks all. you need change nclam config ("clamd.conf"): streammaxlength 50m you have change clamclient instance higher maxstreamsize: var client = new clamclient("localhost", 3310) { maxstreamsize = 52428800 };

php - Getting value from function and adding outside of for loop -

i have following: public function go(){ for($x=0;$x<=31;$x++) { $this->get_answerrules($x); $donetime+=$donetime; } echo $gmdate("i:s", $donetime);; } and public function get_answerrules($x){ ... ... ... if($response = $this->request($data)){ $obj = json_decode($response,true); foreach($obj $file) { $time += $file['batch_dura']; } $donetime = $time; return $donetime; }else{} } how value 31 loop cycles , add them together? right results coming blank. you not using results of method call: public function go(){ for($x=0;$x<=31;$x++) { $this->get_answerrules($x); $donetime+=$donetime; } // below won't work `$gmdate` not in scope of method. echo $gmdate("i:s", $donetime);; } should like: pu

Ansible Playbook to push hostname to ip addresses -

i have csv file has host name corresponding ip address in it. trying write ansible playbook using lineinfile = command variable read csv file , place hostname of corresponding ipaddress on host ipaddress. don't know if way go. want run playbook addressed host. if need connect hosts in csv file , set hostname corresponding name value file, do: --- - hosts: localhost tasks: - add_host: name="{{ item.split(',')[1] | trim }}" ansible_host="{{ item.split(',')[0] }}" group=csv with_lines: cat host-ip.csv - hosts: csv tasks: - hostname: name="{{ inventory_hostname }}"

How to update a single row in C# mysql -

my problem it updates data same id. because have multiple data same id. [see picture below]. i want update row near expiration (30 days). don't want items expired. here code: (int = 0; < datagridviewpos.rows.count; i++) { cmd = new mysqlcommand(@"update inventory2 set quantity = @quantity itemid = @itemid order expiry", sqlconnection); //codehere } screenshot thanks update: (int = 0; < datagridviewpos.rows.count; i++) { cmd = new mysqlcommand(@"select * inventory2 itemid = @itemid order expiry", sqlconnection); //codehere cmd = new mysqlcommand(@"update inventory2 set quantity = @quantity itemid = @itemid , curdate() < expiry order expiry", sqlconnection); //codehere } you need check expiration in sql ie where itemid = @itemid , curdate() < expiry the exact nature of depends on how defin

java - Creating a header with two line in excel file with apache POI -

Image
how can header java code apache poi? usually merging 2 cells "projets" items. see https://poi.apache.org/spreadsheet/quick-guide.html#mergedcells basically define merged areas calls this sheet.addmergedregion(new cellrangeaddress( 0, //first row (0-based) 0, //last row (0-based) 0, //first column (0-based) 1 //last column (0-based) )); see setting value cells after merging in poi , merging cells in excel using apache poi more discussion around this.

stl - What values are inserted in the set with this C++ code? -

i given interview question had following code. unfortunately, didn't right. explain code doing, commented line? here code. #include <iostream> #include <set> struct c { bool operator()(const int &a, const int &b) const { return % 10 < b % 10; } }; int main() { std::set<int> x({ 4, 2, 7, 11, 12, 14, 17, 2 }); std::cout << x.size(); std::set<int, c> y(x.begin(), x.end()); // not sure inserted in set std::cout << y.size() << std::endl; return 0; } when run, x contains in order: 2 4 7 11 12 14 17 y contains in order: 11 2 4 7 my hunch set reverses operator check equality (since set contains unique values). unique values of a%10 exist.

c# - Find a ListView control in tab page -

i have 2 listviews in tab page. looking function find right control name: i have foreach (control c in form.controls) // loop through form controls { if (c tabcontrol) { tabcontrol f = (tabcontrol)c; foreach (control tab in f.controls) { tabpage tabpage = (tabpage)tab; foreach (control control in tabpage.controls) { messagebox.show(control.name); // code go here } } } } the controls collection has find function returns array: control[] ctrls = this.controls.find("listview1", true); if (ctrls.length == 1) { messagebox.show("found " + ctrls[0].name); }

javascript - nightwatch.js - scroll until element is visible -

i want scroll page until desired element appear visible. i have tried: browser.execute(function () { window.scrollby(0, 10000000); }, []); and browser.getlocationinview("<selector>", function(result) { this.assert.equal(typeof result, "object"); this.assert.equal(result.status, 0); this.assert.equal(result.value.x, 200); this.assert.equal(result.value.y, 200); }); first not scroll page , second fails because element not visible. how fix this? want scroll till element appear visible. if using jquery can this: browser.execute(function () { $(window).scrolltop($('some-element').offset().top - ($(window).height() / 2)); }, []); or using plain javascript: browser.execute(function () { document.getelementbyid("some-id").scrollintoview(); }, []); also, in cases suggest use nightwatch's waitforelementvisible instead of assertions because when using assertions check @ given

cordova - Push Notifications To Android App (GCM) -

looking integrate push notifications first time android app. i have done ios app using apns, speaking want notification alert user, don't want handle within app. with ios can via broadcasting apns , app isn't concerned notifications. whereas reading on android app needs register , listen these updates within app. is correct? from reading on android app needs register , listen these updates within app. is correct? depends on use case. if want have control on specific device(s) push sent, yes, must obtain registration id in app , store on server. id used google find device push has sent. can construct message push , use registration ids tell google push message to. however, firebase console (google cloud messaging firebase cloud messaging nowadays (same product, different name)) possible send push notifications target group can specify. example, can use firebase console send push notification users have made in app purchases in app. firebase conso

python - print([[i+j for i in "abc"] for j in "def"]) -

i'm new python. i stumped upon 1 of comprehension print([[i+j in "abc"] j in "def"]) could please me convert comprehension in loop? i'm not getting desired result loop: list = [] list2 = [] j in 'def': in 'abc': list.append(i+j) list2 = list print (list) the above try loop. i' missing something. below should desired result in loop want. ([[‘ad’, ‘bd’, ‘cd’], [‘ae’, ‘be’, ‘ce’], [‘af’, ‘bf’, ‘cf’]]) which believe matrice. thanks in advance. the easiest thing unravel comprehension take 1 comprehension @ time , write that loop. so: [[i+j in "abc"] j in "def"] becomes: outer_list = [] j in "def": outer_list.append([i + j in "abc"]) alright, cool. we've gotten rid of outer comprehension can unravel inner comprehension next: outer_list = [] j in "def": inner_list = [] in "abc": inner_list.append(i + j)

c# - Loop thorough multiple HTML tables in HTML Agility Pack -

i followed example in below link , able parse html table datatable. http://blog.ditran.net/parsing-html-table-to-c-usable-datalist/ but not able parse multiple tables,when traverse through tr first tr have column names , rest have data in each table.so using logic , storing table data in dictionary , sending todatatable function. can on how can loop thoriugh multiple tables , implement same logic.appreciate it. var trowlist = doc.documentnode.selectnodes("//tr"); foreach (htmlnode trow in trowlist) { if (previousrowspanlist.count > 0) { thedict = previousrowspanlist[0]; previousrowspanlist.remove(thedict);        //remove off list                             isworkingwithrowspan = true; } else { thedict = new list<keyvaluepair<string,

android - Can I update OpenSSL version of just one .so file -

i using ffmpeg based https://github.com/sourab-sharma/touchtorecord project app. libavformat.so file's version openssl 1.0.2d , google play requires minimum 1.0.2h . how update it? or replace one? check perfect solution here: https://github.com/sourab-sharma/touchtorecord/issues/23

css - Add Rules to Stylesheets with JavaScript - insertRule not working -

im learning using javascript make css more dynamic reason code here wont work. im developing inside visual studio, intellisense not show me method insertrule. basis use documentation learning: https://davidwalsh.name/add-rules-stylesheets https://www.w3.org/wiki/dynamic_style_-_manipulating_css_with_javascript same written there somehow can't use function on object. window.onload = function() { var bar = newsheet(); bar.insertrule("header { float: left; opacity: 0.8; }", 1); }; function newsheet() { // create <style> tag var style = document.createelement("style"); //webkit hack style.appendchild(document.createtextnode("")); // add <style> element page document.head.appendchild(style); return style.sheet; }; the element style works other dom tag, , such, can use innerhtml append styles it, since created element javascript, need modify value: window.onload = function() { var bar = newsheet(); bar.insertrule(&qu

android - Create file of an ArrayList of java class -

i'm making android app reminds me when it's someone's birthday. i'm able add name , corresponding date. but, i'm stuck @ saving part. i've tried looking solutions unable port needs. since it's arraylist , not simple string cannot serialized (if i'm correct?) , therefore not saved. there other way save kind of data? here code: item.java: public class item implements serializable{ private string name; private string date; public item(string name, string date){ this.name = name; this.date = date; } public string getname(){ return name; } public string getdate(){ return date; } public void setname(string name){ this.name = name; } public void setdate(string date){ this.date = date; } } mainactivity.java: public class mainactivity extends appcompatactivity { recyclerview recyclerview; static recyclerviewadapter adapter; static arraylist<item> itemlist = new arraylist<&

angularjs - Angular2 Object Instantiation for Asynchronous Data -

i working on angular2 project gets object asynchronously api using new observable framework. this._accountsservice.getaccountdetails(this.id) .subscribe( accountdetails => this.accountdetails = accountdetails, err => this.errormessage = <any>err, () => console.log(this.accountdetails) ); when tried access property of object using interpolation {{accountdetails.username}} ,we got property undefined error, because object had not yet been received api. fixed instantiating object in class accountdetails: accountdetails = new accountdetails(); this works, noticed in angular 1, fake object created, if object undefined, there never an undefined error -- show empty value in interpolated code. change in angular2? also, noticed when used *ngfor in our code iterate through properties of object, display empty value (rather trigger object undefined error) if object had not yet been received api. occurs internally in *ngfor dire

Ruby skips if statements -

i have ruby program here w/c consists of hashes. when user enters l or p or sc check if computer generated key matches criteria on first variable w/c player or user. if matches criteria return won. if it's not return loose. otherwise if it's same print tie. my_choices = { 'l' => 'light', 'p' => 'paper', 'sc' => 'scan', } def test?(first, second) (first == 'p' && second == my_choices ['l']) || (first == 'l' && second == my_choices ['p']) || (first == 'sc' && second == my_choices ['sc']) || (first == 'l' && second == my_choices ['l']) end def print_results(player, computer) if test?(player, computer) puts("you won!") elsif test?(computer, player) puts("computer won! loose!") else puts("it's tie!") end end puts "enter key: " choice = gets().chom

angularjs - How to prevent destroy data from DataTable with Angular -

Image
i'm try implement datatables angular, i'm googled , many solutions creating directives, ok old "normal" way draw datatable, problem sorting or typing search box data lost!! e.g: and code: view var myapp = angular.module('myapp', ['ngroute','ui.utils']); myapp.controller("companycontroller", function ($scope, $window, companyservice) { $scope.companies = []; $scope.company = {}; $scope.datatableopt = { //custom datatable options "alengthmenu": [[10, 50, 100, -1], [10, 50, 100, 'all']], }; $scope.$watch("data", function (value) { console.log("data changed, refresh table:"); var val = value || null; if (val) { } }); $scope.initializeindexview = function () { var getallprocess = companyservice.getallcompanies(); getallprocess.then(function (response)

haskell - In aeson, how do you encode from a Value without resulting in scientific notation? -

i have parsed large amount of json, manipulated values , i'd write out. aeson decodes numbers scientific, when encodes it, default, scientific shows numbers in scientific notation in many cases, , aeson not offer means can see change that. > decode "[\"asdf\", 1, 1.0, 1000000000.1, 0.01]" :: maybe value (array [string "asdf",number 1.0,number 1.0,number 1.0000000001e9,number 1.0e-2]) encode (array [string "asdf",number 1.0,number 1.0,number 1.0000000001e9,number 1.0e-2]) "[\"asdf\",1,1,1.0000000001e9,1.0e-2]" > encode (array [string "asdf", number 1, number 1.0, number 1000000000.1, number 0.01]) "[\"asdf\",1,1,1.0000000001e9,1.0e-2]" how can write out value numbers in more acceptable format other languages can consume? let's pretend i'm not concerned precision loss or integer overflows. scientific package has means format numbers in manner, aeson happened not use it

swift - Collectionview with Different items in a row -

okay. collectionview works fine. want change layout bit. have array different numbers array.count = 5 , need 5 items in row. don't know how display in collectionview . thanks help. update: now every row example 6 ! but don't know how handle array of numbers! func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize { let numberofcellinrow : int = 6 let padding : int = 1 let collectioncellwidth : cgfloat = (self.view.frame.size.width/cgfloat(numberofcellinrow)) - cgfloat(padding) return cgsize(width: collectioncellwidth, height: 200) } implementing sizeforitematindexpath, part of protocol of uicollectionviewdelegateflowlayout, how set dimensions of uicollectionviewcell dynamically (i.e., @ runtime). in sizeforitematindexpath, create cgsize object how big you'd each uicollectionviewcell be, , use object retu

jquery - c# MVC Dynamically adding row to HTML Table but all fields in 1 cell -

i new c# mvc , need help. using matt lunn's example ( http://www.mattlunn.me.uk/blog/2014/08/how-to-dynamically-via-ajax-add-new-items-to-a-bound-list-model-in-asp-mvc-net/ ) dynamically add new items bound list in html table. instead of new items getting added each <td> added in first column <td> them spread out in corresponding columns: fy 2017 account element 345789 position director job title director of marketing this result in first cell: new fy box new accountelement box new position box new job title box but want this: new fy box in 1st cell | new account element box in 2nd cell | new position box in 3rd cell | new job title box in 4th cell here view: <i> <table> <tr> <th style="width:60px">fy</th> <th style="width:230px">account element</th> <th align="center" style="width:50px">position

python - Modify string in bash to contain new line character? -

i using bash script call google-api's upload_video.py ( https://developers.google.com/youtube/v3/guides/uploading_a_video ) i have mp4 called output.mp4 upload. the problem cannot array work how like. this new line character "required" because arguments python script contain spaces. here simplified version of bash script: # operator may change these hold=100 location="foo, montana " declare -a file_array=("unique_id_0" "unique_id_1") upload_file=upload_file.txt upload_movie=output.mp4 # hit enter @ end b/c \n not recognized upload_title=$location' - '${file_array[0]}' - hold '$hold' sweeps ' upload_description='the spectrum recording made in @ '$location'. ' # overwrite 1st call > else apppend >> echo "$upload_title" > $upload_file echo "$upload_description" >> $upload_file # load each line of text file array ifs=$'\n' cmd_google=$(<$up

jsp - Publishing Error while cleaning wildfly server and redeploying a web app -

Image
i'm working on simple web project using jsp servlet technologies wildfly 9 server , when make changes project (modifying code of servlets ,or code of jsp pages ) , try clean server in order apply changes , redeploy web application next error "publishing wildfly 9 has enountered problem " .....as below me solve , thks check permissions of c:\tools against of c:\users\username. can use windows cacls tool that. had same problem when working c:\work directory , since got home directory errors disappeared

C# How does Dictionary work when we initialize a class within as a value? -

assuming have following code: public static dictionary<string, viewmodelbase> loaddictionary() { dictionary<string, viewmodelbase> tempdictionary = new dictionary<string, viewmodelbase>(); tempdictionary.add("loginview", new loginviewmodel()); tempdictionary.add("signupview", new signupviewmodel()); tempdictionary.add("contactlistview", new contactlistviewmodel()); return tempdictionary; } i refer line: dictionary<string, viewmodelbase> tempdictionary = new dictionary<string, viewmodelbase>(); does compiler first create constructor (parameterless ctor) , add keyvaluepairs? if so, how parameter ctor (of loaddictionary)? and important question relevant post is: when add keyvaluepairs , values instantiated or wait called , instantiated? i mean to: new loginviewmodel() new signupviewmodel() new contactlistviewmodel() edit: i want know if tempdictionary.add("loginview", n

mobx - Cascading actions not rendering -

i'm doing this: import { observable, action } 'mobx'; export default class datastore { @observable pagedata:object @action fetch() { superagent.get(url1) .send('got url 1', action((err, results) => { if (err) return; this.pagedata = this.pagedata || {}; this.pagedata.urldata1 = results; this.fetchanother(); })); } @action fetchanother() { superagent.get(url2) .send('got url 2', action((err, results) => { if (err) return; this.pagedata = this.pagedata || {}; this.pagedata.urldata2 = results; })); } } these actions separate because fetchanother called itself. i inject store react component class. when fetch called, first async callback wrapped in action updates page, , urldata1 rendered. 2nd callback in fetchanother called , executes, not render, , urldata2 show if force re-render in other way. why, , how can fix that? mobx doesn't

vba - excel macros for pasting multiple columns data under one column -

Image
in excel data in below format, but need data in below format, can me in creating macros it. i used below macro not working, sub combinecolumns1() 'updateby extendoffice 20151030 dim xrng range dim i, j integer dim xlastrow integer dim xtxt string on error resume next xtxt = application.activewindow.rangeselection.address set xrng = application.inputbox("please select data range", "kutools excel", xtxt, , , , , 8) if xrng nothing exit sub xlastrow = xrng.columns(1).rows.count + 1 = 4 xrng.columns.count j = 1 3 range(xrng.cells(j, i), xrng.cells(xrng.columns(i).rows.count, i)).cut activesheet.paste destination:=xrng.cells(xlastrow, 1) xlastrow = xlastrow + xrng.columns(i).rows.count next j = 1 = + 2 next end sub for formula put

java - Can we use one wsimport task for multiple wsdl's in gradle without repeating the similar code? -

i writing gradle task wsimport generate web service artifacts. task wrote working fine , shown below. task wsimport { ext.destdir = file('gen') dolast { ant { sourcesets.main.output.classesdir.mkdirs() destdir.mkdirs() taskdef(name: 'wsimport', classname: 'com.sun.tools.ws.ant.wsimport', classpath: 'c:/users/sbhattar/git/java_commons/common/java/lib/jaxws-2.2.6/jaxws-tools.jar' ) wsimport(keep: true, destdir: sourcesets.main.output.classesdir, sourcedestdir: destdir, extension: "true", verbose: "false", quiet: "false", xnocompile: "true", wsdl:"http://spapen2w1.shashwat.com.planservice_4_0.wsdl") { xjcarg(value: "-xautonameresolut