Posts

Showing posts from March, 2011

php - Display html in echo statement -

this question has answer here: how write php ternary operator 8 answers ok below information works im trying figure problem if displays title grade... but want put | inbetween this title | grade. my below code works if there no grade still echos |, how can echo when there value in field. because when field empty shows title | <div class="sto-info"> <span><?php echo $title; ?> <?php echo '|', $grade; ?></span> </div> you can use ternary operator: <span><?php echo $title; ?> <?php echo $grade ? '|' . $grade : ''; ?></span>

lua - Cannot connect to MQTT broker from ESP8266 -

i have installed mosquitto on windows machine , it's mqtt v3.1 broker (downloaded mosquitto.org). i trying connect broker esp8266 , far have not been able connect broker. can connect public broker, not broker installed on machine connected same wifi network. i have built firmware using build-nodemcu service , used master branch. think has mqtt v3.1.1. i came across question , guess have ran same situation. though cause of issue has been given, how rid of problem has not been mentioned there. can please suggest how rid of problem? update [13-09-2016] here code using: sensorid = "sen_001" tgthost = "192.168.8.101" tgtport = "1883" mqttuserid = "admin" mqttpass = "word" mqtttimeout = 120 topicqueue = "/security" wifi_ssid = "lakmal 4g" wifi_password = "tf18bny3m" wifi_signal_mode = wifi.phymode_n esp8266_ip="" esp8266_netmask="" esp8266_gateway="" if wifi.

Inverse function in R -

so have function: f(a,b,rho)=r . given a , b , r , find rho . came across inverse function in r, seems when function tries find rho , function cannot tell of a , b or rho specified rho , function cannot load given a , b . in addition, know rho between 0 , 1. a = -.7 b = 2 r <- function(rho,a,b){ # here defined long function of r # in terms of , b , rho } r_inverse=inverse(function(rho) r(rho,-.7,2),0,1) # r_value random value r_inverse(r_value) this not work. appreciate inverse function or other alternative way find rho given r , a , b .

javascript - JQuery/JS onclick change class of element inside link clicked -

i have couple of drop downs using bootstrap , want code in simple function change class of span element inside link clicked. to clarify... here's example of html have: <a data-toggle="collapse" href="#collapse-panel" aria-expanded="false" onclick="toggleicon()"> <span class="glyphicon glyphicon-knight"></span> drop down title <span class="glyphicon glyphicon-triangle-bottom"></span> </a> <div class="collapse" id="collapse-panel"> <!-- content --> </div> i looking function (using js or jquery ) can toggle second span class change between glyphicon glyphicon-triangle-bottom , glyphicon glyphicon-triangle-top . bear in mind, function has work multiple drop-downs. appreciated. $('a[data-toggle="collapse"]').click(function(){ $(this).find('.glyphicon-triangle-bottom, .glyphicon-triangle-to

linux - How can I "delay" in Zsh with a float-point number? -

in zsh there wait (for process or job) command, while (seconds == delay) command, , sched (do later if shell still running) command, no "delay" command. if there were, fear limited whole second delays. need "delay" statement can cause procedure/task nothing time specified in fixed point number or until clock time. most scripts use "sleep", have delay timer run without having open io; seeking ideal can accomplished within zsh. does know how perhaps make function (or maybe builtin/module) perform floating point idle delay in seconds? i'll argue making wrong assumption. zsh shell, , therefore purpose shell. 1 important point in being shell posix compatible shell. since zsh backward compatible bash , in turn backward compatible bourne shell should poisx shell. that means zsh must have access sleep since sleep required posix shell . and far go posix compatibility argument. practical use argument. systems use gnu coreutils

sql - oracle self outer join filtering records -

select a.emp_id a_emp_id, a.emp_code a_emp_code, b.emp_id b_emp_id, b.emp_code b_emp_code, c.emp_id c_emp_id, c.emp_code c_emp_code, emp left outer join emp b on a.u_code =b.u_code left outer join emp c on a.u_code =c.u_code a.src ='a' , b.src ='b' , c.src ='c' for 1 employee have data different sources , id different systems. there more 5 different source system data coming table. u_code remain same in sources. emp having each row each system. now, need build cross walk table in 1 row can give source system id single employee. above query working fine if employee having data in 3 systems filtering out data if present in 2 systems. table data empid,emp_code,src,u_code 1,abc,a,101 2,pqr,b,101 3,xyz,c,101 4,kpo,a,102 5,lip,b,102 query should return a_emp_id,a_emp_code,b_emp_id,b_emp_code,c_emp_id,c_emp_code 1,abc,2,pqr,3,xyz,101 4,kpo,5,lip,,,102 query working fine 101 u_code not returing 102 database oracle 10g when have o

sql server - Can the ROOT element in a select statement using FOR XML PATH be set using a variable? -

i have query creates xml file. currently, have root element hard-coded. use variable value set root element value substituting hard-coded string variable throws syntax error of expecting string . select statement: declare @selectresults xml declare @databasename varchar(100) select @databasename = db_name(); set @selectresults = ( select...query results here... xml path(''), root(@databasename) --when set 'databasename' works ) can use variable in function root() ? you replacement in separate replace acting on xml output: declare @selectresults xml declare @databasename varchar(100) select @databasename = db_name(); set @selectresults = replace( select...query results here... xml path(''), root('root_element') --when set 'databasename' works ), 'root_element>',@databasename+'>' )

