Saturday, 15 August 2015

web api - TcpListener in Webapi using C# -



web api - TcpListener in Webapi using C# -

is there sample code or startup documentation running threads in webapi project. have grouping 1 client devices , want them (group 1) communicate webapi using tcp communication , have grouping 2 client devices , want them (group 2) communicate webapi using http get/posts. how can that?

i discourage doing that. webapi projects (selfhosted excluded) controlled iis application pool. means project can closed/restarted @ time.

in other words: can not guarantee tcp listener keeps running in iis project.

it sounds more want utilize websockets communicate users.

c# web-api tcplistener

html - Browser mis-interpreting '&not' in URL -



html - Browser mis-interpreting '&not' in URL -

apparently if url containing text &not used part of field property, many browsers interpret '¬'. html code:

<a href="#" onclick="window.location='http://www.example.com?some_param=1&notify=true';">click here</a>

will rendered as:

<a href="#" onclick="window.location='http://www.example.com?some_param=1¬ify=true';">click here</a>

i found couple of alternatives substituting &not &%6eot, or posting form instead of getting parameterized url. posts aren't welcome alternative , substitution admittedly hack - need deal other mutual tokens &cent, &curren, &pound, &sect, &copy, &reg... (list taken here).

surely out there has improve solution this?

element attributes interpreted html parser, must escape & characters &amp;. works of time if don't, in cases (such yours) have "right" or won't work.

html browser html-parsing

javascript - backbone template won't stay in html -



javascript - backbone template won't stay in html -

so have backbone template i'm inserting in html:

<div class = "outside of template"> <script id="persontemplate" type="text/template"> <div class="view1"> <input class="toggle" type="checkbox"> <input class="view" style="border:none;" value="<%= name %> <%= age %> - <%= occupation %>"> <a class = "destroy" /> </div> </script> </div>

but when run script/ open page, output of template appear underneath

<div class = "outside of template"></div>

so how can create template contents remain within html div or table or whatever element?

your template appears between div element. that's issue right there.

it has be:

<div class = "outside of template"></div> <script id="persontemplate" type="text/template"> <div class="view1"> <input class="toggle" type="checkbox"> <input class="view" style="border:none;" value="<%= name %> <%= age %> - <%= occupation %>"> <a class = "destroy" /> </div> </script>

javascript html templates backbone.js

linux - Searching standard commands for a string -



linux - Searching standard commands for a string -

i'm trying list standard commands contain string. i'm told echo $path help i'm not sure how... advice? in advance!

try this:

find `echo $path | tr : ' ' ` | grep foo

where "foo" string you're interested in.

and if want ignore case, utilize -i flag grep:

find `echo $path | tr : ' ' ` | grep -i foo

linux unix

Rails 3 basic validation not working with :prompt or :include_blank? -



Rails 3 basic validation not working with :prompt or :include_blank? -

i have next code in view:

<%= f.select :user_id, user_all_select_options, :include_blank => '--select name-----' %>

it displays list of users --select name----- @ top. when user doesn't select name list , leaves --select name----- selected errors because user_id blank.

for reference helper method code looks this:

def user_all_select_options user.all.map{ |user| [user.name, user.id] } end

my model follows:

class parcel < activerecord::base attr_accessible :parcel, :received_at, :received_by, :chilled, :courier, :location, :passed_to, :user_id, :user, :content, :localip validates :user_id, :presence => true belongs_to :user end

for reason validation doesn't appear running, if select user drop downwards , add together validation other field input application correctly shows user message stating field incorrectly empty.

interestingly if leave select drop downwards --select name----- , maintain additional validation, exception thrown. doesn't prompt missing fields errors.

