Posts

Showing posts from March, 2012

Passing php variable as hidden input where html is contained in one echo -

i'm new php , still learning. <?php if(isset($_post['btnlogin'])){ $myvariable = $_post['fieldparameter']; if(condition){ //do }else{ echo " <form method='post' action='submit.php'><br/> <input type='hidden' name='myvariable' value='<?php echo $myvariable; ?>'/> <br/> <input type='submit' name='btnsubmit' id='submit' value='submit'> </form> "; } } ?> notice variable $myvariable contained in main if block. i'm trying send value of $myvariable submit.php hidden field. also, enclosed html tags using 1 echo statement double quotes. i found related questions here in so can't find similar embedding php within long echo of html tags i tried put value='<?php echo $studentno; ?>' no success. i want a...

C Linux USB Driver | Best way to print URB buffer contents -

i'm new linux usb driver development, , absolutely love far! i'm creating driver xbox 1 controller, , have question guys. in below code, see fill interrupt in urb in open function, , print contents of urb buffer in xb1_int_in_callback() function. best way this? @ moment, i'm using printk(kern_info "int_in_buffer: %s", dev->int_in_buffer), don't see entire urb buffer contents printed, , weird string printed dmesg. sorry if simple question, i'm new programming , c, i'm still learning go, absolutely love far! code: static void xb1_int_in_callback(struct urb *int_in_urb) { struct xb1_controller *dev = int_in_urb->context; printk(kern_info "xb1_int_in_callback called"); printk(kern_info "int_in_buffer: %s", dev->int_in_buffer); } static int xb1_open(struct inode *inode, struct file *file) { printk(kern_info "open function called.."); struct xb1_controller *dev; struct usb_interface ...

c# - show xml in asp.net -

i have xml data show @ asp.net datagrid using c#. data need store in sql server database.what code like. sorry im new in .net platform <pwldml xmlns="http://www.i2owater.com/netbase/1.00"> <site id="j.k.lama 1 mp 2"> <loggingfunction name="flow" type="flow" readingstype="average" interval="900" units="m"> <loggeddata dtg="10-08-15 07:15:00"> <d>24.422224044799805</d> <d>23.800003051757813</d> <d>22.811113357543945</d> </loggeddata> <loggeddata dtg="11-08-15 00:00:00"> <d>11.777780532836914</d> <d>12.066669464111328</d> <d>11.633336067199707</d> </loggeddata> <loggeddata dtg="12-08-15 00:00:00"> <d>10.800003051757813</d> <d>10.766669273376465</d...

anaconda - curses on windows 7 python -

i want use old cellular automata package called cage on windows7 anaconda install. problem is uses curses module, there no official install of. i downloaded unofficial binary @ http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses , /think/ installed it. c:\users\mds>pip install c:\users\mds\downloads\curses-2.2-cp27-none-win_amd64.w hl processing c:\users\mds\downloads\curses-2.2-cp27-none-win_amd64.whl installing collected packages: curses installed curses-2.2 using pip version 8.1.1, version 9.0.0 available. should consider upgrading via 'python -m pip install --upgrade pip' command. but inside spyder, when run 1 of modules ( conway.py ) of cage package, complains @ _curses module. runfile('c:/users/mds/dropbox/_python/automata/cage-1.1.4/conway.py', wdir='c:/users/mds/dropbox/_python/automata/cage-1.1.4') c:/users/mds/dropbox/_python/automata/cage-1.1.4/conway.py:13: runtimewarning: parent module 'cage' not found while handling absol...

javascript - leaflet how to add circle by coordinates? -

next code add circle map: var mylayer = l.circle([60, 54.75621], 200).addto(window.map); but want add coordinates variable: eq.coordinates console.log(eq.coordinates); print on console: point(31.5 42.2) i want like: var mylayer = l.circle(eq.coordinates).addto(window.map); l.circle wants latlng coordinates. if want use pixel coordinates have convert them latlng coordinates using http://leafletjs.com/reference-1.0.0.html#map-containerpointtolayerpoint if put example online, helping you

opencv - Measure real size of irregular shapes in picture -

Image
i have 2 "contours" shapes in array, 1 contourn square know real size, , other mole need make proportional measurement. here image example: the square has 10x10mm, how can know size of other shape based on square? what tried far this: var moleperimeter = cvinvoke.arclength(contours[0], false); double molearea = cvinvoke.contourarea(contours[0], false); var squareperimeter = cvinvoke.arclength(squares[0], true); double squarearea = cvinvoke.contourarea(squares[0], false); textbox2.appendtext("area: " + squarearea / molearea); textbox2.appendtext("perimeter: " + squareperimeter / moleperimeter); but dont thinks corret. assuming mole in circular shape, may use cv::boundingrect() , return cv::rect() , may use rectangular dimensions of mole. similarly have rectangular dimensions of white patch. dimensions of mole (w1 x h1) , of white patch (w2 x h2). now calculate dimension of mole w.r.t real world dimensions: real_w_patch, real_h_p...

ruby on rails - How to search by column attributes in Filterrific -

i'm trying create search , filter filterrific, part code working expected , i'm able implement basic sorting , search following docs. i've added custom :with_organizer filter filters name column. dropdown displays names properly, nothing shows in results list. can search name column , list updated. how make work expected? my controller def index # @events = event.where(published:true).order('start_date asc').order('start_time asc') @filterrific = initialize_filterrific( event, params[:filterrific], select_options: { sorted_by: event.options_for_sorted_by, with_organizer: event.options_for_organizer }, persistence_id: 'shared_key', ) or return @events = @filterrific.find.page(params[:page]) respond_to |format| format.html format.js end rescue activerecord::recordnotfound => e # there issue persisted param_set. reset it. puts "had...

apache spark - Using Pycuda with PySpark - nvcc not found -

my environment: i'm using hortonworks hdp 2.4 spark 1.6.1 on small aws ec2 cluster of 4 g2.2xlarge instances ubuntu 14.04. each instance has cuda 7.5, anaconda python 3.5, , pycuda 2016.1.1. in /etc/bash.bashrc i've set: cuda_home=/usr/local/cuda cuda_root=/usr/local/cuda path=$path:/usr/local/cuda/bin on 4 machines can access nvcc command line ubuntu user, root user, , yarn user. my problem: have python-pycuda project i've adapted run on spark. runs great on local spark installation on mac, when run on aws get: filenotfounderror: [errno 2] no such file or directory: 'nvcc' since runs on mac in local mode, guess is configuration issue cuda/pycuda in worker processes i'm stumped be. any ideas? edit: below stack trace 1 of jobs failing: 16/11/10 22:34:54 info executorallocationmanager: requesting 13 new executors because tasks backlogged (new desired total 17) 16/11/10 22:34:57 info tasksetmanager: starting task 16.0 in stage 2.0 (tid 34, i...

ios - How can I do an HTTP Post before reading the JSON? -

i reading json url , has been working correctly. code: @iboutlet weak var profilescell: uitableview! let cellspacing: cgfloat = 50 var names = [string]() var posts = [string]() var locations = [string]() var votes = [string]() var comments = [string]() override func viewdidload() { super.viewdidload() profilescell.datasource = self let url:url = url(string: "http://"+connection_string+":8000/profile_view")! urlsession.shared.datatask(with:url, completionhandler: {(data, response, error) in if error != nil { print(error) } else { { let parseddata = try jsonserialization.jsonobject(with: data!, options: .allowfragments) as! [string:any] if let profile = parseddata["profile"] as! [anyobject]? { stream in profile { if let fullname = stream["fullname"] as? string { self.na...

c# - How to get specific column from database and work with this data in a datagridview using Entity Framework? -

Image
i have 8 tables in database. when choose 1 of them , show data in datagridview using entity framework, columns navigation properties. how can hide these columns? for example, electrolyte table code: public partial class electrolyte { [system.diagnostics.codeanalysis.suppressmessage("microsoft.usage", "ca2214:donotcalloverridablemethodsinconstructors")] public electrolyte() { this.experiment = new hashset<experiment>(); } public short electrolyte_id { get; set; } public string electrolyte_name { get; set; } public string formula { get; set; } public nullable<int> component_content { get; set; } public nullable<double> thermal_conductivity { get; set; } [system.diagnostics.codeanalysis.suppressmessage("microsoft.usage", "ca2227:collectionpropertiesshouldbereadonly")] public virtual icollection<experiment> experiment { get; set; } } i tried use code, can't a...

dns - Redhawksdr Failed to connect to local domain -

i'm getting following error while trying connect failed connect domain: redhawk_dev org.eclipse.core.runtime.coreexception: error while executing callable. caused org.omg.cosnaming.namingcontextpackage.notfound: idl:omg.org/cosnaming/namingcontext/notfound:1.0 i tried $ nodebooter -d segmentation fault (core dumped) and also $ cleanomni sh: 1: /etc/init.d/omninames: not found i'm on ubuntu 14.04.5 64bit redhawk-src-2.0.3 there solution? based on dialog, network issue, not redhawk configuration issue. consider adding text mentioned in manual clarification.

php - Symfony baseUrl doesn't respond to apache rewrites and breaks all routes -

Image
imagine simple symfony install: symfony new testsite now imagine inside webroot of apache server. of course won't work since symfony webroot in /web/ folder. so make simple rewriterule , drop in htaccess in symfony folder: rewriteengine on rewriterule ^(.*)$ web/$1 [qsa,l] and works. hooray! try out " create first page in symfony " guide , lo , behold controller's 404ing! so seems symfony cutting off 3 characters start of path. bit of debugging shows it's getting base url $_server['script_name'] cause of problem, since doesn't change when rewrite url. is there proper way fix or have redefine script_name manually in app.php? if comments correct, url should using is: symfony-test.local/web/app_dev.php/lucky/number you should specify documentroot web/ folder! done. read more details: http://symfony.com/doc/current/setup/web_server_configuration.html

c# - Using a WPF application to plot 2 line graphs and get their intesection points -

i need plot 2d continuous line graph using wpf application , find intersection points on graph given particular y-axis value. have plotted graph using chart control in wpf (microsoft visual studio 2015) i'm unable determine intersection points on graph. please point me in right direction. also, possible determine crests , troughs on graph after finding intersection points?

list - Python - For Loop That Prints Each Number And Its Square on a Separate Line -

i have list of numbers: nums = [12, 10, 32, 3, 66, 17, 42, 99, 20] my first task print each number on new line, this: 12 10 32 3 66 17 42 99 20 i able creating loop printed integers in list: nums = [12, 10, 32, 3, 66, 17, 42, 99, 20] in nums: print(i) now need write loop prints each number , square on new line, this: the square of 12 144 square of 10 100 square of 32 1024 square of 3 9 square of 66 4356 square of 17 289 square of 42 1764 square of 99 9801 square of 20 40 so far have been able print squared values, can't them on separate lines themselves. need rid of brackets around values. my attempt: nums = [12, 10, 32, 3, 66, 17, 42, 99, 20] in nums: print(i) squared = [ ] in nums: squared.append(i * i) print("the square of", i, "is", squared) resulted in: 12 10 32 3 66 17 42 99 20 square of 12 [144] square of 10 [144, 100] square of 32 [144, 100, 1024] square of 3 [144, 100, 1024, 9] square of 66 [144, 100, 1024,...

java - Wrong sending and receiving photos through socket -

this code of client (android application): socket msocket = new socket(); msocket.connect(new inetsocketaddress("123.456.789.0", 50), 10000); bufferedreader in = new bufferedreader(new inputstreamreader(msocket.getinputstream())); outputstream out = msocket.getoutputstream(); out.write("image number 3".getbytes("utf-8")); out.flush(); fileinputstream mfileinputstream = new fileinputstream(mfile); // mfile - photo while (true) { byte[] i3 = new byte[65536]; int i4 = mfileinputstream.read(i3, 0, 65536); if (i4 < 0) { mfileinputstream.close(); break; } else { out.write(i3, 0, i4); out.flush(); } } and code server: bufferedreader in = new bufferedreader(new inputstreamreader(this.in, "utf-8")); string i1 = in.readline(); bytearrayoutputstream i3 = new bytearrayoutputstream(); while (true) { try { byte[] i4 = new byte[1024]; int i5 = this.in.read(i4, 0, 1024); ...

Adding a Border to Text on an JavaScript Canvas -

i'm trying add automatic border text used javascript canvas. i've tried options stroketext, strokestyle , similar, can't make entered text had border. this "addtext" button code: $scope.addtext = function() { if (canvas.getactiveobject() && canvas.getactiveobject().type == 'text') { applytextstylesselection(); } else { var obj = applytextstyles(new fabric.text($scope.text.text)); obj.setleft(canvas.getwidth()/2); obj.settop(canvas.getheight()/2); canvas.add(obj); } $('#meme-text-modal').hide(); }; this code formats text entered in control (formatting bolding , font size selected user, make text border mandatory function applytextstylesselection() { if ($scope.selection && $scope.selection.type == 'text') { applytextstyles($scope.selection); canvas.renderall(); } } function applytextstyles(obj) { obj.settext($scope.text.t...

android - How to parse data from multiple URLs using asyncTask -

the main problem i'm unable return 2 value help. have tried lot of time no success. , guys i'm new please write answer respect code in advance. here's code public class calculate extends asynctask<string, string, string> { @override protected void onpreexecute() { super.onpreexecute(); } @override protected string doinbackground(string... params) { try { uss = getjson("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22inrusd%22)&format=json&diagnostics=true&env=store%3a%2f%2fdatatables.org%2falltableswithkeys&callback="); jsonobject usjobj; usjobj = new jsonobject(uss); usresult = usjobj.getjsonobject("query").getjsonobject("results").getjsonobject("rate").getstring("rate"); eurr = getj...

SAS cutting off string during data recode -

on dataset created by: data voa; input address $50.; input city $1-15 state $16-17 zip; input latitude longitude; datalines; 1675 c street, suite 201 anchorage ak 99501 61.21 -149.89 600 azalea road mobile al 36609 30.65 -88.15 i'm attempting add new variable essential recoding of long , lat, so: data voa1; set voa; if longitude < -110 region = "west"; if latitude > 40 , longitude < -90 , longitude > -110 region = "mid-west"; if latitude > 40 , longitude > -90 region = "north-east"; if latitude < 40 , longitude < -110 region = "south"; run; unfortunately, seems sas cutting strings short , leaving them @ 4 characters (e.g. "mid-west" becomes "mid-"). if had guess assume because sas assigns number of bytes each value in column based on first value in column, , doesn't dynamically modify number of bytes based on new va...

Android `@BindingAdapter` setter not being called -

here bindingadapter : public class bindings{ @bindingadapter({"font"}) public static void setfont(textview textview, string fontname) { textview.settypeface(fontcache.getinstance(textview.getcontext()).get(fontname)); } } *instead of using "font" annotation parameter, i've tried "bind:font", "android:font", , "app:font", , made corresponding changes in layout, bindingadapter still not called here layout use bindingadapter (bind_layout.xml): <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data></data> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <button ...

powerbi - Share Power BI Datasets with Users Outside Organisation -

i've connected on premises ssas data source power bi desktop , publish web. i share datasets users outside organisation can drag/drop dimensions/measures , create reports , dashboards or reports see. from i've read it's possible share preconfigured dashboards , reports users outside organisation. please tell me if possible share datasets users outside organisation? if external company setup on premises data gateway on vm in network , them connected cube the external users can publish power bi desktop report power bi tenant. there role based security in cube apply external users? if need setup alternate upn suffix , user accounts external users on domain described here. or setup user mappings use customdata pass username in cube way. customdata change ssas roles have service account member (not real users) use customdata() mdx function in dynamic security mdx expressions. the whole scenario described more here . though talking hosting in azure vms joine...

python - Bad Request with Flask -

really struggling bad request flask. know caused flask not finding [key] in form.. however, i've checked form , python code 40 times , cannot see reason case.. have commented out each line of python code references request.form. have done 1 1 , still bad request. when comment out lines bad request goes away.. thought wonderful.. python code; if request.method == 'post': form = 'add package form' clientid = request.form['id'] date = request.form['date2'] strprice = request.form['price'] price = float(strprice) adultlessons = request.form['adult'] juniorlessons = request.form['junior'] shortlessons = request.form['short'] playinglessons = request.form['playing'] notes = request.form['notes'] form.. <form action="/addpackage" method="post" class="sky-form"> <fieldset> <section...

Wildfly variable properties -

standalone.bat set "dbo_path=d:\test" standalone.xml <subsystem xmlns="urn:jboss:domain:naming:2.0"> <bindings> <simple name="java:propertiesfilename" value="${dbo_path}/test.properties"/> </bindings> <remote-naming/> </subsystem> how set properties wildfly picks them ?? how use relative path in value standalone.xml you there. in order achieve goal, need following: set environment variable set "foo=bar" then change standalone.xml contain reference ${env.foo}: <simple name="java:/foo" value="${env.foo}/test.properties"/> . you can check if solution working running following java ee 6+ code @singleton @startup public class startupbean { @resource(lookup="java:/foo") string foo; @postconstruct public void start() { system.out.println("java:/foo = " + foo); } } please refer http...

swift - Calculated difference of two NSDates is Wrong - fixed -

i'm facing issues , can't seem find solution it. there date picker , 2 buttons set start date , end date. app calculates difference between these 2 dates. unfortunately, calculated difference not correct. example when set 5 nov, 2016 first date , 6 nov, 2016 second date, code returns difference of 0 days. when change second date 7 nov, 2016 returns difference of 1 day etc. but when other way setting first lastdate 6 nov, 2016 and then firstdate 5 nov, 2016 difference being calculated (the output 1 day). somehow depends on date set first. here code: @iboutlet weak var startdateoutput: uilabel! @iboutlet weak var enddateoutput: uilabel! @iboutlet weak var datepicker: uidatepicker! @iboutlet weak var answerfieldtimedifference: uilabel! var firstdate:nsdate? var lastdate:nsdate? @ibaction func startbutton(sender: anyobject) { firstdate = datepicker.date let datestr = nsdateformatter.localizedstringfromdate(firstdate!, datestyle: nsdateformatterstyle...

java - TooManyEvaluationsException when calculating integral of high-order polynomial using Apache Commons Math -

i'm using apache math calculate integrals of high order polynomials (degree 40 many terms) using code: simpsonintegrator.integrate(integer.max_value, uf, 0, 100); however i'm getting exception: exception in thread "main" org.apache.commons.math3.exception.toomanyevaluationsexception: illegal state: maximal count (2,147,483,647) exceeded: evaluations @ org.apache.commons.math3.analysis.integration.baseabstractunivariateintegrator.computeobjectivevalue(baseabstractunivariateintegrator.java:235) @ org.apache.commons.math3.analysis.integration.trapezoidintegrator.stage(trapezoidintegrator.java:135) @ org.apache.commons.math3.analysis.integration.simpsonintegrator.dointegrate(simpsonintegrator.java:112) @ org.apache.commons.math3.analysis.integration.baseabstractunivariateintegrator.integrate(baseabstractunivariateintegrator.java:280) can apache math calculate integrals complex? example code below: double[] coefficients = new double[] { 120....

xml - XSL-FO background image corrupting generated pdf -

i generating pdf xsl document below. trying add background image cover entire generated pdf keeps corrupting pdf on generation when include <fo: block-container> on line 12. there way can generate background image or there doing incorrect here? i attempted include background image using <fo:external-graphic> did display image left border @ top (which presume region-before). works hosted image url , not locally stored image isn't issue found bit strange. <fo:block text-align="center" display-align="before"> <fo:external-graphic top="-20mm" bottom="-20mm" content-width="210mm" height="150mm" src="url()"> </fo:external-graphic> </fo:block> ` <xsl:template match="/"> <fo:root xmlns:fo="http://www.w3.org/1999/xsl/format"> <fo:layout-master-set> <fo:simple-page-master master-name="page"...

ios - Best Approach for Send Value for Swift -

i don't have problem sending values between view controllers , i don't approach this , use prepareforsegue method send values between view controllers today realized , didn't it. lets think this, if have 3 view controllers , fetched values somewhere on internet parse.com in first view controller in array of someobjects , have reuse array of someobjects in third view controller because i don't want refetch objects on network. used prepareforsegue method passing value second view controller , after used again approach pass value third view contoller , realized what if have 10 view controller or more ? what best approach in case ? how can store values in global property ? thank !

ruby on rails - PayPal Advanced Validation -

i have been trying validate when silent post comes application validated indeed paypal. have tried both in following link. paypal payments advanced -- validate parameters sent confirm , cancel pages neither seems work. when try pass token not send. if manually works seems regular params sent paypal "override it". i tried using nvp/soap , rest api , neither of them work either. i need simple way work know silent post receiving paypal , valid transaction 100%. secure token seem work great no cigar far. application in ruby on rails. if still not working you, might want check on url receive silent post url: notify.paypal.com (payflow silent post) ip address: 173.0.81.65 here pro module documentation broadleafcommerce.com http://www.broadleafcommerce.com/docs/paypal-payflowpro/current/paypal-payflow-pro-environment-setup found similar here how verify notification silent post url indeed paypal payflow , not hacker?

elixir - Keep @ character unescaped -

i have following route: get "/@:user_name", usercontroller, :show which appears work. however, when use url helper: user_path( @conn, :show, @current_user.user_name ) the output escaped: https://url.com/%40user if implement route this: get "/@/:user_name", usercontroller, :show then @ symbol outputted un-escaped: https://url.com/@/user is there way implement first route without escaping @ symbol? using @ symbol in url path bad idea? the reason phoenix helper expands segments , encodes params . last segment in http://url.com/@user considered being param, while in http://url.com/@/user not. there might different opinions on correct way, or not, truth param (user name in particular case) typically coming outside world, while route comes code. that’s why http://url.com/@/user not uri.encode d. i not fight against how phoenix handles , go http://url.com/@/user or like. otoh, https://url.com/%40user , https://url.com/@us...

android - Quirk with custom Layout Behavior when updating to Support Library 24 -

Image
in last couple of project i've worked on had custom layout behavior button mimick animation floatingbutton makes when snackbar shown. code used is: public class behaviorbutton extends coordinatorlayout.behavior<button> { public behaviorbutton(context context, attributeset attrs) {} @override public boolean layoutdependson(coordinatorlayout parent, button child, view dependency) { return dependency instanceof snackbar.snackbarlayout; } @override public boolean ondependentviewchanged(coordinatorlayout parent, button child, view dependency) { float translationy = math.min(0, dependency.gettranslationy() - dependency.getheight()); child.settranslationy(translationy); return true; } } and "bind" class button through xml. app:layout_behavior=".behaviorbutton" nothing special. the problem : when updated support libraries 23.4.0 24 functionality disappeared. question is: how supposed implem...

jquery - Remove text after element -

i trying remove text after icon. <i class="flagstrap-icon flagstrap-as" style="margin-right: 10px;">x</i>france $('.flagstrap-icon').next().remove(); the problem next() not work without element. example <span>france</span> demo any idea remove text after icon? jquery can't target nodes aren't elements, plain js can $('.flagstrap-icon').get(0).nextsibling.remove() fiddle note uses native remove() , not supported in older browsers, if have support those, you'd do var node = $('.flagstrap-icon').get(0).nextsibling; node.parentnode.removechild(node);

Integrate jquery-globalize into an ASP.NET Core MVC App -

in tutorial : building first asp.net core mvc app visual studio purpose build simple movie application. @ step adding model there note below : note you may not able enter decimal points or commas in price field. support jquery validation non-english locales use comma (”,”) decimal point, , non us-english date formats, must take steps globalize app. see additional resources more information. now, enter whole numbers 10. but did not found in mentioned additionnal resources how integrate jquery date / decimal inputs when using non english locale. this explain in tutorial : getting started asp.net mvc 5 @ step 7 examining edit methods , edit view (near end of page). same tutorial targeting asp.net mvc, not asp.net core mvc. i tried follow same steps stuck because _layout view in asp.net core mvc tutorial cannot set same way in asp.net mvc tutorial. do know how integrate jquery globalize js package asp.net core mvc web app ? or better can translate conc...

spring boot - Making SpringBoot to use beans.xml -

is possible make spring boot use beans.xml file? how can supply context it? there other way put it? sincerely, peter. absolutely! add @configuration @importresource. more info, see http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/importresource.html

node.js - Set default value to a model(Sails.js) -

i starting learn sails.js , want know if there simpler way set default value in model session variable? using waterlock authentication , setting user_id in session variable req.session.user_id . have message model, want default 'from' field session variable. there way in sails.js? if using sail's default orm, waterline , model attributes have defaultsto option. supplied value may function. can @ waterline documentation . sample model module.exports = { attributes: { description: { type: 'string', defaultsto: 'no description.' }, email: { type: 'email', required: true, unique: true }, alias: { type: 'string', defaultsto: function(){ return this.email; } }, } }; if supplied value function, call function bound values in create. for model.create(values)... , if alias null/undefined, alias = defaultsto.call(values) used value alias. so us...

c++ - Having trouble processing a file from my documents in my code? -

i have searched around web , here can't seem figure out doing wrong. i trying better file processing , c++. for practice trying grab text file game folder , make copy of it. here code (that can't access file). #include <fstream> #include <iostream> #include <string> using namespace std; int main() { //define / open files ifstream my_input_file; ofstream my_output_file; string filepath = "c:/users/david laptop/documents/my games/oblivion/renderinfo.txt"; my_input_file.open(filepath); if (my_input_file.is_open()) { cout << "opened\n"; my_output_file.open("output_file.txt", ofstream::trunc); char c; my_input_file.get(c); while (my_input_file) { my_output_file.put(c); my_input_file.get(c); } my_input_file.close(); my_output_file.close(); } else { cout << ...

sql - How to break a line in VB6 -

i need break line of code not know how: sql = "select [id], [first name], [last name], [mark 1 eng], [mark 2 eng], [mark 3 eng], [mark 1 mat], [mark 2 mat], [mark 3 mat], [mark 1 sci], [mark 2 sci], [mark 3 sci] table1 [active] <> 'no'" this mean when break: if txtfirstname.text = "" or txtlastname.text = "" or txtmarks(0).text = "" or txtmarks(1).text = "" or txtmarks(2).text = "" _ or txtmarks(3).text = "" or txtmarks(4).text = "" or txtmarks(5).text = "" or txtmarks(6).text = "" or txtmarks(7).text = "" _ or txtmarks(8).text = "" where put underscores in line because wherever put them gives me error. you have split string via concatenation: sql = "select [id], [first name], [last name], [mark 1 eng], [mark 2 eng], " & _ "[mark 3 eng], [mark 1 mat], [mark 2 mat], [mark 3 mat], [mark 1 sci], ...

sql - Make product posts draft if post meta field equals value -

i have function runs daily want check if post expired (based on custom postmeta field) , if set post status draft. think have principle right there's pretty wrong syntax isn't making work correctly. function far: function make_product_draft( ) { global $wpdb; $sql = " update $wpdb->posts innerjoin $wpdb->postmeta on $wpdb->posts.id = $wpdb->postmeta.post_id set $wpdb->posts.post_status = 'draft' $wpdb->posts.post_type = 'product' , $wpdb->posts.post_status = 'publish' , $wpdb->postmeta.post_type = 'expired' "; $wpdb->query($sql); } i think going wrong when this: $wpdb->posts.id? not sure correct syntax is. appreciated :) my requirements changed since made post, following code worked me. niklaz comment, assistance pivotal in getting working right :) function make_product_draft( ) { global $wpdb; $sql = "update {$wpdb->posts} inner join {$wpdb-...

C++ check array for duplicates and replace them -

i have array full of values, array can not contain duplicate values. duplicate value add 1 value. here code have far, im still getting duplicates. (randarray values located). for (int = 0; < sizeof(randarray) - 1; i++) { (int j = sizeof(randarray); j == 0; j--) { if (randarray[i] == randarray[j]) { randarray[i] == randarray[i] + 1; } } } you have typo when incrementing duplicate: randarray[i] = randarray[i] + 1; // not == also, increment might create duplicate. if it's item comes afterwards there's no problem. array not sorted, might not catch such new duplicate of value passed. therefore might need several passes: bool wasaninc; { wasaninc=false; ... ... ... // if there increment, set wasaninc true } while (wasaninc);

php - Class not found -

i'm trying write front controller in php. here code: <?php require_once('controller/logincontroller.php'); require_once('view/loginview.php'); require_once('model/usermodel.php'); class frontcontroller { private $controller; private $view; public function __construct(router $router, $routename, $action = null) { $route = $router->getroute($routename); $modelname = $route->model; $controllername = $route->controller; $viewname = $route->view; $model = new $modelname; $this->controller = new $controllername($model); $this->view = new $viewname($routename, $model); if (!empty($action)) $this->controller->{$action}(); } public function output() { if (!empty($this->view)) { return $this->view->output(); } } } when i'm passing in route object properties follows: route-> mod...

How to gain user permission and create slack channel in ruby -

i want give user updates app creating channel in team. want 2 thing: create channel (e.g #coolapp) user (in slack team) send update app coolapp channel thanks stoping by. to create channel need (at minimum) channels:write scope ( https://api.slack.com/docs/oauth-scopes ) doubt client grant. best , easiest thing create custom integration incoming-webhook scope allows post messages channel selected user (not you). customer can install custom integration (app) using slack button , if set correctly incoming-webhook; when install app, select channel messages post to. this explained in more detail here . posting messages channel via webhook simple. docs: curl -x post \ --data-urlencode 'payload={"text":"this line of text.\nand one."}' \ https://hooks.slack.com/services/t00000000/b00000000/xxxxxxxxxxxxxxxxxxxxxxxx

javascript - what is meaning of Dot(.) in angular import statement -

i new angular 2 , following angular 2 quick start guide. trying understand directory structure of angular app . using npm build app . came across import statements in angular 2 e.g. import {ngmodule} '@angular/core'; i found sytemjs.config.js file mapped '@angular/core': 'npm:@angular/core/bundles/core.umd.js' where 'npm:': 'node_modules/' npm: alias node_module folder. but when using custom component(made user) , imports like import {appcomponent} './app.component'; what dot(.) represent here ,is representing app folder mapped app: 'app', the dot has nothing angular, means current directory. for example, if have 2 files this app file1.js file2.js and inside app/file1.js : import './file2' this tell module loader file2.js in app directory because current directory of file1.js . you can use .. parent directory. here's explanation dot definition , obtained rahul tr...

Sync data between users in Android App without server -

i developing android app has list, list synced between multiple users - can done with out server side? syncing data between webserver , android app requires couple of different components on android device. persistent storage: this how phone stores data receives webserver. 1 possible method accomplishing writing own custom contentprovider backed sqlite database. a contentprovider defines consistent interface interact stored data. allow other applications interact data if wanted. behind contentprovider sqlite database, cache, or arbitrary storage mechanism. while recommend using contentprovider sqlite database use java based storage mechanism wanted. data interchange format: this format use send data between webserver , android app. 2 popular formats these days xml , json. when choosing format, should think sort of serialization libraries available. know off-hand there's fantastic library json serialization called gson: http://code.google.com/p/google-gson/...