python - Not able to get the resources attached with route table -

i using python aws infrastructure automation. need resources attached route table api given ec2 = boto3.resource('ec2') route_table_association = ec2.routetableassociation('rtb-**********') response=route_table_association.get_available_subresources() here return type of response giving me empty list time. , response=route_table_association.delete() gives exception an error occurred (invalidassociationid.notfound) when calling `disassociateroutetable operation: association id 'rtb-*********' not exist.` but route tebale exist , attached subnet explicitly the id required routetableassociationid i.e. rtbassoc-xxxxxx , not route table id . routetableassociationid inside describe_route_tables response json 'associations' element. { 'routetables': [ { 'routetableid': 'string', 'vpcid': 'string', 'routes': [ {....}

loops - multiplying numbers in vector out of order in C++ -

my name matt. i'm new stackoverflow , new c++. working way through c++ primer lippman. i'm doing exercise in book, , task read integers in vector, , multiply integers doing first , last, second , second last, third , third last etc. i did myself without looking up, or else i'd barely learn if copied... program compiles , acts expected. question is: did correctly? there more efficient way of doing it? i not want learn how make working code, want correctly. thank in advance! #include <iostream> #include <string> #include <vector> #include <cctype> using std::cout; using std::cin; using std::vector; using std::endl; using std::string; int main() { vector<int> numbers; int usernum = 0; cout << "enter numbers: "; while (cin >> usernum) { numbers.push_back(usernum); } unsigned maxelement = numbers.size() - 1; unsigned minelement = 0; (auto : numbers) { cou

java - Why is a bean declared in @SpringBootApplication class registered even though it is not a stereotyped class? -

i have main class in project @springbootapplication @enableoauth2sso public class app { public static void main(string[] args) throws exception { springapplication.run(app.class, args); } @bean public requestcontextlistener requestcontextlistener(){ return new requestcontextlistener(); } } as far know, component scan scans beans in stereotyped classes 1 of @component, @service, @repository, @controller if not wrong. from spring docs by default, classes annotated @component, @repository, @service, @controller, or custom annotation annotated @component detected candidate components. i cannot understand how bean in class registered. not stereotyped class , no annotation annotated @component shouldn't scanned in first place code works perfectly. in fact use case having bean in class way problem solved, different thing. can please explain this. !! @springbootapplication meta annotation looks like: // details om

numpy - is there a 2D dictionary in python? -

i create matrix : 33 12 23 42 11 32 43 22 33 − 1 1 1 0 0 1 1 12 1 − 1 1 0 0 1 1 23 1 1 − 1 1 1 0 0 42 1 1 1 − 1 1 0 0 11 0 0 1 1 − 1 1 1 32 0 0 1 1 1 − 1 1 43 1 1 0 0 1 1 − 1 22 1 1 0 0 1 1 1 − i want query horizontal or vertical titles, created matrix by: a = np.matrix('99 33 12 23 42 11 32 43 22;33 99 1 1 1 0 0 1 1;12 1 99 1 1 0 0 1 1;23 1 1 99 1 1 1 0 0;42 1 1 1 99 1 1 0 0;11 0 0 1 1 99 1 1 1;32 0 0 1 1 1 99 1 1;43 1 1 0 0 1 1 99 1;22 1 1 0 0 1 1 1 99') i want have data if query a[23][11] = 1 so there way can create 2d dictionary, a[23][11] = 1? thanks you're asking outside of numpy . a defauldict default_factory dict gives sense of 2d dictionary want: >>> collection

dart - How to Remove a Polymer paper-listbox Item in an AngularDart Component -

i generate paper-listbox follows: <paper-listbox class="scroll-list gutter" id="index"> <paper-item class="index-entry" *ngfor="let composition of compositions" [class.selected]="composition == selectedcomposition" (click)="onselect(composition)"> {{ composition.name }} </paper-item> </paper-listbox> i have method deletes item database. want remove corresponding entry list well. found this stackoverflow question , tried it. gave no such method error when ran it. tried: paperlistbox index; ... index = queryselector('#index'); ... index.remove(); it removes entire listbox. in ball park tried: index.selecteditem().remove(); that gave me browser console error: original exception: class 'paperitem' has no instance method 'call'. nosuchmethoderror: method not found: 'call' receiver: instance of 'paperitem' arguments: [] given err

php - javascript works on localhost but fails on hosting server -

Image
when click on add-to-basket button see error appears in browser console saying : here basket.js file : $(document).ready(function() { initbinds(); function initbinds() { if ($('.remove_basket').length > 0) { $('.remove_basket').bind('click', removefrombasket); } if ($('.update_basket').length > 0) { $('.update_basket').bind('click', updatebasket); } if ($('.fld_qty').length > 0) { $('.fld_qty').bind('keypress', function(e) { var code = e.keycode ? e.keycode : e.which; if (code == 13) { updatebasket(); } }); } } function removefrombasket() { var item = $(this).attr('rel'); $.ajax({ type: 'post', url: '/home/u919084925/public_html/mod/basket_remove.php'

asp.net core webapi - How to include CorrelationId in microservice architecture? -

i creating microservices architecture using asp.net core web api. services decoupled each other, , may deployed in different environments. every service has own logging. when requests flows through these services fail in of service, need way of tracing series of events source, if means traversing multiple services. handle issue, service originates request creates correlationid , pass next service. 2nd service pass 3rd service , on. if exception occurs corresponding service log exception message along correlationid. i wanted know best place caller of service pass correlationid? should caller pass correlationid in httpheader or should pass part method parameter below this service getting called public class requestdto { public string correlationid {get;set;} public string someotherdata {get;set;} } public service2controller:controller { public task<in> dosomething(requestdto request) { // add correlationid in current request items collect

How to get current Wifi channel on Android KitKat? -

how current wifi channel / frequency on android kitkat devices? this post talks it, - supposedly - works devices lollipop (or later os versions) android wifi getting frequency of connected wifi thanks.

r - Discrepancies in median values between dplyr table and ggplot2 boxplot -

Image
this question has answer here: ggplot2 boxplot medians aren't plotting expected 1 answer ggplot2: boxplot use calculations values lying within limits of y-axis? 1 answer i'm summarising data , different median values in table created dplyr package , boxplot (ggplot2). sample data can found here : dplyr table library(dplyr) library(ggplot2) sample2 = read.csv("sample2.csv") sample2 %>% group_by(category) %>% summarise(median_avg=median(avg_value), median_total = (median(total_value))) the result 307 3+ category # tibble: 3 × 3 category median_avg median_total <chr> <dbl> <dbl> 1 1 17.500 37.07 2 2 16.830 117.48 3 3+ 17.375 306.95 however, when try visualise in b

SignalR 2 connection not being persisted -

i've set sample signalr hub, chathub, added list of connections. when runs onconnected see being add list. when open page in browser (expecting list have 2 connections see 0 connections in list). chathub instantiated per request? list<string> connections = new list<string>(); public override task onconnected() { connections.add(context.connectionid); return base.onconnected(); } yes hub instance created each request. specifically : you don't instantiate hub class or call methods own code on server; done signalr hubs pipeline. signalr creates new instance of hub class each time needs handle hub operation such when client connects, disconnects, or makes method call server.

keyboard - Best way to emulate hardware input? -

i used autoit because of versatility , semplicity solve repetitive problems on windows. want try improve way code works. the major problem have encountered work hardware input on non-software level. want use "pure" input i'm pressing key on keyboard or clicking on mouse instead of emulating mouse-clicking or key-pressing autoit. i searched solution several days on google before asking here, , had 2 ideas. maybe work, i'm sure aren't best methods solve problem. 1: use c++ keyboard/mouse apis - make perfect emulation of "hardware" signal or seen virtual signal anyway? 2: use arduino - have found apis same result. thought have been because input usb source. can request sending of key keyboard press key itself. intricate , exaggerated? however i'm wrong , laughing @ these ideas because stupid , insane :p i have little knowledge of c++. if best way reach target, hard learn solve problem? but important question is: are solutions good,

runtime error - Scala forward referencing -

i'm new scala. i'm making game , have list of locations character can visit, of type location . have case class , companion object achieve this. linkedlocations inside location array of type location , can have number of locations location can lead to. in case, room 1 leads room 2, , vice versa. case class location(name: string, desc: string, linkedlocations: array[location]){} object location { val none: location = location("none","none",array(none)) val room1: location = location("room 1","you in room 1",array(room2)) val room2: location = location("room 2","you in room 2",array(room1)) room1.linkedlocations.foreach(location=>println(location.name)) } i've tried making them lazy vals end stack overflow. how fix forward referencing problems this? there better way design this? this looks graph representation--typically forward references avoided decoupling graph nodes (locations

Getting llvm-rs-cc.exe error in Android Studio -

getting error when compiling renderscript library: llvm-rs-cc.exe finished non-zero exit value -1073741515. i know there similar thread same question didn't find solution out of answers provided. searched thoroughly on internet there nothing can find it. it great if helps. i guess using build-tools 23.0.2 or before on windows? there bug incorrect packaging dependencies in old windows build-tools. the fix simple, use buildtoolsversion "23.0.3" or later.

Python code works 20 times slower than Java. Is there a way to speed up Python? -

i wrote program in python , in java search smallest integer solution of equation: a^5+b^5+c^5+d^5=e^5 (expected output 133^5+110^5+84^5+27^5=144^5) powers , roots either computed directly ("direct calculation" method) or computed , stored in array ("power lookup" method). fifth powers looked n5 = fifth_power[n]. fifth power root computed using binary search in array 'fifth_power`. i running on netbeans if matters. takes: 30. s (python, direct) 20. s (python, lookup) 5.6 s (java, direct) 0.8 s (java, lookup) is there way boost python performance? not looking better math (sieving of kind). looking better implementation of "for each combination of a,b,c,d compute of powers, check if sum perfect power. if - print result". is expected python runs 20 times slower java? python 3.5 http://pastebin.com/qvthwgkm from array import * import math import time #python, bruteforce : ~30 s millis1 = int(round(time.time() * 1000)) keep_searching

Issue in using the "\n" as a delimiter in java -

this question has answer here: string.replaceall single backslashes double backslashes 5 answers hi file contents #nadal\r\n#federer\r\n*#djokovic\r\n#murray\r\n i want use \n delimiter want output as #nadal\r #federer\r *#djokovic\r #murray\r i googled not find answer here code written in java scanner scan=null; scan = new scanner(new filereader("//users//rakesh//desktop//input.txt")); // initialize string delimiter scan.usedelimiter(pattern.compile("[\\r\\n;]+")); // printing delimiter used system.out.println("the delimiter use "+scan.delimiter()); // printing tokenized stringhashtable while(scan.hasnext()){ system.out.println(scan.next()); } // closing scanner stream scan.close(); i getting output whole line instead of in new line.can 1 on tia your progr

r - ggplot2 legend title position -

Image
i use following code create heatmap: library(ggplot2) gamma_df <- read.csv("https://www.dropbox.com/s/1kpclcq7o907t61/blogs_test.csv?dl=1") p <- ggplot(data = gamma_df, aes(x=gamma2, y=gamma3, fill=predacc)) + geom_tile() p <- p + scale_fill_gradient2(low = "white", high = "red", limit = c(0.1,0.4), space = "lab", name="discounts") p <- p + theme(legend.position="right") p and results this: i've been unsuccessful in moving legend title little bit doesn't overlap values. tried adding p + guides(color=guide_colourbar(title.vjust=3)) as suggested here various values title.vjust parameter, without luck. know magic this? a quick solution add newline @ end of legend title: library(ggplot2) gamma_df <- read.csv("https://www.dropbox.com/s/1kpclcq7o907t61/blogs_test.csv?dl=1") p <- ggplot(data = gamma_df, aes(x=

javascript - The first buttons work, the second do not -

the first section works. when press +, works. nothing works after +. press plus , second set of buttons appear, pressing them nothing. way, making calculator. <html> <head> <title> javascript </title> </head> <body> <script> var first = "" document.write('<button onclick="one()">1</button>'); document.write('<button onclick="two()">2</button><br/>'); document.write('<button onclick="three()">3</button>'); document.write('<button onclick="four()">4</button><br/>'); document.write('<button onclick="five()">5</button>'); document.write('<button onclick="six()">6</button><br/>'); document.write('<button onclick="seven()">7</button>'); document.write('<button onclick="eight()">8</button&

c# - How to use AutoMapper to map a list to a dictionary? -

i'm trying merge existing list of objects existing dictionary (and in reverse) list has string id should used key in dictionary. rest of parameters on object in list make object in value field of dictionary. mapper.createmap<objecta, objectb>(); mapper.createmap<list<objecta>, dictionary<string, objectb>>().?????? i've seen ways of doing online none got me way there. reversing (to go dictionary<string, objectb> list<objecta> ideal (i doubt reverse() function me there). the 2 objects simple types don't have fancy collections in them. also, there way make mapping fail (throw exception perhaps) if id object in list doesn't exist current key in dictionary? another 1 of attempts (pseudocode): objecta.todictionary(key => key.id, value => mapper.map(value, objectb[value.id], typeof(objecta), typeof(objectb))); however recreate new dictionary , still need merge in elements original dictionary. when comes going i

pymc - PyMC3 Simple Topic Model -

i'm trying implement simple topic model in pymc3 , i'm having problem getting sample. i'm pretty sure issue in 'p' function in how i'm trying access 'theta' variable. theta isn't list, don't know how else combine information. appreciated. import numpy np pymc3 import * import theano.tensor t k = 3 #number of topics v = 20 #number of words n = 15 #number of documents #generaete random categorical mixtures data = np.ones([n,v]) @theano.compile.ops.as_op(itypes=[t.dmatrix, t.lscalar],otypes=[t.dvector]) def p(theta, z_i): return theta[z_i] model = model() model: alpha = np.ones(v) beta = np.ones(k) theta = dirichlet('theta', alpha, shape=(k,v)) phi = dirichlet('phi', beta, shape=k) z = [categorical('z_%i' % i, phi) in range(n)] x = [categorical('x_%i' % (i), p=p(theta,z[i]), observed=data[i]) in range(n)] print "created model. begin sampling" step = me

Casting cost addressing pointer in c from unsigned char * to const char *? -

i wondering how many there calculating @ compile casting of addressing. e. g. in strlen api defined : size_t strlen ( const char * str ); they arr const char * . but sometime use unsigned char arr[] = "something" strlen((const char *)arr); just focus on unsigned char * const char * i wonder cost there in code? there no runtime overhead associated cast in way. merely tells compiler access (or interpret) variable differently how declared. in specific case, compiler smart enough generate code treats char array char* pointer no overhead. in general, casts in c never incur runtime overhead.

How to provide predefined data structure to Firebase Database -

i need put default structure data in firebase database. i'm developing chat application using firebase static list of chat groups. there way manually push list of groups (with data fields needed filled) or others predefined data without using mobile app or website? you can create data structure json file , them import json file firebase console. alternatively can import json file command line, using firebase cli's database:set command .

ios - How come my section headers only disappear on larger devices? -

Image
it works on phones width of 320 iphone 4 , 5. when test on simulator 6 , however, uitableview section headers no longer visible reason. here relevant code: func numberofsectionsintableview(tableview: uitableview) -> int { return 3 } func tableview(tableview: uitableview, viewforheaderinsection section: int) -> uiview? { let headerview = uiview(frame: cgrectmake(0, 0, self.tableview.frame.size.width, 30)) headerview.backgroundcolor = uicolor(red:0.20, green:0.47, blue:0.45, alpha:1.00) let sectionlabel = uilabel(frame: cgrectmake(0, 0, self.tableview.frame.size.width, 30)) switch section { case 0: sectionlabel.text = "monday friday" case 1: sectionlabel.text = "saturday" case 2: sectionlabel.text = "sunday" default: sectionlabel.text = "" } sectionlabel.font = uifont(name:"helvetica

ios - Collection View in a Table View not recognize all sections -

i have collection view inside table view. table view has 5 sections in moment, collection view actives 3 times function: func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { and table view actives 5 times function: override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return 1 } why be? if need examples, ask them.

javascript - angular 2 Do we need avoid two way databind when not necessary? -

i search lot understand if there bad performance if use 2 way databind (ng-model) times @ forms instead of 1 way databind. know angular 1 each 2 way databind new watch created , huge applications angular 1 can have performance issues because this. need know if angular 2 make difference if use 1 way databind or not? 2 way databind need avoid when not necessary? angular2 doesn't have two-way data binding. angular2 has data-binding parent child [childprop]="parentprop" when change detection detects change in parentprop updates childprop , calls ngonchanges() in child component (when implemented). and event binding child parent the way child parent event binding. (childpropchange)="parentprop = $event" calls "someactiononparent()" when eventfromchild.emit(somevalue) called in child component. the combination of these two syntactic sugar data , event bindings shown above [(childprop)]="parentprop" this

ruby on rails - Supplying a name when declaring a package resource - Chef -

i have following chef recipe ( web.rb ): # install apache , start service. httpd_service 'customers' mpm 'prefork' action [:create, :start] end # add site configuration. httpd_config 'customers' instance 'customers' source 'customers.conf.erb' notifies :restart, 'httpd_service[customers]' end # create document root directory. directory node['awesome_customers_ubuntu']['document_root'] recursive true end # write home page. file "#{node['awesome_customers_ubuntu']['document_root']}/index.html" content '<html>this placeholder</html>' mode '0644' owner node['awesome_customers_ubuntu']['user'] group node['awesome_customers_ubuntu']['group'] end my default.rb recipe looks like: include_recipe 'apt::default' include_recipe 'awesome_customers_ubuntu::firewall' include_recipe 'awesome_customer

xml - How to generate alphabetical list in xslt -

how create alphatical list link in xslt such as; <a href="sample.htm?letter=a">a</a> <a href="sample.htm?letter=b">b</a> <a href="sample.htm?letter=c">c</a> ...up to.. <a href="sample.htm?letter=z">z</a> it can xml transform <node> <letter>abcdefghijklmnopqrstuvwxyz</text> </node> or varible? <xsl:variable name="letter">abcdefghijklmnopqrstuvwxyz</xsl:variable> xslt 1.0 <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="1.0"> <xsl:output method="html"/> <xsl:variable name="url">sample.htm</xsl:variable> <xsl:variable name="letter">abcdefghijklmnopqrstuvwxyz</xsl:variable> <xsl:template match="/"> <xsl:call-tem

mysql - 3 columns data to be converted to date wise like in pivot tables -

i have data this. br date total 602 20160901 22 603 20160901 23 602 20160902 24 603 20160902 25 i want out put this. br date 20160901 20160902 tot 602 22 24 64 603 23 25 48 tot 45 49 102 can me.

java - How to ask multiple permissions at the same time in android 6.0+ -

i want ask user accept following permissions @ same time(one one), permissions like: checklocationpermission, checkreadsms, checkcallingpermission, checkreadstate, checkcontactwritestate. so, how can ask these permissions in first screen itself. please me out in regard. in advance. you have first check user phone build version 23. if (build.version.sdk_int >= build.version_codes.m) { askpermissions(true); } else { startactivity(new intent(permissionsactivity.this, splashactivity.class)); finish(); } if version 23 need ask permissions. private void askpermissions(boolean isforopen) { isrationale = false; list permissionsrequired = new arraylist(); final list<string> permissionslist = new arraylist<string>(); if (!checkpermission(permissionslist, manifest.permission.write_external_storage)) permissionsrequired.add("write external storage"); if (!checkpermission(permissionslist, manifest.permission.call_p

ruby on rails - How do I create an HTML tag and place it within an existing HTML tag with content_tag in a helper? -

i have @profile has_many positions . html version looks this: <h3>defensive midfield</h3> <div class="alternative-positions"> <small>attacking midfield</small><br /> <small>right midfield</small> </div> however, doing creating helper abstract view logic, putting bunch of content_tags in profile_helper.rb . the rules follows: when profile has 1 position, goes h3 tag. when there 2, first 1 goes h3 , , second goes small in div.alternative-positions . when there 3, follow #1 & #2 put third position within newly created <small> within existing div.alternative-positions . 1 & 2 straightforward , can code: def player_positions(profile) profile.positions.each_with_index |index, position| if index == 0 content_tag(:h3, position.position_type) else content_tag(:div, content_tag(:small, position.position_type), class: "alternative-positions")

How set cron job - PHP in digital ocean for daily bases? -

i have set cron job command on digital ocean server. 0 1 * * * php /var/www/html/domain/cron/index.php right coded?? because not running daily. had check of 5mint , hourly, working fine not each day. please me find out solution. in advance. check if cron commands ok typing: $ crontab -l or right in /var/spool/cron/crontab your command seems ok script executed every day @ 01am.

php - How to insert value key-value pair in array -

i'm trying insert value key pair in array in php. code given below issue is giving error illegal offset type on line i'm trying push data. $request_url data coming api. $response = simplexml_load_file($request_url); //make different array of images of small , medium , large size $array_features = array(); $array_smallimages = array(); $array_mediumimage = array(); $array_largeimage = array(); foreach($response->items->item $item){ echo $item->itemattributes->title.'<br>'; echo $item->asin.'<br>'; $asin = $item->asin; echo $item->detailpageurl.'<br>'; echo $item->itemattributes->manufacturer.'<br>'; $small_img = $item->smallimage->url; $array_smallimages[$asin] = $small_img; //$array_smallimages = $item->smallimage->url; echo $item->mediumimage->url.'<br>'; echo $item->largeimage->url.'<br>';

c# - Sum of Numbers as Distinct Primes -

//list style using system; using system.collections.generic; using system.linq; public class pr{ static public void main (){ int n, i, j, k, l, sum,flag = 0; //int sum = i+j; //int k = (n-i); //int l = (n-j); //system.console.writeline ("enter number"); //n = convert.toint32 (console.readline()); //list <int> primes = new list <int>(); //list handle numbers //hashset <int> myprimes = new hashset <int> (primes); system.console.writeline ("enter number"); n = convert.toint32 (console.readline()); //myprimes.add(n); //myprimes.add(i); //myprimes.add(j); // var count = string.join(", ", primes); //system.console.writeline("the value of n {0}",myprimes); for(i=3; i<n/2; i++)

sql - What does the e flag and special characters do in mysql? -

i studying mysql http://dev.mysql.com/doc/refman/5.7/en/batch-mode.html . on second paragraph says: if running mysql under windows , have special characters in file cause problems, can this: c:\> mysql -e "source batch-file" what special characters? if save file in notepad, there automatic special characters saved in file? how know whether there or not? hidden? what -e flag do? can find explanation in mysql documentation? -e short --execute , that's why had trouble finding it. http://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html#option_mysql_execute execute statement , quit. default output format produced --batch. see section 5.2.4, “using options on command line”, examples. option, mysql not use history file. a special charater needs escaped in sql query. know when run them because mysql produce errors.

node.js - Data is been sent from client but not reached in server angular2 and nodejs -

i trying post form data server(node) not getting reached there when put console data in backend says undefined.data been sent client not reached in server.i think wrong @ headers,can 1 please suggest help. ts, var headers = new headers(); headers.append('content-type', 'application/x-www-form-urlencoded') this.http.post(this.header1+'login', json.stringify(form), { headers: headers }) my server, exports.login = function( req, res ) { console.log("params:"+req.body.email); //console.log('email:'+params.email); var query = 'select * profile email = ? , password = ?'; connection.query(query,[req.body.email,req.body.password],function(error,result,rows,fields){ if(!!error){console.log(error) console.log('fail'); }else{ console.log(result); res.send(result); } // } });} my routes(express) router.post('/login', admin.login); http uses observable ,

c# - Button in partialview stops working after search -

Image
i have layout page , partialview. i have search-button on layout page , update-button in table in partial view. once click search-button update-button stops working. works fine until search. i'm guessing has forms , actionresult can't work. actionresult never reached - "nothing" happens. controller - registertruckuser [httppost] public actionresult registertruckuser(string registername, string registerpassword, string employeenumber, string userteam) { var model = new registermodel { userlist = db.searchtruckusers(""), userteamlist = getuserteamlist(), triggeronload = true }; //if save button clicked user updated if (request.form.allkeys.contains("btnupdateuser")) { if (!request["btnupdateuser"].isempty()) { name = request.form["item.