Posts

Showing posts from May, 2012

Write a C Program to extract a portion of a string from a character string using for loop -

#include<stdio.h> #include<string.h> void main() { char str1[50],str2[50]; int i,j,n,m,l; clrscr(); printf("enter string\n"); gets(str1); //scanf ("%s",str1); printf("enter position of required character: "); scanf("%d",&n); printf("enter required number of characters extracted: "); scanf("%d",&m); l=strlen(str1); if(m+n-1<l) { for(i=n-1;i<m+n-1;i++) { for(j=0;j<i;j++) { str2[j]=str1[i]; str2[j]='\0'; } } printf ("the extracted string is: %s",str2); } else printf ("string extraction not possible"); } expected output enter string : university in bangalore enter position of required character: 6 enter required number of characters extracted: 4 extracted string is: sity package exatractstring; import java.util.scanner; public class exatractstring { public static void main(string[] args) { string str;

python - Extract monthly categorical (dummy) variables in pandas from a time series -

so have dataframe (df) dated data on monthly time series (end of month). looks this: date data 2010-01-31 625000 2010-02-28 750000 ... 2014-10-31 450000 2014-11-30 475000 i check on seasonal monthly effects. this simple do, how can go extracting month date create categorical dummy variables use in regression? i want this: date 01 02 03 04 05 06 07 08 09 10 11 2010-01-31 1 0 0 0 0 0 0 0 0 0 0 2010-02-28 0 1 0 0 0 0 0 0 0 0 0 ... 2014-10-31 0 1 0 0 0 0 0 0 0 1 0 2014-11-30 0 1 0 0 0 0 0 0 0 0 1 i tried using pd.dataframe(df.index.month, index=df.index)... gives me month each date. believe need use pandas.core.reshape.get_dummies variables in 0/1 matrix format. can show me how? thanks. this how got april: import pandas pd import numpy np dates = pd.date_range('20130101', periods=4, freq='ms') df = pd.dataframe(np.random.randn(4), index=dates, columns=['data']) df.

Android using fragments add to back stack wont work -

