Posts

Showing posts from January, 2015

php - RDS access from my own computer using apache server -

hi guys m trying access rds instance computer using apache in wamp after fiddling around found out security group checked security group , made traffic ports ips 0.0.0.0/0 tried make ip when tried run script in computer script <?php $conn = new mysqli("xxxxxxxxxxxxxxxxxxxx.rds.amazonaws.com","xxxxxxxxx","xxxxxx","xxxxx"); if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } else { echo "yess"; } ?> this gave me error "connection failed: connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond. " do? idea appreciated.

c# - NEST Elastic Search: Difference between FilterInputs term and terms? -

filterinputs mustfilters; mustfilters &= ms.term("cityid", filterinputs.cities); mustfilters &= ms.terms("cityids", filterinputs.cities); what difference between above 2 lines? as far have tested, second allow multiple cities in document kye cityids. if matches filterinputs.cities=> record returned. while first allow once city.if matches=>record return else not. please confirm. term allows match 1 term. according documentation: the term query finds documents contain exact term specified in inverted index. see here while terms allows specify multiple terms , match of them.it works in in sql . according documentation: terms query filters documents have fields match of provided terms (not analyzed). see here

Swift: Get multiple array values like "x" -

for example, have array var myarray = ['player_static.png', 'player_run0.png', 'player_run1.png', 'player_run2.png', 'player_jump0.png', 'player_jump1.png'] is there simple way "player_runx.png" images? you can use filter elements hasprefix("player_run"): let myarray = ["player_static.png", "player_run0.png", "player_run1.png", "player_run2.png", "player_jump0.png", "player_jump1.png"] let playerruns = myarray.filter{$0.hasprefix("player_run")} print(playerruns) //["player_run0.png", "player_run1.png", "player_run2.png"]

android - Filtering a listview based on fields not displayed in listview -

i have app grabs json file internet, parses through , creates , item object it. items have following fields: type (image, text), , data (this url if item type image or string of text if item type text) when app first loads list displays mix of items both types text , images. if item image, image displayed in list item in listview, if it's text text displayed. what need do(and having problem with) need when user selects menu "image only" show objects have type "image" in listview , hide items have type "text", if select "text only", filters out image list items , displays items of type "text". if select "all" should display default when app first loads. i not display object's type field on listview anywhere, data field of object either image loaded url or text. seems every filtering example come across when types text filters list text displayed in list , visible in list need filter not visible on list.

JavaScript: Convert different Values in a single Number -

i have following 3 values: week (number between 1 , 52) year (number between 0 , 99) string (between "aa" , "zz") is there way convert ("pack") number between 0 , 999999? or information number of 6 digits? the goal (later) unpack/convert number 3 values. thank much! this not sallest possible number, easy code,decode: 52992626 if see mean... (wwyyaazz)

c# - I can start threads with switches but can't end them -