here record during error (this record when had validates presence check on location field:

{"utf8"=>"✓", "authenticity_token"=>"wm4kptoswp3xdv8uu4uasdadnszi9yfzmk=", "parcel"=>{"user_id"=>"", "received_by"=>"dan", "content"=>"", "chilled"=>"0", "courier"=>"", "location"=>"", "passed_to"=>"", "received_at(3i)"=>"9", "received_at(2i)"=>"2", "received_at(1i)"=>"2013", "received_at(4i)"=>"22", "received_at(5i)"=>"59"}, "commit"=>"receive parcel", "action"=>"create", "controller"=>"parcels"}

where should start looking? errors show when controller unless check against user.

the parcel controller create method looks this:

def create @parcel = parcel.new(params[:parcel]) @parcel.localip = request.env['remote_addr'] @parcel.received_by = @parcel.received_by.upcase unless @parcel.user.mobilenumber.blank? usermailer.parcel_notification(@parcel).deliver end respond_to |format| if @parcel.save format.html { redirect_to @parcel, notice: 'parcel created.' } format.json { render json: @parcel, status: :created, location: @parcel } else format.html { render action: "new" } format.json { render json: @parcel.errors, status: :unprocessable_entity } end end end

the reason why you're getting exception when don't select user line

unless @parcel.user.mobilenumber.blank?

since user_id not set, @parcel.user nil causes exception. suggest move within @parcel.save block.

def create @parcel = parcel.new(params[:parcel]) @parcel.localip = request.env['remote_addr'] @parcel.received_by = @parcel.received_by.upcase respond_to |format| if @parcel.save unless @parcel.user.mobilenumber.blank? usermailer.parcel_notification(@parcel).deliver end format.html { redirect_to @parcel, notice: 'parcel created.' } format.json { render json: @parcel, status: :created, location: @parcel } else format.html { render action: "new" } format.json { render json: @parcel.errors, status: :unprocessable_entity } end end end

ruby-on-rails-3 validation model controller

wordpress - Wrong og:image in the Facebook Open Graph -



wordpress - Wrong og:image in the Facebook Open Graph -

i did open graph on website , perfect.

but, homepage (front_page), facebook takes image of footer (?!)

in debug alright. how forcefulness facebook create og: image first image?

the code:

<?php if (have_posts()):while(have_posts()):the_post(); endwhile; endif;?> <!-- default values --> <meta property="fb:app_id" content="my id" /> <!-- if page home --> <?php if (is_front_page()) { ?> <meta property="og:title" content="name" /> <meta property="og:type" content="article" /> <meta property="og:url" content="http://www.com/"/> <meta property="og:image" content="http://www.com/wp-content/uploads/2013/02/thumbface.jpg" /> <?php } ?> <!-- if page content page --> <?php if (is_single()) { ?> <meta property="og:title" content="<?php single_post_title(''); ?>" /> <meta property="og:type" content="article" /> <meta property="og:url" content="<?php the_permalink() ?>"/> <meta property="og:description" content="<?php echo strip_tags(get_the_content($post->id)); ?>" /> <meta property="og:image" content="<?php $fbthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'facebook-thumb' ); echo $fbthumb[0]; ?>" /> <!-- if page others --> <?php } else { ?> <meta property="og:site_name" content="<?php bloginfo('name'); ?>" /> <meta property="og:description" content="<?php bloginfo('description'); ?>" /> <meta property="og:image" content="http://www.com/wp-content/uploads/2013/02/thumbface.jpg" /> <?php } ?>

and sorry bad english

debug url on facebook's debug tool. there's possibility url has been cached facebook though image right one. using linter delete cache, , utilize presently available tags on page.

facebook wordpress opengraph

How do I loop a portfolio return calculation for multiple periods in matlab? -



How do I loop a portfolio return calculation for multiple periods in matlab? -

i have next data/sets (simplified version create illustration clear):

3*10 matrix of stocks identified number given period (3 stocks (my portfolio) in rows * 10 days (in columns) named indexbest. 10*10 matrix of returns each period each security in universe named dailyret (my universe of stocks 10).

i want create loop able calculate sum returns of each portfolio each period 1 matrix ideally 1*10 or 10*1 (returns * date or vice versa).

i have done single period portfolio, see below: want able automate process instead of doing 10* on each portfolio each period. please help!

portfolio_1_l= indexbest(:,1); %helps me portfolio constituents period 1 (3 stocks basically). returns_1_l= dailyret(portfolio_1(:,1));%to calculate returns of portfolio period 1 have referenced extraction of returns portfolio constituents. sum_ret_port_1_l=sum(returns_1_l); %sum homecoming of portfolio period 1

how loop process other 9 periods?

use for loop , utilize index variable in place of hardcoded 1 in illustration code. index output store result each day.

for day = 1:10 portfolio_1_l = indexbest(:,day); returns_1_l = dailyret(portfolio_1_l); sum_ret_port_1_l(day) = sum(returns_1_l); end

matlab loops finance portfolio