i building calculator app using fragment , want calculator fragment show when button pressed on menu item fragment. have been using addtobackstac(null) not working me. here code below public class mainactivity extends actionbaractivity { fragmentmanager fragmentmanager; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if(savedinstancestate == null){ fragmentmanager = getfragmentmanager(); fragmenttransaction fragmenttransaction = fragmentmanager.begintransaction().addtobackstack(null); calculatorfragment calc = new calculatorfragment(); fragmenttransaction.add(r.id.rellejaut, calc); fragmenttransaction.commit(); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.main, menu); return super.oncreateoptionsmenu(menu);

meteor - Template empty initially but renders properly on changing and coming back to route -

i have template named profile contains 3 other templates. 1 of these templates {{> postlist}} and helper function template is template.postlist.helpers({ posts: function() { return posts.find({rph: {$in : postsarr}}); } }); the problem on going route, postlist template empty, since postsarr calculated later after dom has loaded on basis of other 2 templates. but, if click on other route , come route, template renders properly. what should template renders itself? the easiest way session , though it's worst option: template.postlist.helpers({ posts: function() { return posts.find({rph: {$in : session.get('postsarr') }}); } }); if call session.set('postarr', ...) anywhere in code posts helper update automatically. second option use shared reactive variable: var postsarr = new reactivevar(); and inside helper: return posts.find({rph: {$in : posts.arr.get() }}); now can postsarr.set(...) , should work fine. remember meteor

mailgun - Possible to get the total count of sent messages by day for a single campaign? -

i want @ longitudinal summary of single campaign, campaigna . i want like: curl -s --user "api:0123456789" -g https://api.mailgun.net/v2/example.mailgun.org/campaigns/campaigna/events?groupby=day&event='sent' but not supported in api. does know of alternative way information? if attach tag campaign when send can retrieve campaigns tag. per each daya can have different campaign tag , filter these on sent event or maybe delivered event. have here: http://documentation.mailgun.com/api-events.html#filter-event

jquery - hoverIntent with Foundation 5 Menu -

i trying implement hoverintent zurb foundation 5 dropdown menus. issue foundation menus firing on hover. causes issues when using mega menus. i can see event triggers because of color change dosn't effect timing of hovering state mega visible. example can viewed at.. foundation.myplumbingshowroom.com/testing.html <script type="text/javascript" charset="utf-8"> $(document).ready(function(){$(".hovering").hoverintent(hoverin,hoverout)}); function hoverin(){$(this).attr("data-options","is_hover:true").css('color', 'red');} function hoverout(){$(this).attr("data-options","").css('color', 'white');} </script> <li class="hide-for-medium-down"><a class="hovering" aria-expanded="false" href="#" data-dropdown="menu-1" data-options="is_hover:true" ><strong>ceiling lights</strong><

php - Check mysql data with android -

i got strange (at least me) problem. want check if email address, that's on android device in database. got code on server side: <?php include('db_connect.php'); $db = new _db_connect(); $db->connect(); if(isset($_post['email'])){ $accountmail = $_post['email']; $result = mysql_query("select email gcm_users;"); $count = mysql_num_rows($result); while($row = mysql_fetch_array($result)){ if($row['email'] == $accountmail){ echo "e-mail found"; }else{ echo "not found"; } } } ?> i post account email android file. mail in database echo "e-mail found" , see on android. if e-mail not in database, see nothing. heres function use on android far: protected void doinbackground(string... params) { try{ string accountmail; inputstream inputstream; string stat

How to use python vtk to get the stereo effect? -

i got vtk working rendering 3d objects. want render in stereo way. cannot figure out how tried ren.resetcamera() window = vtk.vtkrenderwindow() #window.getstereocapablewindow() #window.stereocapablewindowon() window.addrenderer(ren) window.setstereorender(1) but doesn't work. body can give idea? this piece of code guarantee work window = vtk.vtkrenderwindow() window.getstereocapablewindow() window.stereocapablewindowon() window.addrenderer(ren) window.setstereorender(1) window.setstereotypetointerlaced()

ios - Connect UISwitch with event in other view controller -

i have 2 view controller first 1 main view controller , run music when view controller load , other view controller settings content uiswitch want when user go setting view controller , turn switch off music stop in main view here code main.h #import<avfoundation/avaudioplayer.h> @interface main : uiviewcontroller { avaudioplayer *audioplayer; bool didinitialize; } main.m static bool didinitialize = no; if (didinitialize == yes) return; didinitialize = yes; //add audio sound current view controller nsurl *url = [nsurl fileurlwithpath:[nsstring stringwithformat:@"%@/mlgboxsoundtrack.mp3", [[nsbundle mainbundle] resourcepath]]]; nserror *error; audioplayer = [[avaudioplayer alloc] initwithcontentsofurl:url error:&error]; audioplayer.numberofloops = -1; // -1 looping forever // audioplayer.volume = 0.5; // 0.0 - no volume; 1.0 full volume // nslog(@"%f seconds played far", audioplayer.currenttime); // audioplayer.currenttime = 5; //

hibernate - Need help on Spring MVC hello world -

i trying learn spring mvc on netbeans 8.0.2 using hibernate , frankly stuck. appreciated. trying simple "hello world" type site. someone on first page hit submit button , resulting page have list of values db. sounds pretty simple right? i've included 5 short files here me if inclined. "web.xml", "dispatcher-servlet.xml","index.jsp", "teamcontroller.java", "secondview.jsp" the way understand how spring mvc should work, using files, follows... 1) running project netbeans, index.jsp file brought up. happens because web.xml consulted, has following line... "<welcome-file>redirect.jsp</welcome-file>" once redirect.jsp consulted, see has following... "<% response.sendredirect("index.htm"); %>" so redirect go web.xml has following... "<servlet-name>dispatcher</servlet-name>" "<url-pattern>*.htm</url-pattern>" s

javascript - What could be causing the Bootstrap modal not to stay on the screen? -

Image
i using bootstrap modal in app, , trying execute stock bootstrap modal proof of concept (i.e. start @ baseline modal works , build there). in _notifications.html.erb have this: <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#mymodal"> launch demo modal </button> <!-- modal --> <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">close</span></button> <h4 class="modal-title" id=&qu

.net - Ajax.BeginForm return Json for message -

i using jquery unobtrusive ajax , mvc ajax.beginform() validate form via c# server side. i'm replacing form itself. it's working fine, wondering: let's form triggering "save database" action , action succeeded. there no errors in form don't want post form client, rather json message triggers success dialog on front end. problem form replace happening. how can force not replace form when json server? i guess i'm asking is: how can not have div updated other code instead? i know onsuccess, fired after div replace, want skip replace. you should jquery ajax post form instead of ajax.beginform kind of functionality. point of ajax.beginform post form , update given target. if want return either partial view or json object, should page replacing , success dialog triggering jquery.

vaadin - How to reference a maven dependency that does not follow the conventions -

i bound use module provided maven artifact not follow conventions, in sense contains two jar files: artifactid-version.jar , artifactid-version-suffix.jar . have reference both in project, , not know how this. when add dependency artifact in pom (in usual way), end first jar in classpath. how second one, *-suffix.jar, on classpath, too? (without manually copying project structure.) unfortunately, communication provider of artifact - well, difficult. otherwise straight go , ask them first. in case matters: artifact contains vaadin widgetset, , suffix "widgets". first jar contains java classes , xml files, second 1 (with suffix) static web content: css, images, html files. apparently accompanies vaadin theme (provided maven artifact). browsed vaadin docs on whether common way of delivering widgetset, no avail. the suffix mention known classifier in maven terminology . to both dependencies, add dependency pom (leave 1 have, too): <dependency>

ios - Distinction between one UITableView displaying different array in segmented control. How to implement swipe for delete only in one segment -

i have 1 uitableview, 2 arrays , segmented control. when segmented control index "1", uitableview display data first array, when index "2" - second array. want swipe delete function in second segment. how can that? thinking of "if statements" in tableview(tableview: uitableview, commiteditingstyle editingstyle: uitableviewcelleditingstyle, forrowatindexpath indexpath: nsindexpath) but don't know put them. if use commiteditingstyle , cells still display delete button when swipe. use editingstyleforrowatindexpath: instead. put if statement in test segment selected, , return uitableviewcelleditingstyle.none (to disable swipe delete) or .delete (to enable swipe delete) accordingly. if want able delete cells putting table view editing mode, test tableview.editing determine whether use .delete or .none .

android - How should inflating go right way? -

i need have several listviews on scrollview android doesn't allow me decided make manually inflate listrows on vertical linearlayout, goes not right way private void filldata(final viewgroup parent, final arraylist<person> array ){ (int i=0;i<array.size();i++){ final view view = lf.inflate(r.layout.personal_listrow, parent,true); parent.setbackgroundcolor(getactivity().getresources().getcolor(r.color.background_light_darker)); view.setbackgroundcolor(getactivity().getresources().getcolor(r.color.background_night_lighter)); textview tvname=(textview) view.findviewbyid(r.id.tvname); textview tvstatus=(textview) view.findviewbyid(r.id.tvstatus); textview tvgender=(textview) view.findviewbyid(r.id.tvgender); //fill textviews info, set onclicklisteners , on } so - view.setbackgroundcolor paints parent . parent vertical linearlayout, view horizontal linearlayout - it's

C++ Program crashing from print function -

at moment program crashing after displaying 1 line out of 250 supposed display. here code: string movielist::printall() { (int = 0; < last_movie_index; i++) { movies[last_movie_index].movie::printmovie(); } } string movie::printmovie() { cout << fixed << setprecision(1) << rating << "\t\t" << votes << "\t\t" << "(" << year_made << ")" << "\t" << name << endl; } full movie , movielist class: class movie { public: movie(); movie(string n, int y, int v, double r); string get_name(); void set_name(string n); int get_year(); void set_year(int y); int get_votes(); void set_votes(int v); double get_rating(); void set_rating(double r); string printmovie(); private: string name; int year_made; int votes; double rating; }; movie::movie() { name = "null";

filter - How to escape minus in regular expression with sed? -

i need free string unwanted characters. in example want filter + 's , - 's b , write result c . if b +fdd-dfdf+ , c should +-+ . read b c=$(echo $b | sed 's/[^(\+|\-)]//g') but when run script, console says: sed: -e expression #1, char 15: invalid range end the reason \- in regular expression. how can solve problem , say, want filter - 's? are looking this? kent$ echo 'a + b + c - d - e'|sed 's/[^-+]//g' ++--

android - How to Find The Link for JSON Data of a Certain Website -

i finished tutorial on how develop android application retrieves updated posts blog using json data. the link json data used retrieve posts, blog name ending "/api/get_recent_summary" how can find link of json data different websites? for example website time magazine http://time.com the quickest , easiest way use google developer tools in google chrome . 1st go google developer tools. 2nd click on " network " tab. 3rd click on xhr sub-tab. xhr(xmlhttprequest) if site uses json listed under xhr sub-tab. can search through different return objects using preview sub-sub-tab. here link website step step how on finding json files http://www.gregreda.com/2015/02/15/web-scraping-finding-the-api/ although above way easiest not stable way of getting info need. many sites make changes return data without notice. break app... i think looking api ( application programming interface ). web apis return json or xml . should start searching

java - RSyntaxTextArea Custom Language JFlex -

i'm trying use jflex add custom language highlighting rsyntaxtextarea. however, moment type character index out of bounds exception: http://pastie.org/private/ygjyj4y5nludeu3dn1xug this occurs if use example jflex code provided here: https://github.com/bobbylight/rsyntaxtextarea/wiki/adding-syntax-highlighting-for-a-new-language i'm not sure causing this. point me in right direction? i'm not quite sure why works, appear have fixed problem copying part of yylex method pythontokenmaker.java java class created jflex. specifically, copied , replaced section of code: http://pastie.org/private/whjzfhbrzwm8qc88t1idq it defintion of method line comment // store cached position hopefully stuck on same problem!

frontend - What subjects I need to study for create a web application? -

first,sorry english( studying still) or first time in community.i need learn how create web application create startup( "my own business" ).the idea have,in country have little quantity startups or web-business( big e-commerces walmart ) have mmmaaannnyy internet users,the market little explored stil , goal startup giving $6,000 mouth. i haved study little html in past fun.then,i know basic computer love it.all know informal/auto-didatic. trying create roadmap books learn. (i belive need learn front-end: html5/ css3 / javascript - jquery , back-end : php ) i searched in amazon goods books themes, create list: -front-end : --html5/css3/javascript: learning web design: beginner's guide html, css, javascript, , web graphics jennifer niederst robbins amazon.com/learning-web-design-beginners-javascript/dp/1449319270/ref=sr_1_2?ie=utf8&qid=1417824449&sr=8-2&keywords=webdesign html , css: design , build websites jon duckett amazon.com/html-css-design

How to update button labels in R Shiny? -

the r shiny website has great example of how update labels , values of variety of input types based on user input. however, couldn't find buttons. specifically, how update label button based on user input? you can dynamically create button so, updating labels @ same time: library(shiny) ui =(pagewithsidebar( headerpanel("test shiny app"), sidebarpanel( textinput("sample_text", "test", value = "0"), #display dynamic ui uioutput("my_button")), mainpanel() )) server = function(input, output, session){ #make dynamic button output$my_button <- renderui({ actionbutton("action", label = input$sample_text) }) } runapp(list(ui = ui, server = server))

list - C++ debugging segfault, runs fine without debugging -

i working tree-structure. all nodes in tree kept in list, children of each node kept in list of treenode pointers within treenode object. this should recursively erase subtree starting given node. it erases treenode-object "nodes" list, , pointer in children-list. it works fine, when use built in debugger in ide, segfaults first time destroysubtree called (*i). not segfault when run program normally, , should. means can't use debugger else in program. @ first thought had how actual erasing, segfaults @ first recursive call of destroysubtree - before erasing... void tree::destroysubtree(treenode* node) { if(node->children.size() == 0) return; list<treenode*>::iterator i; for(i = node->children.begin(); != node->children.end(); i++) { destroysubtree((*i)); //segfaults here, when debugging list<treenode>::iterator j; for(j = nodes.begin(); j != nodes.end(); j++) { if((j

Resource interpreted as Script but transferred with MIME type application/dart -

i sending dart file via httpserver, whenever it, chrome says: "resource interpreted script transferred mime type application/dart: "http://localhost:8000/dart/game.dart"." the line client is: <script type="application/dart" src="dart/game.dart"></script> and line give file is: if(new regexp("/dart/(.*)").hasmatch(uri)){ new file("static/" + uri.substring(1)).exists().then((bool exists){ if(!exists) return; new file("static/" + uri.substring(1)).readasstring().then((string contents){ if(uri.substring(uri.length - 2, uri.length) == "js") request.response.headers.contenttype = new contenttype("application", "javascript", charset: "utf-8"); else request.response.headers.contenttype = new contenttype("application", "dart"); request.response.write(contents);

shell - how to use the if statement for error and warning messages in bash -

i writing codes on gedit , want latest error , warning messages using if statement, if theres error should warning messages. cp /volumes/documents/criticalfile.txt /volumes/backup/. if [ "?" != 0 ]; echo "[error] copy failed!" 1>&2 exit 1 fi i've used above code not sure if correct or not. you have use if [ "$?" != 0 ]; instead of if [ "?" != 0 ]; let want copy file don't know if error. use below command cp -f /root/desktop/my_new_file */root/t definitely give me error because copying "*/root/t" not possible. i can check using following codes #!/bin/bash cp -f /root/desktop/my_new_file */root/t if [ "$?" = 0 ];then echo "no error" else echo "we have error!" fi my output (note condition working) cp: cannot create regular file `*/root/t': no such file or directory have error now let want copy file possible location like cp -f /root/de

html - How take all available space before meet a div with different dimension each time? -

i have div on left contains name, , don't know how long name can be. on right have div containing buttons. number of them can change don't know how many buttons have. using css, how can take available space first div before meet second? i need having 2 div on 1 line. this final effect have: http://www.clipular.com/c/5701413332058112.png?k=sip2dmbxmooyixxulrai6up1oa0 add code better response. it depends how displaying. if menu ul li give them attribute in css display :inline-block. render them in line sorry ré-read. divs different. you can absolure positioning think should throw code on have tried easy editing

entity framework - Specify an association table in Code First -

consider scenario entity called list can hold many user. public class list{ public int id{get;set;} public string name{get;set;} public virtual list<user>users{get;set; } public class user{ public int id{get;set;} public string name{get;set;} public virtual list<list>list{get;set; } i have association table called listuserassociation in db , contains multiple records. the table has 2 columns listid , userid how specify association in ef code first? p.s . cannot drop , recreate table. since have collections defined on both sides, can define relationship either side: modelbuilder.entity<list>().hasmany(e => e.users).withmany(e => e.list).map(ca => ca.mapleftkey(new string[] {"listid"}).maprightkey(new string[] {"userid"}).totable("listuserassociation"); modelbuilder.entity<user>().hasmany(e => e.list).withmany(e => e.users).map(ca => ca.mapleftkey(new string[] {"userid

graph - C++: Using BFS to find a path through a matrix -

suppose 1 given matrix 1 1 0 0 0 0 1 1 0 0 1 0 1 1 0 0 1 1 0 0 0 0 1 1 1 and asked find path only passing through ones top-left point (bold italic 1) bottom-right point (another similar 1). once such path shown in bold. i have been trying implement in c++, i'm - surprise - segfaulting. more importantly, can't work out way without duplicating lot of code. here code: #include <iostream> #include <vector> #include <map> #include <queue> #include <algorithm> #include <list> using namespace std; typedef pair<int, int> coords; struct point { int x, y; int val; bool visited; point (int a, int b, int v) : x(a), y(b), val(v), visited(false) {} }; int main() { int n; cin >> n; vector<vector<point> > pts(n, vector<point>(n, point(0, 0, 0))); int temp = 0; for(int = 0; < n; ++i) { for(int j = 0; j < n; ++j) { c

Accessing public method of another class -

basically, i'm trying call method in class, i'm running errors. here code : public class ocean { private static int gridwidth, gridheight; private int safecount; private boolean shipsafe; private static ship[] ships; private static int[][] grids; public ocean(int a, int b, int c) { grids = new int[a][b]; ships = new ship[c]; for(int = 0; < c; i++) { ships[i] = ship(); } gridwidth = a; gridheight = b; } i cannot access public ship class, , error appears in ships[i] = ship(); i've tried redefining it, adding constructor. change line ships[i] = new ship();

c++ - How much is too much with C++11 auto keyword? -

i've been using new auto keyword available in c++11 standard complicated templated types believe designed for. i'm using things like: auto foo = std::make_shared<foo>(); and more skeptically for: auto foo = bla(); // bla() return shared_ptr<foo> i haven't seen discussion on topic. seems auto overused, since type form of documentation , sanity checks. draw line in using auto , recommended use cases new feature? to clarify: i'm not asking philosophical opinion; i'm asking intended use of keyword standard committee, possibly comments on how intended use realized in practice. side note: question moved se.programmers , stack overflow. discussion can found in meta question . i think 1 should use auto keyword whenever it's hard how write type @ first sight, type of right hand side of expression obvious. example, using: my_multi_type::nth_index<2>::type::key_type::composite_key_type::\ key_extractor_tuple::tail_type::head

c++ - Redirect command prompt output to output window in Visual studio 2012 -

how can redirect printed onto command prompt printed onto output window in visual studio 2012? looking console shown in eclipse. i developing console application in visual c++. i tried "using namespace system::diagnostic" way don't see debug.writeline in suggestions. other alternative have? this question answered here . anyway should try work different approach, may used eclipse believe, used visual studio soon. never needed redirect console output output window. these 2 types of outputs has different purposes. console output intended application (customer) , 1 output window intended debugging purposes. don't want release debug messages customer. right? don't want delete or comment out debug messages every time release software.

c - Is strict aliasing only for the first element? -

using gcc 4.7.2, why cause strict alias violation: #include <stdint.h> #include "emmintrin.h" int f(){ int ret = 0; __m128i vec_zero __attribute__ ((aligned (16))) = _mm_set1_epi32(0); __m128i vec_one __attribute__ ((aligned (16))) = _mm_set1_epi32(1); __m128i vec_result __attribute__ ((aligned (16))); vec_result = _mm_cmpgt_epi32(vec_zero, vec_one); ret += (((uint32_t*)&vec_result)[0] != 0); ret += (((uint32_t*)&vec_result)[1] != 0); return ret; } while ok: #include <stdint.h> #include "emmintrin.h" int f(){ int ret = 0; __m128i vec_zero __attribute__ ((aligned (16))) = _mm_set1_epi32(0); __m128i vec_one __attribute__ ((aligned (16))) = _mm_set1_epi32(1); __m128i vec_result __attribute__ ((aligned (16))); vec_result = _mm_cmpgt_epi32(vec_zero, vec_one); // ret += (((uint32_t*)&vec_result)[0] != 0); ret += (((uint32_t*)&vec_result)[1] != 0); return ret; }

r - Adding to a numeric matrix with data from a dataframe -

i'm wondering if missing faster way of doing following, other doing laborious loop. say have matrix this: m1 <- structure(c(0, 2, 2, 1, 0, 1, 1, 1, 0), .dim = c(3l, 3l), .dimnames = list( c("ak", "jw", "sz"), c("ak", "jw", "sz"))) #m1 # ak jw sz # ak 0 1 1 # jw 2 0 1 # sz 2 1 0 now, want add values following dataframe. here can see individuals listed in 'id1' , 'id2' , value add in 'val'. dfx <- structure(list(id1 = c("jw", "sz", "sz"), id2 = c("ak", "ak", "jw"), val = c(1.5, 2.5, 1)), .names = c("id1", "id2", "val"), row.names = c(na, -3l), class = "data.frame") #dfx # id1 id2 val #1 jw ak 1.5 #2 sz ak 2.5 #3 sz jw 1.0 each value should added respective cell of matrix e.g 2.5 should added m1[sz, ak] . however, same value should added transposed cell, i.

asp.net mvc - checkbox is not showing in foreach statement in partial view in mvc 5 -

i using mvc 5 razor view develop something.i using partial view show data on search button. need show checkbox every row in table i.e in foreach statement in view. the code tried - <input type="checkbox" name="@item.kidfeeid" id = "@item.kidfeeid" value="@item.kidfeeid" /> @html.checkboxfor(modelitem=> true,item.kidfeeid) @html.checkbox("kidfeeid", new { value = item.kidfeeid }) @html.checkbox("checkname") but of above code unable display checkbox in browser.its blank space in browser on inspect html shows code not render it. can 1 me solution.

javascript - console output does not appear in code wars -

i'm doing javascript exercises on code wars. want see what's going wrong in programs printing console, nothing except test results appears in output window. know how print console in code wars? can't find in documentation. function areyouplayingbanjo(name) { // implement me var person = name.split(''); person[0].tolowercase(); console.log(person[0]); if(person[0] === 'r'){ return name + " plays banjo"; } else{ return name + " not play banjo"; } } see issue: http://www.codewars.com/users/elistan/comments https://codewars.com/users/isbadawi/replies from coding point of view first store lower case value compare:you need this: function areyouplayingbanjo(name) { // implement me var person = name.split(''); console.log(person); var x= person[0].tolowercase(); console.log(person[0],x);// see difference here if(x === 'r'){// if use person[0] not match

performance - Double for-loop operation in R (with an example) -

please @ following small working example: #### pseudo data nobs1 <- 4000 nobs2 <- 5000 mylon1 <- runif(nobs1, min=0, max=1)-76 mylat1 <- runif(nobs1, min=0, max=1)+37 mylon2 <- runif(nobs2, min=0, max=1)-76 mylat2 <- runif(nobs2, min=0, max=1)+37 #### define distance function thedistance <- function(lon1, lat1, lon2, lat2) { r <- 6371 # earth mean radius [km] delta.lon <- (lon2 - lon1) delta.lat <- (lat2 - lat1) <- sin(delta.lat/2)^2 + cos(lat1) * cos(lat2) * sin(delta.lon/2)^2 c <- 2 * asin(min(1,sqrt(a))) d = r * c return(d) } ptm <- proc.time() #### calculate distances between locations # initiate resulting distance vector ndistance <- nobs1*nobs2 # number of distances mydistance <- vector(mode = "numeric", length = ndistance) k=1 (i in 1:nobs1) { (j in 1:nobs2) { mydistance[k] = thedistance(mylon1[i],mylat1[i],mylon2[j],mylat2[j]) k=k+1 } } proc.time() - ptm the computation time: user system elaps

c - Bootloader - Display String Runtime Error -

i going write first "hello world" bootloader program.i found article on codeproject website.here link of it. http://www.codeproject.com/articles/664165/writing-a-boot-loader-in-assembly-and-c-part up-to assembly level programming going well, when wrote program using c,same given in article, faced runtime error. code written in .c file below. __asm__(".code16\n"); __asm__("jmpl $0x0000,$main\n"); void printstring(const char* pstr) { while(*pstr) { __asm__ __volatile__("int $0x10": :"a"(0x0e00|*pstr),"b"(0x0007)); ++pstr; } } void main() { printstring("akatsuki9"); } i created image file floppy.img , checking output using bochs . displaying booting floppy... s it should akatsuki9 . don't know did mistake? can 1 me find why facing runtime error? brief answer: problem gcc (in fact, specific application of generated code) , not c

python - In Django view,How to save array which pass from template via Ajax, to database? -

i create array in javascript , send via ajax view , can in view.now want save database(mysql) "internal error" ajax.i think ajax when post data view , django want connect mysql database, connection ajax abroted. this template ajax: var posturl = "http://localhost:8000/student/{{id}}/student_add_course/"; $('form[name="myform"]').submit(function(){ $.ajax({ url:posturl, type: "post", // stock somthing this.stock=[[1,12],[2,14],...] data: {'stock': stock, 'counter':i,csrfmiddlewaretoken: '{{ csrf_token }}'}, error:function (xhr, textstatus, thrownerror){ alert(thrownerror);}, }) }); this view: def student_add_course(request,student_id): if request.method=='get': context={'id':student_id , 'form':addcourseforstudentform()} request.session['listofcourses']=[] return render(request, 'student/addcourseforstudent

Perform a PHP loop every X seconds -

i have user type in how want message sent defined $time variable this loop code have right now $time = $_post["time"]; ($x = 0; $x < $amount; $x++) { mail($completenum, $subject, $message, $headers); sleep($time); } the issue code messages never sent through, believe it's because sleep function halts script. ideas? php isn't correct language this, want try javascript or similar. php designed let dynamically build page when loaded. putting sleep in there, you're delaying load time of page, , server and/or browser going time out - pages aren't expected take excessively long times load, , indicates error. different browsers going different things, , you'd need modify timeout settings on if delay long one. a scripting language keeps running in browser going able kick off periodically want, , update page - want code keeps executing after page loaded. alternately, if want php only, php code store request in database, , have

php - How to break up HTML document to implement modularity? -

i'm creating web-site , use html build page layout. have 1 big html document index.html . there header, middle section , footer. many scripts used form checks, animations, slider , etc. slider has several background images , different content each slide. index.html has lot of stuff in , when user loads first time quite bit of traffic used. when user fills login form, client side jquery script checks form , data posted php script server side checks performed , session started. after successful response server want index.html reload different header. came 2 solutions this: * i can load different document using ajax header container. i can redirect html document(for example index2.html has exact same code exception header container part changed. i don't both of solutions. using ajax can avoid forcing user reload traffic. seems not elegant me reloading header make white square appear in section break user's design experience , looks clunky. while it's asyn

c# - Flatten/Unflatten data from Entities to Models with AutoMapper -

i flatten/unflatten classes using automapper, not sure if possible. have listdefo , valuedefo, how list , values defined. user can add them data object. not worried storing valuedefo id against datavalue, need string value. here classes public class listdefo { public long id { get; set; } public virtual icollection<valuedefo> values { get; set; } } public class valuedefo { public long id { get; set; } public string value { get; set; } } public class data { public long id { get; set; } public icollection<datavalue> values { get; set; } } public class datavalue { public long id { get; set; } public virtual listdefo listdefo { get; set; } public string value { get; set; } } currently if use automapper, have following models, data object values property, , each datavalue have id, listdefoid , value. public class datamodel { public long id { get; set; } public icollection<datavaluemodel> values { get; set; } } p

jsf - java.lang.TypeNotPresentException: Type bookingSessionBean.Plot not present -

i want show list of plot database. have created plot.java in package bookingsessionbean , viewplot.java in package viewbean, doesn't work. index.xhtml code: <h:body> <h1><h:outputtext value="selected plot" /></h1> <h:form> <f:view> <h:datatable value="#{viewplot.plots}" var="item"> <h:column> <h:outputtext value="#{item.plotno}" /> </h:column> </h:datatable> </f:view> </h:form> </h:body> viewplot.java code @managedbean @named(value = "viewplot") @sessionscoped public class viewplot implements serializable { @persistencecontext(unitname = "2day4upu") private entitymanager em; public viewplot() { } public list<plot> getplots() { return em.createnamedquery("plot.findall").getresul

javascript - How can you reliably test if a value is equal to NaN? -

i know use isnan test if value equal nan. reliable? the nan property represents value “not number”. special value results operation not performed either because 1 of operands non-numeric (e.g., "abc" / 4), or because result of operation non-numeric(e.g., attempt divide zero). while seems straightforward enough, there couple of surprising characteristics of nan can result in hair-pulling bugs if 1 not aware of them. for 1 thing, although nan means “not number”, type is, believe or not, number: console.log(typeof nan === "number"); // logs "true" additionally, nan compared – itself! – false: console.log(nan === nan); // logs "false" a semi-reliable way test whether number equal nan built-in function isnan(), using isnan() imperfect solution. a better solution either use value !== value, produce true if value equal nan. also, es6 offers new number.isnan() function, different , more reliable old global isnan() function.

node.js - Is each browser tab its own connection when using Socket.io? -

say there 5 open tabs in single browser, , using node.js , socket.io. client , server exchange packets maintain (establish) communications. will connection client lost if of 1 tab closed? how can determine if user closed browser? yes, socket.io establishes new connection every tab. you're going want using session cookies figure out user current socket.io connection communicating with.

javascript - issue when embedding the both Youtube video url and Vimeo video url from json response in angular js -

var app = angular.module('speakout', []).config( function($scedelegateprovider) { $scedelegateprovider.resourceurlwhitelist([ 'self', '*://www.youtube.com/**' ]); $scedelegateprovider.resourceurlwhitelist([ 'self', '*://player.vimeo.com/video/**']); }); i new angular js. trying append both youtube url , vimeo video url @ same time in jsp page,but working vimeo , not working youtube when trying above code.it working individual videos not both. anyone can help! thanks! this happening because second call $scedelegateprovider.resourceurlwhitelist([ 'self', '*://player.vimeo.com/video/**']); override first settings. try combine white list elements. $scedelegateprovider.resourceurlwhitelist([ 'self','*://www.youtube.com/**', '*://player.vimeo.com/video/**']);

multithreading - How to display a "please wait" message box while the processing goes on in C#? -

i have windows application in using web reference show current sms balance in account of particular user.here code using: thread t1 = new thread(new threadstart(showwaitmessage)); t1.start(); xmlnode xmlnde = ws.bsacbalance(txtloginid.text, txtpassword.text); string sresponse = xmlnde.childnodes[0].innerxml; if (sresponse.contains("authentication failed")) { t1.abort(); messagebox.show("invalid login id or password !", "information", messageboxbuttons.ok, messageboxicon.asterisk); } else { t1.abort(); messagebox.show("total balance in account rs : " + sresponse , "information", messageboxbuttons.ok, messageboxicon.asterisk); } public void showwaitmessage() { messagebox.show("please wait ......"); } th

html - CSS 3 Keyframes Animation (Opacity) Causes Images to Blur at the End -

the animation happens perfectly, images not blurred etc. when finishes, image blurred , stays that. browser testing chrome, regardless of browser, happens. images used in blink animation not scalet, shown in original size. here's css: @charset "utf-8"; @-webkit-keyframes blink { 0% { opacity:0; } 11%, 22% { opacity:1; } 33%, 100% { opacity:0; } } @-moz-keyframes blink { 0% { opacity:0; } 11%, 22% { opacity:1; } 33%, 100% { opacity:0; } } @-o-keyframes blink { 0% { opacity:0; } 11%, 22% { opacity:1; } 33%, 100% { opacity:0; } } @keyframes blink { 0% { opacity:0; } 11%, 22% { opacity:1; } 33%, 100% { opacity:0; } } .blink { opacity:0; -webkit-animation-duration: 6s; -moz-animation-duration: 6s; -o-animation-duration: 6s; animation-duration: 6s; -web