i want start number of threads based on number of threads computer running program have. i tried doing switches seems can't end threads. this main thread , doesn't work, says threads out of context on 2nd switch is there can add or should use different method altogether? using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.collections; using system.io; using system.diagnostics; using system.threading; using system.security.principal; namespace yahtzee_datamine { class program { public static random dicevalue = new random(); public static int numberofdie = new int(); public static int numberofsides = new int(); private static system.object lockthis = new system.object(); public static decimal percent = new decimal(); public static consolecolor oldcolor = console.foregroundcolor; static void main(string[] args) { while (true) {

c# - EF - Best way to manage DbContext? -

i know there alot of articles regarding topic, wherever looked, either complicated or unclear me. my team develops web application uses entity framework code first. use autofac dependency injection. currently, data access looks follows: the api supplied projects not contain ef: public class dataservice { private idbcontextfactory<mycontext> _factory; private idataserviceexecutor _dataserviceexecutor; public dataservice(idbcontextfactory<mycontext> factory, idataserviceexecutor executor) { _factory = factory; _dataserviceexecutor = executor; } public void additem(product prod) { using (var context = _factory.create()) { if (_dataserviceexecutor.additem(context, prod)) context.savechanges(); } } } my dataserviceexecutor: public class dataserviceexecutor { private irepository<product> _products; public dataservice(irepository<product> products...more repo

c++ - "unable to read memory" when filling 2D dynamic array -

the code below fails @ loop fills dynamic 2d array when trying fill first element of array. debugger tells me unable read memory. during run, rows = 7 , cols = 20, if matters. i appreciate help. searched forum. thank you!! // sets rows number of newline characters in file int rows = countrows("bookmaze.txt") + 1; /* +1 bc last row has no newline char */ // sets number of columns number of characters on single row in file int cols = countcols("bookmaze.txt"); char **p_rows; // allocate p_rows = new char*[rows]; (int = 0; < rows; i++) p_rows[rows] = new char[cols]; // fill (int = 0; < rows; i++) { (int j = 0; j < cols; j++) { p_rows[i][j] = '*'; } } you have typo/bug here: for (int = 0; < rows; i++) p_rows[rows] = new char[cols]; ^^^^ it should be: for (int = 0; < rows; i++) p_rows[i] = new char[cols];

mysql - How to get the last 3 group created at the same time? -

i'm trying last 3 groups of coupons created @ same date. table looks so: +-------------+-----------+ |coupon name |created @ | +-------------+-----------+ |c1 |2016-01-17 | |c2 |2016-01-17 | |c3 |2016-01-18 | |c4 |2016-01-19 | |c5 |2016-01-19 | |c6 |2016-01-20 | |c7 |2016-01-20 | |c8 |2016-01-20 | |c9 |2016-01-20 | |c10 |2016-01-21 | |c11 |2016-01-21 | +-------------+-----------+ my result should be: +-------------+-----------+ |coupon name |created @ | +-------------+-----------+ |c4 |2016-01-19 | |c5 |2016-01-19 | |c6 |2016-01-20 | |c7 |2016-01-20 | |c8 |2016-01-20 | |c9 |2016-01-20 | |c10 |2016-01-21 | |c11 |2016-01-21 | +-------------+-----------+ i have looked same question couldn't find any. thanks in advance, try this: select t1.`coupon name`, t1.`created at` my

How to create a global array in netlogo -

i trying create array can accessed of patches, seems though setting global, available in function in gave value. have following 3 segments of code in respective places: globals[a] toward top of program, in setup function have set array:from-list n-values asize [0] for integer asize defined in setup function, , go method calls function addtoarr runs following line: array:set index val for index , val defined earlier in function. might worth noting within ask patches . when run code following error: extension exception: not array: 0 error while patch 70 91 running array:set called procedure addtoarr called procedure go called button 'go-forever' i confused error, because seems me defined a array, netlogo differs in opinion. netlogo not support global arrays? appreciated.

angularjs - Resetting a Formly form within an ng-repeat -

i have angular formly form inside ng-repeat. i've got working expect except reset button. reason clicking reset button resets last form, not 1 it's supposed to. submitting , updateinitialvalue() seem work fine. <div ng-repeat="model in vm.models"> here form declaration inside repeat: <formly-form model="model" fields="vm.fields" options="vm.options[$index]" form="vm.form[$index]"> and here reset button. <button type="button" class="btn btn-default" ng-click="vm.options[$index].resetmodel()">reset</button> here whole thing in fiddle. http://jsbin.com/feguvulumo/edit?html,js,output thanks in advance can give! i figured out @kentcdodds on formly gitter chat ( https://gitter.im/formly-js/angular-formly ) he suggested issue repeating forms sharing same field configuration. to fix it, implemented function called ng-init inside ng-repeat. builds arra

docker-compose 1.6 "args" attribute on "build" -

i'm trying use new "args" attribute pass variable dockerfile build. yaml parser not accepting parameter. error: yaml.scanner.scannererror: mapping values not allowed here for version 2 of docker-compose.yml requirements docker-compose 1.6+ , docker-engine 1.10+ , have both them installed. this part of docker-compose file: version: '2' services: solr: build: ./solr args: solr_port: 8983 volumes: - ./apps/solr-conf:/opt/solr/server/solr ports: - 8983:8983 the error refers "args" line. the issue here build field should specified path build context or object options, not both. if going use args field, have specify path of build in context field. check below how should be: version: '2' services: solr: build: context: ./solr args: solr_port: 8983 volumes: - ./apps/solr-conf:/opt/solr/server/solr ports: - 8983:8983

Retrieving certain values from a variable jMeter beanshell script -

currently developing script in jmeter, need retrieve x amount of values response push values http request, here tricky part response table changes (e.g. rows increase or decrease each time test run) far i've created regex extractor retrieves between table need create beanshell post processor retrieves values variable retrieved regex extractor , applies them http request. i'm not sure if best way open suggestions on doing way. you need beanshell preprocessor applied 2nd request, not postprocessor applied 1st request i don't think using regular expressions idea parse html, suggest going css/jquery extractor or xpath extractor instead once have required values in form of var_1=foo var_2=bar var_matchnr=2 you able add these values 2nd http request like: import java.util.iterator; import java.util.map; iterator iter = vars.getiterator(); int counter = 1; while (iter.hasnext()) { map.entry e = (map.entry)iter.next(); if (e.getvalue() != null) {

php - Why does $n = $n + $n not work -

i've tried out code use loop in php add numbers seems not work, how can be? $n = 3; //or else for($i=0;$i<$n;$i++){ $n = $n+$n; } echo $n; this test code else, i'd still work, please help you increasing loop ending condition $n inside loop this means never exit loop. this infinite loop, , wont ever print anything. also loop needs $i = 0; $i < $n; $i++

c# - Shifting bits of 64Bit Ints getting error -

i'm experimenting bit shifting using uint64 data type. code works expected when use constant number. however, fails when use variable. compiler issues "operator << cannot applied operands of type 'int' , 'ulong'" error. how go fixing code can use variable in place of constant number? here's excerpt of code using system.io; using system; class program { static void main() { uint64 x=0; int pos = 2; x = ((uint64)x | (1 << pos)); console.writeline(x); } } try making right-hand side operand of | -operator of type uint64 , e.g.: x = x | (1ul << pos); btw, 1 may prefer compound form: x |= 1ul << pos;

android - Rotating a view and handling redraws -

i using rotationanimation rotate custom view object (derived directly view ). view object's ondraw() called repeatedly during animation, , onanimationend callback called. in callback updating view's backing data object record new rotation. the problem seeing view object continues have ondraw() called after onanimationend callback has been called , has returned. problem because, in callback, update values cause view render contents rotation. since animation still transforming view, end-result briefly over-rotates before snapping correct position rotation transform removed. so, if animation causes animated view's ondraw() called after onanimationend called, how can determine when animation has really finished can update backing object model @ appropriate time? i'd grateful on this. for benefit of reading question in future, solution reliably detecting end of animation seems to override onanimationend() on view object being animated. further

asp.net - Sorting a nested list array in C# -

i trying sort nested array of elements in asp.net , having bit of trouble. have playlist has model so: public class playlist { public playlist() { this.date = new list<dates>(); } [key] public int id { get; set; } public string userid { get; set; } public list<dates> date { get; set; } public class dates { [key] public int dates_id { get; set; } public list<places> place {get; set;} } public class places { [key] public int places_id { get; set; } public string id { get; set; } } }` as can see nested array of objects, dates, array of objects, places. what doing pulling out data so: playlist = db.playlists.where(e => e.userid.equals(userid)).orderby(q => q.id).include("date.place").tolist(); what realized places in date object wasn't being pulled out in sorted array based on place_id, rather randomly. there way pull out playlis

html - Rails 4 - rendering views is slow due associations -

i have query: @companies = company.includes(:car, :member).where('companies.status != 3 , companies.status != 4 , companies.status != 5').order(sort_column + " " + sort_direction) views: all_companies.html.erb : <div id="cars_list"> <%= render :partial => 'companies_list', locals: { companies: @companies } %> </div> _companies_list.html.erb : <div class="tr"> <span class="td">id</span> <span class="td">registration</span> ... </div> <% companies.each |company| %> <%= form_tag edit_inline_company_path(:id => company.id), :method => "post", :id => "id#{company.id}", :remote => true %> <%= render :partial => 'edit_inline_company', locals: { company: company } %> <% end %> <% end %> _edit_inline_company.html.erb : <span class="td"> <s

java - How can I get in game player ELO with the Riot Games API without reaching the API limit? -

i have question riotgames api. have api token riot games , limited 10 requests per second. however, when want read in game info player elo + divisions, need request. in game info champion runes masteries , on, still need elo, need request server. by time have looped 10 players, have reached api limit because need general request player list , other requests each player. you error handling retry request when receive response says limit has exceeded. function request(player) response = riotgamesapi(player1) if response.status == "limit exceeded" response = request(player) else return response end end this call recursively until receive valid response

initialization - when does javascript initialize vars? -

var x = ["aaa", "bbb", "ccc", ...]; function f() { var y = ["aaa", "bbb", "ccc", ...]; } it big array, @ least in opinion. i assume y gets initialized again @ every instance. would global x initialized 1 time when page loaded? seems reasonable... yes (+27 chars satisfy so!)

Creating an array in Swift that has random boolean values -

i working on function must create array of random boolean values , lost @ how make work inside function. on appreciated. sadly, confined rules names , how must see general structure must use, can't see how logically isn't woking. func thirdfunction() { //var numoftrue = 0 //var numoffalse = 0 var sometrue = true var randbools = [bool] () num in 1...10{ let random = arc4random_uniform(2) print(random) if (random == 0){ sometrue = false randbools.append(sometrue) } else { randbools.append(sometrue) } } print (randbools) } this works: var array: [bool] = [] func randomizer() { var bool: bool = false num in 1...10 { let random = arc4random_uniform(2) if random == 0 { bool = false } else { bool = true } array.append(bool) } print(array) }

ios - How to cancel a segue in certain conditions (if/else)? -

this question has answer here: conditional segue in swift 2 answers i creating app. in view, there several text fields in user inputs numbers, presses button, , transported next view controller. how make if person taps button, , 1 or more text fields empty, segue cancels? here code area far: override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if savebutton === sender { let name = nametextfield.text ?? "" // set meal passed meallisttableviewcontroller after unwind segue. meal = meal(name: name) } if calcbutton === sender { if weightinkilos.text == "" && percentofdehydration.text == "" && ongoinglosses.text == "" && factor.text == "" { let alertcontroller = uialertcontroller(title: "fields left empty.",

html - Make divs same size as the biggest one inside the parent -

Image
so have div 3 childs, 1 of them has less text others, image , button move, want position of image not dependent of size of text, can stay in same position biggest child image. parent position: relative; , child position: absolute; doesn't work, because image , button traslape html: <div id="child"> <h5>about us</h5> <p>lorem ipsum dolor sit amet, consectetuer adipiscing elit. donec molestie. .</p> <img class="img-responsive" src="http://www.marijazaric.com/minimalism_responsive/images/picture1.jpg" alt=""/> <button>read more</button> </div> sass: .parent display: flex flex-wrap: wrap justify-content: center #child border-style: solid margin-left: 25px margin-right: 25px if declare each of "child" elements flex container, can layout want. this quick example assumes parent element 3 elements "child" class va

multithreading - Java program with multiple threads not working -

so, i'm having problem gui i'm designing java app renames files in given directory junk (just fun). main block of code behind all: import java.io.file; import java.io.ioexception; import java.io.printwriter; import java.util.arraylist; import java.util.hashmap; import java.util.scanner; import org.json.simple.jsonobject; import org.json.simple.parser.jsonparser; import org.json.simple.parser.parseexception; /** * class renaming files garbage names. * methods static, hence private constructor. * @author shadow hacker */ public class renamefiles { private static int renamedfiles = 0; private static int renamedfolders = 0; public static char thechar = '#'; public static arraylist<file> filewhitelist = new arraylist<>(); public static hashmap<file, file> revert = new hashmap<>(); public static int getrenamedfiles() { return renamedfiles; } public static int getrenamedfolders() { return r

java - Recursion: Determine if there are two elements in an array A that sum to k -

i've seen question asked lot. how works: check sum of first , last. if sum more k last-- or if less k first++. carries on recursively till either first == last or sum k found. **note values in array sorted in ascending order. i've tried using recursion, whenever run it, returns "false". i've tried arrays of sizes , test cases return false. e.g. array[1 2 3 4 5 6], size n = 6 , k = 7 returns false when should true. cannot seem find bug. can please give me indication making mistake? , if i'm not mistaken runs in o(n) time? public static boolean sum( int[] a, int n, int k ) //where k sum needed , n size of array { if (k <= a[0] || k >= a[n]*2) { return false; } int = 0; int j = n-1; return sum_recursion(a, n, k, i, j); } private static boolean sum_recursion(int[] a, int n, int k, int i, int j) { if(i == j) { return false; } else if((a[i] + a[j]) == k) { return true;

c# - How to fix "MessageEncoder content type parsing is not supported" error when uploading to an asp.net iis server? -

i have app upload image asp.net webservice via soap. works 4mb images , fails following error: additional information: there exception running extensions specified in config file. ---> maximum request length exceeded. so made these changes web.config based on stack overflow post, said default max upload size of asp.net 4mb: <httpruntime maxrequestlength="1048576" /> <requestlimits maxallowedcontentlength="1073741824" /> from stackoverflow link but error: exception thrown: 'system.platformnotsupportedexception' in mscorlib.ni.dll additional information: messageencoder content type parsing not supported. if remove changes web.config error goes away. maxrequestlength value in kilobytes, whilst maxallowedcontentlength in bytes. if change this, sure keep them matching.

python - Pandas : Merge two dataframe where the keys are different -

i have 2 pandas dataframe, 1 store values , stores weight key of value dataframe : [symbol, date, hour] , weight dataframe [symbol, date]. in [8]: value_df = pd.dataframe({'symbol':['s1','s1','s1','s1','s2','s2','s3'], 'date' : [20150101,20150101, 20150101, 20150102,20150101,20150102,20150103], 'hour' : [8,9,10,8,8,8,8], 'value' : [10,10.1,10.2,11,100,101,300]}) in [9]: value_df out[9]: date hour symbol value 0 20150101 8 s1 10.0 1 20150101 9 s1 10.1 2 20150101 10 s1 10.2 3 20150102 8 s1 11.0 4 20150101 8 s2 100.0 5 20150102 8 s2 101.0 6 20150103 8 s3 300.0 in [10]: weight_df = pd.dataframe({'symbol': ['s1','s1','s1','s2','s2','s2','s3','s3','s3'], 'date':[20150101,20150102,20150103]

Why does this Java program has infinites loops? -

this question has answer here: how compare strings in java? 23 answers why boolean conditions condition return true ? if variable reponse equal constants oui or non ; final string oui = "o"; final string non = "n"; string reponse = oui; // code omitted { // code omitted // true boolean condition = false; { system.out.println(msg_sol_troncon); reponse = mscanner.nextline(); // debug system.out.println("reponse:" + reponse + ":fin"); /* // boucle infinie, problème avec la condition // infinite loop condition = !((reponse == non) || (reponse == oui)); system.out.println("condition : " + condition); if (condition) { system.out.pr