Posts

Showing posts from June, 2010

osx - Build Bash variable name -

this question has answer here: dynamic parameter expansion [duplicate] 1 answer i want create function colored output (just learn bash little better) here works esc_seq="\x1b[" # foreground red fg_red="${esc_seq}31;" # background yellow bg_yellow="43;" # style bold fs_bold="1m" # echo echo -e "${fg_red}${bg_yellow}${fs_bold}hello world!" no try build function function ext_echo() { // lets $1 red, $2 yellow, $3 bold // need ... echo -e "${fg_$1}${bg_$2}${fs_$3}hello world!" } how can build echo execution parameters? the following script should enough starting point: #!/bin/bash ext_echo() { declare -a colors colors=( [red]="<red>" [blue]="<blue>" ) c in "$@"; echo ${colors[$c]} done } ext_echo red blue out...

HTML Email: Images are not showing in MS Outlook and Gmail -

i creating html emailer. when check in yahoo mail, images there in emailer. not there in gmail , ms outlook, , displaying in outlook mail, too. so images displaying in yahoo, outlook mail. not displaying in gmail , local outlook software. i have checked radio button of gmail setting always allow external images i want know table structure affects different email engine? <!--email_cover_page--> <!-- speakers --> <table class="speakers" style=" border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;background: #fa4b00;" align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody> <tr> <td style=" border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;font-size:0px; line-height:0px; mso-line-height-rule: exactly;" ali...

php - $_POST not work in codeingiter -

my login form : http://www.khabgahfeiz.ir/admin/login in controller : public function handling() { var_dump($_post['email']); return; .... but return null value , got error : severity: notice message: undefined index: email filename: backend/login.php line number: 29 use $this->input->post() . e.g.: $this->input->post('table field'=>'form element name');

class - in php why does isn't work -

