Posts

Showing posts from May, 2015

browser - Is Adblock filtering my website? -

how can bypass ? has 'ad' on hostname, think reason. http://testinad.info every resources blocked. unviewable running adblock. there in code ? or deblacklisted ? failed load resource: net::err_blocked_by_client http://testinad.info/assets/css/style.css failed load resource: net::err_blocked_by_client http://testinad.info/assets/img/logo.svg failed load resource: net::err_blocked_by_client http://testinad.info/assets/img/webicon-facebook.svg failed load resource: net::err_blocked_by_client http://testinad.info/assets/img/webicon-googleplus.svg failed load resource: net::err_blocked_by_client http://testinad.info/assets/img/webicon-twitter.svg failed load resource: net::err_blocked_by_client http://testinad.info/assets/img/logo.svg failed load resource: net::err_blocked_by_client because of following filter /inad. found in: easylist it's filter in easylist.

android - How/where in the code to detect wether in ListFragment's ListView all items are visible? -

i trying change actionbar's action depending on wether list items visible (there's less items fit screen => show "add item" action | there items invisible => show "search" action) what method of listfragment should override in order able use getlistview().getlastvisibleposition() , not -1? this code listfragment, in oncreateoptionsmenu lv.getlastvisibleposition() returns -1. @override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { super.oncreateoptionsmenu(menu, inflater); inflater.inflate(r.menu.list, menu); final menuitem search = menu.finditem(r.id.menu_item_search); final menuitem add = menu.finditem(r.id.menu_item_add_item); final listview lv = getlistview(); if (lv.getfirstvisibleposition() == 0 && lv.getlastvisibleposition() == madapter.getcount()-1) { // items visible: show add, hide search search.setshowasaction(menuitem.show_as_action_never); } else { ...

for loop - R: Vectorizing a condition -

i have dataset on million rows , 67 columns. create new column records scores according code below. i stuck @ condition need take care of in: df$change[df[,63] == "m"] <- df$change[df[,63] == "m"] - pos2 when df$change[df[,63] == "m"] - pos2 = 0 need see if happend on bidside or askside. way can determine seeing if position of df[,64] even(askside) or odd(bidside). there's caveat, can't use value pos2 , have calculated, because of function called mywhich (i can provide code if needed) used in code. determine even/odd have recalculate position of df[,64]. once know or odd, df$change should either -1 or 1 depending on whether df[,66] > df[,64] or <. now, i've tried subsetting don't see how can work because have recalculate positions. tried not using mywhich part cant seem head around make work. any pointers/suggestions? else should try? should write separate function handles this? write version of function? little l...

Change Cmake syntax colors in Clion -

i have installed clion , custom configured dark theme make staring @ screen long hours easier on eyes. able change every color c++ syntax configuration, color options cmake non-existent, , cmakes default colors dark olive requires me strain eyes read. cmake shows in code styles changing tabbing, spacing, etc, cannot find color options anywhere in settings menu. anyone in here clion user can point me in right direction? heres screenshot of cmake colors, prepare squint http://puu.sh/nxwtf/bd0625f791.png yes, functionality missing. please, vote issue !

ios - SpriteKit Memory Leak on static Menu scene -

Image
im experiencing memory leak on static menu scene, appears happens on every scene, game scene static menu/gameover. memory appears deallocated correctly (and it's reduced when scene gone). those static scenes not conatins update callback defined. it's setup in didmovetoview , inside there couple sklabelnodes , skspritenode allocated spritenodewithimage . i have tried use dealloc monitor if scene got's deallocated correctly, , appears seems it's not source of issue. browsing google pointed me other threads created on stackoverflow spritenodewithimage texturewithimage may cause -memory leaks -weird error "cuicatalog: invalid request: requesting subtype without specifying idiom" so have tried create uiimage imagenamed , put in texture , use in sktexture, has removed cuicatalog error (which anyway, seems stupid message did not been removed apple - can confirm ?) according memory leaks didn't @ all, , anyway in scene being created once on begi...

Which is faster? Native HTML Select options or SELECT options populated using JQuery -

i have html page few select input more 50 options each. wonder whether faster load html options populating them via jquery , or put <options> in html form. jquery method allow me easier maintain in future, need update json data. the client might add more options in future main concern efficiency. neither database nor internet available page, main consideration javascript or pure html. updated: jquery loaded on page sits in same box(locally) javascript , jquery can't elements until elements have been loaded dom. text contained within elements inserted dom nodes on load while javascript , jquery sit idly waiting. when jquery gets work on text nodes, it's relatively slow process. so, html faster loading them javascript/jquery.

ios - Disable apps for iPhone 4s in apple store -

i want apps available phones above 4s i-e iphone 5,6 , ipad. how can disable app store make available iphone 4s. asks me put iphone 4s , app not made screens. unfortunality, can't this. if you, check screen size in applicationdidfinishlaunching method if device iphone 4s, show alertview , explain user. might best way approach.

php - PHPDoc GraphViz error unable to fork and dot command not found -

i have found few related questions here seem solved installing missing graphiz. in case installed , in path. the error phpdoc is: execute transformation using writer "graph" php warning: exec(): unable fork [dot -v 2>&1] in /usr/share/php/phpdocumentor/src/phpdocumentor/plugin/graphs/writer/graph. php on line 254 php stack trace: php 1. {main}() /usr/bin/phpdoc:0 php 2. phpdocumentor\application->run() /usr/bin/phpdoc:24 php 3. symfony\component\console\application->run() /usr/share/php/phpdocumentor/src/phpdocumentor/application.php:183 php 4. symfony\component\console\application->dorun() /usr/share/php/phpdocumentor/vendor/symfony/console/symfony/component/console/application.php:126 php 5. symfony\component\console\application->doruncommand() /usr/share/php/phpdocumentor/vendor/symfony/console/symfony/component/console/application.php:195 php 6. symfony\component\console\command\command->run() /usr/share/php/phpd...

python - Group objects with an identical list attribute -

i have 2 classes: class a: def __init__(self, name, li): self.b_list = li class b: def __init__(self, i): self.i = class a contains list of objects of type class b . assuming have list of class a objects, how can group class a objects have identical b_list together? for example: a_list = [] li = [b(1), b(2), b(3)] a_list.append(a(li)) li = [b(2), b(3)] a_list.append(a(li)) li = [b(1), b(2), b(3)] a_list.append(a(li)) after processing should give 2 lists, 1 list first , third a , , list second a . or in nutshell: result = [ [ a([b(1),b(2),b(3)]), a([b(1),b(2),b(3)]) ], [ a([b(2),b(3)] ] ] for starters, i've removed name parameter class a, since rest of details omitted it. to group class objects together, you're going need define meant when 2 objects equal. i've created __cmp__ method let sort on objects comparing them. now, since objects composed of b objects, you're going need define meant 2 b objects be...

c# - EF getting mapped column name from string -

i have 3 entities share common base class. each of entities have own map class context , load fine. each entity has different primary key name rename in base class can use generic methods of the 3 entities while using same property name. everything maps fine when going database, example can db.vehicle.where(v => v.vehicleid < 100) , translates db column name different vehicleid . the problem wanting go opposite direction. example might have string "length" in 1 table might length1 , in length2 . want use same mapping used in model builder able translate "length" whatever corresponding value based on ( v => v.length ) property in base class. does have ideas on how might accomplished? if have tried fluent api , did not work, recommend declaring property virtual. modelbuilder.entity<concreteclass1>() .property(f => f.length) .hascolumnname("length1"); modelbuilder.entity<concreteclass2>() .prop...

apache spark - reading a file in hdfs from pyspark -

i'm trying read file in hdfs. here's showing of hadoop file structure. hduser@gvm:/usr/local/spark/bin$ hadoop fs -ls -r / drwxr-xr-x - hduser supergroup 0 2016-03-06 17:28 /inputfiles drwxr-xr-x - hduser supergroup 0 2016-03-06 17:31 /inputfiles/countofmontecristo -rw-r--r-- 1 hduser supergroup 2685300 2016-03-06 17:31 /inputfiles/countofmontecristo/booktext.txt here's pyspark code: from pyspark import sparkcontext, sparkconf conf = sparkconf().setappname("myfirstapp").setmaster("local") sc = sparkcontext(conf=conf) textfile = sc.textfile("hdfs://inputfiles/countofmontecristo/booktext.txt") textfile.first() the error is: py4jjavaerror: error occurred while calling o64.partitions. : java.lang.illegalargumentexception: java.net.unknownhostexception: inputfiles is because i'm setting sparkcontext incorrectly? i'm running in ubuntu 14.04 virtual machine through virtual box. i'm not sure i...

java - Why are private inner classes not visible for static imports? -

i defined private inner enum class , tried static import 1 of enum values this: public class outerclass { private enum innerenum { one, 2 } public static void main(string... args) { system.out.print(one); } } this not possible because static import statement shown below not visible: import static outerclass.innerenum.one; i had widen visibility private package private make work. know semantic of private point why same code, once written qualified enum value this: system.out.print(innerenum.one); is valid written this: import static outerclass.innerenum.one; ... system.out.print(one); is not. java import statement (static or not) introduces alias. private types not allowed introduce alias. seams weird me. does know language design decision behind restriction? which risk or danger occur allowing static import in case? i hardly interested in technical motivated reasons. the idea behind private class in class...

python - Is chronological order of logging messages guaranteed? -

i'm using logging module log messages application server. more specifically, use streamhandler log messages stdout/stderr, , use supervisord log messages files (since server process monitored supervisord ). my main question is, order of messages in log file always truthfully reflect order of execution of code? example, if message a: log msg a appears before message b: log msg b in log file, can 100% line of code logs message a executed before line of code logs message b , if timestamps of 2 messages in log file same? you can't be 100% sure, i'm pretty sure. although logging module locks output file before writing it, if you're running multiple threads or processes there's no guarantee code called logging.warning("a") or whatever acquires lock if several other threads trying same @ around same time. see docs logging , its source . see uses threading.rlock , the docs say: if more 1 thread blocked waiting until lock unlocked, ...

Inputs writing to the wrong position of an array in C -

i'm working on assignment multiplying 2 2d matrices of variable sizes. i keep having same issue, , stuck on how fix it: when calling input define matrix, last column of row doesn't input reason. instead first column of next row gets written both spots. for instance, if trying enter 2 x 2 1 2 3 4 it stored as 1 3 3 4 i've searched around , can't seem find similar issues. same thing size, inputs until last position of row. if last row last position stays good. i'll post code here, if give me pointers direction head fix appreciate it. (as pointers on cleaning rest, functional i'm sure aint pretty experienced eye.) the culprit somewhere in here believe for(j=0; j < rows_1; ++j){ for(i=0; < columns_1; ++i){ printf("\nenter value row %d column %d=",j+1,i+1); /*fgets(input, sizeof(input)-1, stdin); sscanf("%d", &matrix_1[j][i]);*/ scanf("%d"...

c - Overwriting of stack static array when the other static array overflows -

#include<stdio.h> int main(){ char a[10]; char b[10]; sprintf(a,"hello"); sprintf(b,"aaaaaaaaaabbbbbbbbbbcccccccccc"); printf("%s:%s\n",a,b); return(0); } (gdb) p &a $1 = (char (*)[10]) 0x7fffffffe450 (gdb) p &b $2 = (char (*)[10]) 0x7fffffffe440 (gdb) step 2: b = "aaaaaaaaaa" 1: = "bbbbcccccc" printf o/p- bbbbcccccccccc:aaaaaaaaaabbbbbbbbbbcccccccccc questions- a comes first in stack frame , b comes later. if b overwriting "bbbbbbbbbb" should go why starting "bbbbcccccccccc" ? also want know if overwrite bp, program terminate? sure b comes "after" a in stack, stack (often, , assumedly on platform based on print-outs) growns downwards . notice address of b less of a . so overwrite of b goes a . also think gdb being clever , printing 10 characters b , since prints 10 a 's , there's no termination. you can't overwrite processor register u...

Python lists outside of range -

how can move forward item in list past range? example, if set alarm @ 2pm , want go off in 59 hours, time be? i code this, fails past range of 25: time = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24) print(time[15+59]) this has nothing python, modular arithmetic: print(time[(14 - 1 + 59) % 24]) prints 1

How to make the linked list ordered in C++? -

#include <iostream> #include <string> using namespace std; struct node { int num; node*next; }; bool isempty(node *head); char menu(); void insertasfirstelement(node *&head, node *&last, int num); void insert(node *&head, node *&last, int num); void remove(node *&head, node *&last); void showlist(node*c); bool isempty(node*head) { if(head == null) return true; else return false; } char menu() { char choice; cout << "\n\nmenu:\n"; cout << "\n1. add item"; cout << "\n2. remove item"; cout << "\n3. show list"; cout << "\n4. exit" <<endl; cin >> choice; return choice; } void insertasfirstelement(node *&head, node*&last, int num) { node * temp = new node; temp ->num=num; temp ->next=null; head = temp; last = temp; } void insert(node *&head, node *&last,...

java - What is the purpose of a private constuctor with no parameters? -

i trying practice code analyzing , have noticed there constructor no parameters (which private) in below code snippet.what purpose behind whole code? public class wit { public static wit instance = null; private wit() { } public static wit getinstance() { if (instance ==null){ instance = new wit(); } return instance; } } this following singleton pattern , makes sure class can have 1 instance making default constructor private , handling instantiation internally. in example, however, singleton guarantee broken exposing non-final instance variable. can come along , set reference null, causing instance created on next call getinstance() .

java - maven-compiler-plugin Compilation Failure trying to build HDFS -

i'm trying build hdfs distribution. however, can't past mvn clean install got failed execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project hadoop-hdfs: compilation failure: compilation failure: and followed lot of compile error. such as [error] failed execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project hadoop-hdfs: compilation failure: compilation failure: [error] /users/janinkuwijitsuwan/desktop/hadoop-common/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocolpb/pbhelper.java:[2405,12] constructor fileencryptioninfo in class org.apache.hadoop.fs.fileencryptioninfo cannot applied given types; [error] required: org.apache.hadoop.crypto.ciphersuite,org.apache.hadoop.crypto.cryptoprotocolversion,byte[],byte[],java.lang.string,java.lang.string [error] found: org.apache.hadoop.crypto.ciphersuite,byte[],byte[],java.lang.string [error] reason: ac...

android - AlarmManager not waking phone up in Air Mode (onReceive delayed) -

problem onreceive method of broadcastreceiver "called" alarmmanager delayed until device awoken user. this has never happened me, information have report sent user. in log saw in first case onreceive method call delayed 2 hours , in second 1 20 minutes. in both situations alarm (and onreceive ) has started after phone awoken user. problem has occured twice in 2 consecutive days , user states has never happened before. distinctive change in phone's settings air mode enabled. my code: alarm set like: pendingintent pendingintent = pendingintent.getbroadcast(context, 0, alarmintent, pendingintent.flag_update_current); am.set(alarmmanager.rtc_wakeup, timeinmillis, pendingintent); logger.log("posting alarm " + id + " " + formattime(timeinmillis); broadcast receiver's onreceivemethod: @override public void onreceive(context context, intent intent) { logger.initialize(context, "alarmreceiver"); ... } logs received ...

r - Create a sequential number (counter) for rows within each group of a dataframe -

this question has answer here: numbering rows within groups in data frame 3 answers how can generate unique id numbers within each group of dataframe? here's data grouped "personid": personid date measurement 1 x 23 1 x 32 2 y 21 3 x 23 3 z 23 3 y 23 i wish add id column unique value each row within each subset defined "personid", starting 1 . desired output: personid date measurement id 1 x 23 1 1 x 32 2 2 y 21 1 3 x 23 1 3 z 23 2 3 y 23 3 i appreciate help. the misleadingly named ave() function, argument fun=seq_along , accomplish nicely -- if personid column not strictly ordered. df <- read.table(text = "personid date meas...

Using Blackberry MDS Simulator for connecting to specific SSID -

i'm trying create blackberry app connect specific ssid, blackberry mds simulator provides 'default wlan test network' - there way change ssid of wlan mds simulator creates? yes, can this. note: doesn't require mds (bes) simulator. mds simulator simulates mds. wifi different transport, , supported directly in device simulators (e.g. 8900, 9900, etc.). so, need device simulator running this. from device simulator menu, select simulate -> network properties . then, select add... button. select wlan network type, , give new wifi network ssid (name) want. make sure in network properties window, new wifi network has in coverage checked, , signal strength should turned (e.g. -40 dbm). might choose disable default wlan network unchecking in coverage box it, can sure new network 1 being used. then, use blackberry simulator normal device connect new network: select manage connections button, set wi-fi network . follow instructi...

node.js - Why is the body of request empty? -

i'm using pattern project sending json-data node. in other project works, in project not. req-object valide, body empty. why? client-side: json = { "auth_user_pkref": 2 } json.test_id = "anca" json.questions_count = 3 json.right_answers = 2 json.wrong_answers = 1 json.seconds_spent = 180 console.log('/api/answer/add', json); $.ajax({ url: "/api/answer/add", type: "post", data: json.stringify(json), contenttype: "application/json", success: function (data) { }, error: function (jqxhr, textstatus, errorthrown) { console.log("error, db error"); } }); server-side: router.post('/api/answer/add', function (req, res) { console.log('/api/answer/add: ', req.body) server-log: /api/answer/add: undefined ...

Send 404 header via PHP after .htaccess redirect -

i want create custom 404 page won't send 404 header, still send's 200 ok. .htaccess my .htaccess redirects every request index.php. rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^ /index.php [nc,l] index.php the index.php handles url included .php files. controller.php parses url , pastecontent.php includes requested .php content-file. //handle url require 'inc/controller.php'; //paste <head> require 'inc/site_header.php'; //paste <body> require 'inc/pastecontent.php'; //paste footer require 'inc/site_footer.php'; a closer controller.php: as can see tried send 404-header, before there output. //parse url function parse_path() { [...] return $path; } $path_info = parse_path(); $controller = $path_info['call_parts'][0]; //does page exist? function contentfound($c){ $found = true; switch ($c) { [...] default: ...

ios - What is the best way to save data for a table within a table? -

i have gone through tutorial on apple's developer website called 'your second ios application' in learned how make master detail application. went on learn how save data of master , detail view controllers sqlite3. want add table view controller , view controller structured same way master detail application within master detail structure have created. , within each cell user creates, show different data if navigate through different cell. basically, wondering best and/or simplest way save is. please ask questions if need it. if want save data can use core-data. first create model this. (create relations if necessary). create , add objects context , save context. here don't have worry how saved (default sqlite in ios). if need started core-data check out: raywanderlich - core data .

iphone - Can't save string into SQLite database (SQLITE_DONE doesn't return true) -

i'm trying store strings in sqlite database ios 6 iphone application. it's simple: joke displayed in textview when clicking button. when clicking second button, want save textview sqlite database (savejoke). however, sqlite_done never returned, indicating not working. so, looking @ alerts, "fail" when savejoke executed below. any idea why not working? have feeling might missing basic in creation of , inserting sqlite database. thankful help! my code: jokefirstviewcontroller.m: #import "jokefirstviewcontroller.h" @interface jokefirstviewcontroller () @end @implementation jokefirstviewcontroller @synthesize joke = _joke; - (void)viewdidload { [super viewdidload]; nsstring *docsdir; nsarray *dirpaths; dirpaths = nssearchpathfordirectoriesindomains( nsdocumentdirectory, nsuserdomainmask, yes); docsdir = dirpaths[0]; // build path database file _databasepath = [[ns...

python 2.7 - How to rename a file name without changing the extension -

Image
this example code rename file name reference "csv" file.this csv file has old name of file in row[0],and new names in row 1 image import csv import os open('new_names_ddp.csv') csvfile: reader = csv.reader(csvfile) row in reader: oldname = row[0] newname = row[1] os.rename(oldname, newname) but here have files different extenstions like(.wav,.txt,.xml,.html).so want rename file name new name , add extension automatically.can please me this. i don't know trying do, because problem , code sample talking else. i assume want is: read files in directory hard disk. if filename (without extension) in column a, rename whatever in column b. to that: import os import csv import glob file_path = '/home/foo/bar/some/where/' file_pattrn = '*.*' file_names = {} open('somefile.csv') f: reader = csv.reader(f) row in reader: file_names[row[0]] = row[...

OWIN compression middleware for selfhost scenario -

we have owin application (built nancy , webapi). when hosting in console application (with katana selfhost), don't have compression enabled on static content. i've tried working example of owin gzip middleware. so far found few like: owin.compression nuget, squeezeme nuget, https://gist.github.com/pinpointtownes/538cde1ed5e5d768355d , https://gist.github.com/pinpointtownes/ac7059733afcf91ec319 nothing seems work - in end browser gets responses without content-encoding header , not compressed. tried adding compression in end of nancy's pipeline - doesn't work either. while hosting in iis - iis takes care of compression. am missing something? there overwrites response body stream , removes headers? or, maybe, host should take care of compression? from additional reading, related katana host. issue happens in nowin host. thanks. bottom line: issue not related mentioned above. appears eset av monitors http traffic in company. in case of c...

java - actionlistener(this) not working -

import java.io.*; import java.awt.event.*; import java.awt.*; import javax.swing.*; class casestudy extends jframe implements actionlistener {//making facebook program jbutton login,register; jlabel lbl1, lbl2; jtextfield txtemail; jpasswordfield txtpassword; public casestudy() { //setting labels button etc super ("casestudy2.0"); setlayout(new flowlayout()); lbl1 = new jlabel (" username "); lbl2 = new jlabel (" password "); txtemail = new jtextfield(10); login = new jbutton("login"); register= new jbutton("register"); //this login.addactionlistener(this);//adding listener register.addactionlistener(this); register.setbounds(2,250,100,20); } public void actionperformed(actionevent e){ //my code supposedly im working im checkin frame , apppars not work frame no buttons } public static void ...

amazon web services - Mechanism to retrieve all items from DynamoDB that begin with a string -

is there mechanism retrieve items dynamo db table hash key of gsi begins specific string? thanks in advance! use begins_with condition in query: http://docs.aws.amazon.com/amazondynamodb/latest/apireference/api_condition.html

php - Trying to convert from mysqli to pdo -

try { $pdo = new pdo("mysql:host=$dbhost;dbname=$dbname", $dbusername, $dbpassword); } catch (pdoexception $e){ exit('datebase error.'); } // db login info defined, didnt post here $username = $_get["user"]; $password = $_get["passwd"]; //$data = mysqli_query($mysqli, "select * users username='".$username."'"); //$hash = mysqli_fetch_object($data); $query = "select username, password, loginreqkey, banned users username='$username'"; //if (password_verify('rasmuslerdorf', $hash)) { if ($stmt = $pdo->prepare($query)) { $stmt->execute(array($username, $password, $loginreqkey, $banned)); //$stmt->bind_result($username, $password, $loginreqkey, $gbanned); // $result = $stmt->fetch(pdo::fetch_lazy); //$dt = $stmt->fetchall() ; //$query->execute(array($username, $password)); if (password_verify($password, $result['password'])) { while($r = $stmt->fetchall(pdo::fe...

php - How to fill all other files to "false" when adding data into a table in wordpress -

for example, let's there table consists of 7 fields. fill specific values 2 of them , set "false" remaining 5 fields. for example, global $wpdb; $table_name = $wpdb->prefix . "imlisteningto"; $wpdb->insert( $table_name, array( 'name' => $_post['name'], 'title' => $_post['title'] ) ); is there simple way set "false" remaining fields without specifying each field respectively? thanks. you can set default value rest fields false, means if not specify them in query filled automatically default one

Setting working directory in R (Jumping directories) -

r doesn't allow me set newly created folder working directory if jump folders. don't set working directories way, curious why exhibiting behaviour. first set working directory: original_directory <-setwd('c:/users/rooirokbokkie/documents') now want create 2 folders in current working directory folder_2 being sub-folder of folder_1: dir.create(file.path('folder_1', 'folder_2'), recursive = true) when try set folder_2 working directory: setwd('folder_2') i following error: error in setwd("folder_2") : cannot change working directory but if set folder_1 working directory first, works: setwd('folder_1') setwd('folder_2') getwd() [1] c:/users/rooirokbokkie/documents/folder_1/folder_2" ` but when try 1 folder gives error again: setwd('folder_1') error in setwd("folder_1") : cannot change working directory but can set original working directory again fine: setw...

Several Amazon ECS tasks on the same instance host -

Image
say have autoscaling group initial number of 2 instances. assume instances of autoscaling group of same type (hence same amount of memory , cpu). maximum number of instances isn't relevant in case. have elb load-balancing load among instances of group. besides this, instances of autoscaling group members of fresh ecs cluster i've created earlier. there 1 task definition in case 1 container use 512mb of ram. container requires port mapping host's 80 container's 5000. say i've spun autoscaling group , 2 initial instances ready used. i'm trying spawn service of 4 tasks based on aforementioned task definition. imagine tasks fit 2 instances if placed 2 (if hosts had 1gb of ram each). would setup legitimate? if happen port mappings because there 2 identical containers on 1 host? you forward 5000 different instance ports (since can't bind 80 multiple times). you use elb map across ports. this post answers specifics . you'd want standardize ...

javascript - Ajax Not Working With C# Controller Action With 2D Array Parameter -

my ajax not hitting controller action. reason? my controller action public actionresult save_data(string [][] rosterarray, int pricelist_id, int group_id) my ajax $.ajax({ url: '@url.action("save_data", "pricelistmaster")', type: 'post', async: false, contenttype: 'application/json', datatype: "json", data: { "rosterarray": rosterarray, "pricelist_id": "2", "group_id": $("#group_id").val() }, //data: json.stringify({ "item_code": item_code, "ipd_price": ipd_price, "opd_price": opd_price, "ems_price": ems_price }), success: function (data) { debugger if (data.success) { alert('data saved successfully.'); location.reload(); } else { alert(data.error_msg); } } } if using type: 'post' in ajax, means...

security - converting http to https using self signed certificate -

i want convert http request https using self signed certificate. how create keystore files , add certificate in keystore,how use keystore file converting http https. please sort out problem not sure if helps adding code htaccess redirect http https: <virtualhost *:80> servername www.example.com redirect "/" "https://www.example.com/" </virtualhost > <virtualhost *:443> servername www.example.com # ... ssl configuration goes here </virtualhost >

Quantlib FixedRateBond Cashflow Memory Leak -

when extract , iterate on cashflows in fixed rate bond, valgrind reports memory leak. using following code: fixedratebond fixedratebond( settlementdays, faceamount, fixedbondschedule, std::vector<rate>(1, couponrate), actualactual(actualactual::bond), businessdayconvention ::unadjusted, redemption, issuedate ); vector<boost::shared_ptr<cashflow>> cashflows = fixedratebond.cashflows(); (size_t i=0; != cashflows.size(); ++i) { cout << "date: " << cashflows[i]->date() << " amount: " << cashflows[i]->amount() <<endl; } edit: looks it's osx issue same code doesn't raise issues when run in linux. posterity, here report getting on osx: ==62096== 148 (80 direct, 68 indirect) bytes in 1 blocks lost in loss record 170 of 208 ==62096== @ 0x1001f8ea1: malloc (vg_replace_malloc.c:303) ==62096== 0x102d3d4a2: __balloc_d2a (in /usr/lib/...

magento - Get product information of items added in cart -

i need product's information in shopping cart. mean if add product in cart need product id , category id of item. i want information of product attributes (e.g product's id, price, parent id) whenever product added cart @ shopping cart. how can that? $catid = mage::getmodel('catalog/category')->load($this->getproduct()-> getcategoryids($_item->getproductid()))->getname(); i have written code @ /checkout/cart/item/default.phtml , can follow step work out surely. this answer , follow instruction accordingly mr. benmarks. have started posting stackoverflow. working on solution product in 1 or more categories. sorry if have misinterpreted anything.

swift retain cycle in function -

i'd ask if retain cycle happens in situation: func somefunc() { var avar = someobj() funcwithclosure(something, completionhandler: { _ -> void in avar = someobj() // new }) } in case, refer avar closure. wonder if creates retain cycle. if true, should fix by: func somefunc() { var avar = someobj() funcwithclosure(something, completionhandler: { [weak avar] _ -> void in avar = someobj() // new }) } just expand on question, would retain cycle if avar references closure. example: func somefunc() { var avar = someobj() avar.funcwithclosure(something, completionhandler: { dosomethingwith(avar) } } avar references closure because calls function, , closure references avar because uses variable in body. break cycle, create weak reference avar outside closure, this: func somefunc() { var avar = someobj() weak var weakvar = avar avar.funcwithclosure(something, completionhandler: { ...

django - DurationField format -

i have durationfield defined in model day0 = models.durationfield('duration monday', default=datetime.timedelta) when try view this, want formatted "hh:mm" -- less 24. so, tried these in html template file: {{ slice.day0|time:'h:m' }} {{ slice.day0|date:'h:m' }} however, empty space. what doing wrong? a timedelta instance not time or datetime . therefore not make sense use time or date filters. django not come template filters display timedeltas, can either write own, or external app provides them. might find template filters in django-timedelta-field useful.

java - Handle starvation in apache commons-pool -

i using 1.6 version of apache commons-pool library. per javadoc, whenexhaustedaction specifies behavior of borrowobject() method when pool exhausted: can either when_exhausted_fail, when_exhausted_grow, or when_exhausted_block. i want use borrowobject , if don't object within specified timeframe, need sort of handle handle scenario(like rescheduling tasks, if don't target object) but option, here nosuchelementexception runtimeexception, need catch , handle error scenario. quite sceptical catching runtimeexception is intended way of handling object starvation genericobjectpool or have other options ? i've looked @ borrowobject documentation , states throws these exceptions illegalstateexception - after close has been called on pool. exception - when makeobject throws exception. nosuchelementexception - when pool exhausted , cannot or not return instance. because nosuchelementexception documented behavior of method, there nothing wrong catchin...

java - extract hashtag and mention from instagram -

is there java library or regex pattern extracting hashtag , user mention instagram media caption? know twitter-text api can not handle no space hashtag. this 1 should work (^|\s)(#[a-z\d-]+) (got here ) anyway, if using instagram api, there part of result when call gives hashtags: ["data"]=> array(14) { ["attribution"]=> null ["tags"]=> array(3) { [0]=> string(13) "workingermany" [1]=> string(18) "trabajarenalemania" [2]=> string(10) "radeberger" } if, requested in comment, need korean chars, add them regular expression this: (^|\s)(#[a-z\p{hangul}\d-]+) more alphabets want, more set of chars should add, \p{hiragana} , \p{katakana} , or \p{latin}

angular 2: when resolving promise in component via service 'this' is 'window' -

i'm following quickstart tutorial angular 2 ( https://angular.io/docs/ts/latest/tutorial/toh-pt4.html#!#review-the-app-structure ) , got stuck in services chapter. component: @component({ selector: 'main', templateurl: 'main/main.template.html', styleurls: ['main/main.component.css'], providers: [heroservice], directives: [herocomponent] }) export class maincomponent implements oninit { title: string = 'tour of heroes'; heroes: hero[]; selectedhero: hero; constructor(private _heroservice: heroservice) { } getheroes() { this._heroservice.getheroes().then(heroes => this.heroes = heroes ); } ngoninit() { this.getheroes(); } onselect(hero: hero) { this.selectedhero = hero; } } as can see implements oninit , executes component's getheroes method, in turns calls injected heroservice : import { injectable } 'angular2/core'; import { heroes } '../hero/hero.mock'; @injec...

python - Prune some elements from large xml file -

i have xml file of more 1gb , want reduce size of file removing unwanted children of parent tag creating new xml file or rewriting existing one. how can done through python file large,simple parse tree = elementtree.parse(xmlfile) won't work. xml file in file every parent tag tasksreportnode want have child tablerow rowcount attribute value 0 , reject other children(table row) of parent. sample xml code: <tasksreportnode name="task15"> <tabledata numrows="97" numcolumns="15"> <tablerow rowcount="0"> <tablecolumn name="task"><![cdata[ task15 [get - /pulsev31/appview/projectfeedhidden.jsp - 200]]]></tablecolumn> <tablecolumn name="status"><![cdata[success]]></tablecolumn> <tablecolumn name="successful"><![cdata[96]]></tablecolumn> <tablecolumn name="failed...