class grandclass { public $data; public function __construct() { $this->somemethodintheparentclass(); } public function somemethodintheparentclass() { $this->$data = 123456; } } class myparent extends grandclass{ public function __construct() { parent::__construct(); } } class child extends myparent { // public $data; public function __construct() { parent::__construct(); } public function getdata() { return $this->data; } } $a = new child(); var_dump($a->getdata()); php notice: undefined variable: data in d:\test.php on line 7 php fatal error: cannot access empty property in d:\test.php on line 7 update function somemethodintheparentclass below using $this->data = 123456; public function somemethodintheparentclass() { $this->data = 123456; }

fastICA in R (Extracting the Components) -

i'm new r. run analysis in sas. however, need use fastica in r. i've conducted independent component analysis in r , looking extract actual components. the code i've used follows: ica<-fastica(final_all_truncated_s, n.comp = 100) ica list 5 elements "x" "k" "w" "a" "s" i extract values these elements, save excel file, , import sas. question is, how extract values these elements can export excel file? rather saving results excel format, recommend saving each component of result separate csv file. this way don't need additional packages, , have software-independent file format can read sas, excel, etc. you can achieve using simple for-loop in r, e.g.: for (x in names(ica)) { write.csv(ica[[x]], file=sprintf('%s.csv', x), row.names=false, quote=false) } here, names(ica) returns vector of list indices ("x", "k", "w", "a", , "s")...

php - Getting blank array from web service -

i having strange problem in consuming web services created on server. this url of web services created http://52.53.227.143/api_test.php?post_name=bsn%20syntha-6%20isolate i can't able receive data in array or other format on site. used both file_get_content , curl receive json format, giving me blank array. here code: $post_name = 'bsn syntha-6 isolate'; $base = "http://52.53.227.143/api_test.php?post_name=".$post_name; $str = file_get_contents($base); echo '<pre>'; print_r(json_decode($str)); its giving me following result: stdclass object ( [info] => array ( ) ) i use curl, here's code: $curl = curl_init(); curl_setopt($curl, curlopt_ssl_verifypeer, false); curl_setopt($curl, curlopt_header, false); curl_setopt($curl, curlopt_followlocation, true); curl_setopt($curl, curlopt_url, $base); curl_setopt($curl, curlopt_useragent, 'mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.2.3) gecko/20100401 firefo...

php - WordPress hook / filter to process link inside a post -

Image
is there hook / filter process link being added wordpress post ? my aim pre-process link inserted in post using following button , shorten using third party api bit.ly i want both internal / external links. one solution think of add button editor prefer hook / filter job, way more clean , convert custom plugin website (there allowing wordpress up-gradable). i went through wordpress docs , skimmed through following hooks / filters of no use me https://developer.wordpress.org/reference/hooks/add_link/ https://developer.wordpress.org/reference/hooks/post_link/ and of ones listed here https://developer.wordpress.org/?s=link update 1 : far know, external urls inserted post content tinymce editor link plugin, php nothing. in wordpress, there're 2 plugins located @ wp-includes/js/wplink.js , wp-includes/js/tinymce/plugins/wplink/plugin.js . note if you're not in script_debug mode, have .min suffix. wp-includes/js/wplink.js handles dialog: ...

Can't Access Webmin on GCE Instance on port 10000 -

i have gce instance debian 1v cpu & 1.7gb. followed below tutorial , installed webmin on it. https://www.howtoforge.com/tutorial/how-to-install-webmin-on-ubuntu-15-04/ the installation went successfully. created firewall exception on using ufw , allowed port 10000. sudo ufw allow 10000/tcp but not able access webmin through browser. https://my-gce-instance-ip-address:10000 . then created firewall exception using google cloud console. again tried url didnt work. then thought might because of webmin https mode. open /etc/webmin/miniserv.conf , changed ssl=0. after restarted webmin. /etc/init.d/webmin restart then tried the url http, still can't access. i tried below command , checked output. accordingly webmin correctly running , listening on port 10000. netstat -tulpn | grep :10000. i can't seem think doing wrong. have spent several days on without , solution in sight. hope can kindly me? try ... it's working me iptables -i input 1 -p...

opengl - Lighting 2D Objects from behind -

Image
i working on 2.5d lighting problem. wanted create effect moon lighting 2d things behind. have ever seen solution problem this? i'm trying use normal maps on sprite in unity, looks fine-ish when moon poking out behind -- when it's behind (as in third picture), effect doesn't work -- because light 2d element in 3d, have light front, far know perhaps there's solution doesn't involve real light, shaders reveal angle-based mask. have bright (haw!) ideas? i'm not familiar using 2d objects i'm guess going have simulate effect using transparency , looking function calculate brightness origin (the center of moon) or (not sure if possible) maybe create 3d overlay (or backlay if will) uses material give desired look.....set transparency on 2d object allow light effects of 3d rectangle shine though.. there beter solutions, i'm throwing ideas around

opencv - How to find a line from polar coordinates (Hough Transform Confusion) -

i started cv course , going through old homeworks (the current ones aren't released). i've implemented hough lines function, loop through each point, if it's edge, loop through 0-180 (or -90 90) theta values, , calculate rho, , store in array. when tried convert polar coordinates, can find x,y pair (using rho * sin(theta), , rho * cos(theta)), don't understand how convert line in cartesian space. have line need either 2 points or point , direction (assuming ray of course) i understand point is. i've done searching can't seem quite find answer, folks tend say, polar tells x, bam have line in cartesian, seem missing connection "bam" was. what mean described here; explain hough transformation also vector/line polar coordinates it's asked how draw line polar coords, response here's x , y. me never mentions rest of solution. is line somehow related y = mx+b m theta , b rho? if not how convert line in cartesian space. edit: afte...

How to show all invalid objects in PostgresQL -

looking view can list 'invalid' objects in postgresql. in oracle, can use dab_objects.status column i'm not sure if there simple way such thing in postgresql. maybe, can check invalid indexes below code. how can other objects? select pg_class.relname pg_class, pg_index pg_index.indisvalid = false , pg_index.indexrelid = pg_class.oid; i don't think have check else, since other objects cannot become invalid in postgresql. oracle , postgresql work quite differently in respect. in oracle, can alter object (for example table) if there dependent objects (for example views). dependent objects become invalid , have recompiled . in postgresql, cannot alter object has dependend objects in way renders these dependent objects invalid. have drop , recreate dependent objects. invalid indexes can left behind failed create index command.

angularfire - no provider for angular fire in angular 2 -

i keep gettings following error when trying implement login: browser_adapter.ts:82exception: error in http://localhost:4200/app/app.component.js class appcomponent_host - inline template:0:0browserdomadapter.logerror @ browser_adapter.ts:82browserdomadapter.loggroup @ browser_adapter.ts:93exceptionhandler.call @ exception_handler.ts:58(anonymous function) @ application_ref.ts:289zonedelegate.invoke @ zone.js:323oninvoke @ ng_zone_impl.ts:72zonedelegate.invoke @ zone.js:322zone.run @ zone.js:216(anonymous function) @ zone.js:571zonedelegate.invoketask @ zone.js:356oninvoketask @ ng_zone_impl.ts:61zonedelegate.invoketask @ zone.js:355zone.runtask @ zone.js:256drainmicrotaskqueue @ zone.js:474zonetask.invoke @ zone.js:426 browser_adapter.ts:82original exception: no provider angularfire!browserdomadapter.logerror @ browser_adapter.ts:82exceptionhandler.call @ exception_handler.ts:70(anonymous function) @ application_ref.ts:289zonedelegate.invoke @ zone.js:323oninvoke @ ng_zone_impl.t...

amazon web services - Alexa SSML not playing -

i trying ask , tried dummy example ssml. using amazon lambda , python. if test code lambda console expected output: { "version": "1.0", "response": { "outputspeech": { "text": "<speak><audio src='https://s3.amazonaws.com/aws-website-resources-1183x/dice-die-roll.mp3' />three</speak>", "type": "ssml" }, "shouldendsession": true, "card": { "content": "three.", "type": "simple", "title": "dice" } } } when go alexa service simulator , try request, text in output speech gone, "listen" button in console disabled , if try on echo, doesn't play anything: { "version": "1.0", "response": { "outputspeech": { "type": "ssml" }, "card": { ...

javascript - How do I convert JSON string date to a custom format date? -

hi know how convert json string date comes response format "8/24/2016". made datefilter.js bit didn't work out expected here's tried. here's datefilter.js (actually didn't work. error: data recursion) (function () { angular .module('myapp') .filter('date', function ($filter) { return function (input) { if (input == null) { return ""; } var _date = $filter('date')(new date(input), 'dd/mm/yyyy'); return _date.touppercase(); }; }); })(); here's how json service ( the code not complete since want show how did response. ) function getempdetails(successcallback, failcallback) { var req = { method: 'get', url: 'http://localhost:2222/api/getemployees/getemployeedetails', headers: { ...

php - Filter string from inside an array -

i tried this:- function sum_array($arr_sum){ $string= ""; $length= count($arr_sum); $sum= null; if(is_string($arr_sum)){ echo "you cannot use string"; }else{ for($i=0; $i<$length; $i++){ $sum = $sum + $arr_sum[$i]; } echo " sum ". $sum; } } $array_summation=["string",12.6,25.2,10,12]; sum_array($array_summation); i want know should if want integer or float value inside array, , if string come inside array gives error no string wanted or try this function sum_array($arr_sum){ $sum = 0; foreach($arr_sum $value){ if(!is_numeric($value)){ echo 'array contain non numeric data'; exit; } $sum += $value; } echo 'the sum '.$sum; } $array_summation=[...

java - Set current instance to a different instance of the same object -

this question has answer here: what difference between variable, object, , reference? [duplicate] 5 answers is there way within instance method of class change current instance pointing to? this tried far: public class test { string name; test other; public test(string name) { this.name = name; } public void setother(test test) { this.other = test; } public void printname(){ system.out.println(this.name); } public void testmeout(){ changeinstance(this, other); printname(); } public static void changeinstance(test instance1, test instance2) { instance1 = instance2; } } and class testing test class: public class testingtest { public static void main(string[] args) { test test1 = new test("test1"); test1.setother(new test("test...

javascript - child-parent components react (sharing) -

i have link in particular component... class bottom extends react.component { constructor(){ super(); this.state = {link:"don't have account?"} } render(){ return ( <div> <div classname="sub-login"> <p>{this.state.link}<a onclick={this.props.onclick.bind(null, this)}> register here</a></p> </div> </div> ); } } export default bottom; i added onclick event handler on link above. now, want parent component uses component above, bottom , catch onclick event. so in following component, want following... import bottom './register-link.js'; class index extends react.component { constructor() { super(); this.state = {header:"welcome tutorhub"} } if clicked: console.log("link clicked"); render(){ return ( <div> ...

SonarQube java.lang.OutOfMemoryError: GC overhead limit exceeded -

i getting outofmemoryexception while performing sonar analysis on project. jenkins job shows analysis report generated during background task in sonarqube failing below exception., 2016.08.24 10:55:52 info [o.s.s.c.s.computationstepexecutor] compute comment measures | time=14ms 2016.08.24 10:56:01 info [o.s.s.c.s.computationstepexecutor] copy custom measures | time=9075ms 2016.08.24 10:56:02 info [o.s.s.c.s.computationstepexecutor] compute duplication measures | time=150ms 2016.08.24 10:56:34 error [o.s.s.c.c.computeenginecontainerimpl] cleanup of container failed java.lang.outofmemoryerror: gc overhead limit exceeded 2016.08.24 10:56:34 error [o.s.s.c.t.ceworkercallableimpl] failed execute task ava6ex7gdswg1hqk_vvc java.lang.outofmemoryerror: java heap space 2016.08.24 10:56:34 error [o.s.s.c.t.ceworkercallableimpl] executed task | project=iserve | id=ava6ex7gdswg1hqk_vvc | time=53577ms hi solved problem in 2 ways 2 different scenarios found issue case : when us...

mongodb - Mongo Aggregation $filter on ISO date value -

i have following document { "_id": "57b4c5f0291ebb13110b888e", "first": "john", "last": "smith", "email": "john.smith@gmail.com", "fulfillments": [ { "_id": "57b683e531a5a21679b78e6d", "created_by_name": "john smith", "created_by_id": "57b4c5f0291ebb23110b888e", "fulfilled_by_name": "john smith", "fulfilled_by_id": "57b4c5f0291ebb13110b888e", "date": new date("2016-08-23t13:58:15-0700") } ] } for have mongo query want return list of fulfillments have not occured. means date property on fulfillment embedded document greater current time. db.users.aggregate([ { $match : { "_id" : "57b4c5f0291ebb13110b888e" } }, { $project : { "fulfillments" : { $filte...

ios - Reset UITableViewCell position -

-(nsarray *)tableview:(uitableview *)tableview editactionsforrowatindexpath:(nsindexpath *)indexpath { course *c = self.courses[indexpath.row]; uitableviewrowaction *button = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledefault title:@" - " handler:^(uitableviewrowaction *action, nsindexpath *indexpath) { [c remove]; [tableview beginupdates]; [tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationnone]; [tableview endupdates]; }]; button.backgroundcolor = [uicolor red]; return @[button]; } - (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { // need implement method or nothin...

authentication - Adobe Business Catalyst and Intranet Active Directory SSO integration -

i'm researching different approaches build web app integrates active directory login business catalyst. i'm wanting implement single sign on active directory in intranet environment. specifically, users should able use active directory credentials login business catalyst. workflow: user provides username, password, , domain form. form sends request authentication (i'm thinking via soap, http) gets response based on status of ad user account (if disabled notify them otherwise continue) create user in business catalyst if 1 not created , login user. (optionally: use pre-existing account has matching username or other matching criteria) optional: detect if user logged in ad account , auto-login credentials. option 1: communication ad server via liquid: reviewed docs , saw social media , security zone docs neither had login api call. know liquid has access server side data i'm not sure if there server side call handling authentication. option 2: ...

Elixir Try Catch -

i trying figure out scoping issue. have procedural function setting bunch of related resources on aws. need able catch failure , rollback relations have been setup. have try catch setup, variables in try block not available in catch, need them can take correct steps rollback. try c = connection cert = aws.cert module = aws.create_mod(cert) etc... rescue :error -> rollback(c, cert, module) end any advice how handle this? this happens because elixir cannot guarantee variables set time exception raised. may not case you, imagine this. try foo = do_something_safe() bar = do_something_that_will_raise_an_error() baz = do_something_else_safe() ... rescue runtimeerror -> quux(foo, baz) end in previous example, call do_something_that_will_raise_an_error() raise error. both bar , baz not set because of it. in specific case, may able like baz = do_something_else_safe() foo = do_something_safe() try bar = do_something_that_will_rais...

javascript - React - Why is input field still readonly (i.e. not editable) even though I've added onChange? -

i know question has been asked before, i've tried of solutions find, , after wasting days on this, i'm literally cry. doing wrong? the input field remains readonly , onchange won't fire despite varied , increasingly desperate attempts coax behaving basic of text input fields. here's code: import react, { component, proptypes } 'react'; export default class contact extends component { constructor(props) { super(props); this.state = { name: '' }; } handlechange(e) { this.setstate ({ name: e.target.value }); } render() { return ( <div> <form> <input type = "text" value = { this.state.name } onchange = { this.handlechange.bind(this) } /> </form> </div> ); } } edit: realized work expected...

java - How to map one-to-many relationships in myBatis? -

so have following table must map java objects: +---------+-----------+---------------------+---------------------+--------+ | task_id | attribute | lastmodified | activity | row_id | +---------+-----------+---------------------+---------------------+--------+ | 1 | 1 | 2016-08-23 21:05:09 | first activity | 1 | | 1 | 3 | 2016-08-23 21:08:28 | connect db | 2 | | 1 | 3 | 2016-08-23 21:08:56 | create web services | 3 | | 1 | 4 | 2016-08-23 21:08:56 | data dump | 4 | | 1 | 5 | 2016-08-23 21:08:56 | test cases | 5 | | 1 | 6 | 2016-08-23 21:08:57 | dao object | 6 | | 1 | 7 | 2016-08-23 21:08:57 | buy streetfood | 7 | | 2 | 6 | 2016-08-23 21:08:57 | drink coke | 8 | | 2 | 6 | 2016-08-23 21:09:00 | drink tea | 9 | | 2 | 1 | 20...

java - How can I test an abstract class using Espresso? -

suppose make abstract baseactivity toolbar , this: /** * base activity handles common functionality in app. * includes toolbar */ public abstract class baseactivity extends appcompatactivity { // primary toolbar private toolbar mtoolbar; @override public void setcontentview(int layoutresid) { super.setcontentview(layoutresid); settoolbar(); } private void settoolbar() { if (mtoolbar == null) { mtoolbar = (toolbar) findviewbyid(r.id.toolbar); if (mtoolbar != null) { mtoolbar.setnavigationcontentdescription(getresources().getstring( r.string.navigation_drawer_description_ally)); setsupportactionbar(mtoolbar); } } } } and mainactivity extends baseactivity , this: public class mainactivity extends baseactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstanc...

How can I change the channel_variable like destination_number at run time (dynamically) in Freeswitch? -

i looking solution dynamically changing channel_variable, destination_number without needing reloadxml (as might affect ongoing or incoming call). basically, fs has wait till provide appropriate destination_number. till now, have been doing xml way (editing xml files) , reloadxml command @ fs prompt. not viable requirement you can use lua(or other freeswitch supported scripting language) script this. using lua can write custom script sophisticated logic. more details: https://freeswitch.org/confluence/display/freeswitch/lua+api+reference

node.js - How can I switch between a live and a production database without duplicating code? -

here situation. have extensive rest based api connects mongodb database using mongoose. api written standard "mean" stack application. currently, when developer queries api they're connecting live production database. want have exact duplicate database "staging" database, new data added first, vetted on period of time, , move live database. want developers able query either 1 modifying query. i started looking mongoose documentation, , appears though models tied db connection, , if want have multiple connections have have multiple models, 1 each connection. nightmare of wet code , not path want take. what want not touch of code @ , have switch changes proper database given query. question is, how can achieve this? possible? documentation seems imply not. rather trying maintain connections 2 environments in same code base have considered setting stage version of application? database connects set through environment variable or other conf...

How can we discover a service in Eureka using a qualifying property with Spring Cloud and Spring Boot -

we have 50 microservices developed using spring boot. use spring cloud registering services eureka , invoke service consumer using feign. contract pretty standard, consumer uses interface @feignclient("<foo>") annotation locate service that's registered foo eureka. registration, lookup , invocation on target service works expected 1 or multiple instances of service running. we have new requirement same service foo may running multiple instances each instance has specific stereotype or designation . example, instances of foo expected deal 3rd party integration synchronous workload, , instances of foo expected deal internal messages (asynchronous workload). have defined configuration property called stereotype in service defined @ bootstrap (done via part of spring cloud config) tell service instance deal sync or async workloads. configuration looks this: service.stereotype: sync # or async in addition, add property eureka's eureka.instance.meta...

python - 'module' object has no attribute 'TK' -

i'm beginner of learning gui. my python version 2.7 , i'm using windows. i've searched tkinter in folder there 1 python file in c:\python27 . here code: import tkinter tk class electronic_signature_user_program(tk.tk): def __init__(self,*args,**kwargs): tk.tk.__init__(self, *args, **kwargs) container = tk.frame(self) container.pack(side = "top",fill = "both",expand = true) container.grid_rowconfigure(0,weight=1) container.grid_columnconfigure(0,weight=1) self.frames = {} f in (loginpage, login_confirm): frame = loginpage(container,self) self.frames[loginpage] = frame frame.grid(row=0,column=0,sticky="nsew") self.show_frame(loginpage) def show_frame(self,cont): frame = self.frames[cont] frame.tkraise() class loginpage(tk.frame): def __init__(self, parent, controller): tk.frame.__init__(self, ...

ruby on rails - Simple_form_for, comment don't appear as expected -

Image
i have problem comments. if comment status whatever is, comment displayed on last status. hope help, can edit more code if needed, let me know need. _form.html.erb <%= simple_form_for([status, status.comments.new]) |f|%> <%= f.input :content %> <%= f.button :submit, "comment", class:"btn btn-primary"%> <% end %> index.html.erb <% @statuses.each |status| %> <%= image_tag status.user.avatar.thumb if status.user.avatar?%> <%= status.user.full_name%> <%= simple_format(status.content) %> <%= link_to time_ago_in_words(status.created_at) + " ago", status %> <% if status.user == current_user %> <span class="admin"> <%= link_to "edit", edit_status_path(status) %> | <%= link_to "delete", status, method: :delete, data: {confirm: "are sure?"} %> </span> <% end %> <% status.comments.e...

html - Bootstrap CSS Column -

Image
i working on quick ui page , still in stages. there 1 thing trying , cant quite figure out. in screenshot attached, have full height column solid background color goes hr footer on left side. i created fiddle basic rendering of page. fiddle: https://jsfiddle.net/unovgp8b/ i tried adding class left column , giving height of 100% never worked. goal column (the solid background) 100% height seeing how content on right going push page down when panel details populated. is there easy way make 100% height column using bootstrap? you're looking equal height column think. there many ways of doing this, 1 have outer container set overflow: hidden , add left column: margin-bottom: -99999px; padding-bottom: 99999px; heaps more examples here: https://css-tricks.com/fluid-width-equal-height-columns/ fiddle: https://jsfiddle.net/h3no8jww/1/

get headers - PHP - Differences between `get_headers` and `stream_get_meta_data`? -

intro / disclaimer decent chunks of outputs can largely ignored. still bit of reader, i'm trying thorough in analysis , questioning. if familiar stream_get_meta_data , fine skip "questions" @ end . other in docs, having trouble finding out php's stream_get_meta_data . overall functionality not vastly different of php's get_headers , cannot life of me find comparisons between two, or pros/cons of former. the setup up until point, i've used php's get_headers verify validity of url. downside get_headers is notoriously slow . understandably, of latency directly due server hosting site of interest, maybe method overly robust, or else slowing down. there plenty of links recommend using curl , claiming faster, i've run side-by-side, timed tests of both, , get_headers has come out on top, factor of 1.5 or 2. i've yet see solutions using stream_get_meta_data , , stumbled upon first time today. i've exhausted google skills, without lu...