Posts

Showing posts from March, 2011

Android: Is it possible to have same-signature app modules, but only one is on Google Play? -

android documentation says multiple apps having same signature can seen system single app made of modules, can upgraded independently. i know if happens when 1 app distributed via google play , distributed in independent way, provided signature same.

siliding image css and html only -

i want pic slide left , top side , and not straight foward, using css , html without javascript. and there simple code take make "dropdown" li go down , push rest of categories? thanks fot helping guys ! nav{ background-color: #fff; width:150px; height: 667px; float:right; } nav h1{ padding: 20px; color: #777; font: 20px tahoma,times,serif; } ul { position: relative; margin: 0; padding: 0; list-style: none; width: 150px; text-align: right; } ul li { position: relative; } li ul { position: absolute; right: 149px; top: 0; display: none; } ul li { display: block; text-decoration: none; color: #777; background: #fff; padding: 5px; border-bottom: 0; } ul { margin: 0; padding: 0; list-style: none; width: 150px; } li:hover ul { display: block; } * { margin: 0; padding: 0; } body { background: #333; background: url("images/3.jpg&qu

sms - Reflect Twilio Opt Outs/Blacklist Requests in My App -

not finding (any) info on subject, thought go ahead , post question. reflect blacklist sms requests/responses in application instead of letting twilio handle it. there mechanism accessing account's twilio sms blacklist? or message status on responses? or need parse every single response keywords? that depends on if using 10 digit number or shortcode. twilio addresses handling stop, help, , other keywords here https://www.twilio.com/help/faq/sms/can-you-customize-the-helpstop-messages-for-sms-filtering the stop keyword sets blacklist described here https://www.twilio.com/help/faq/sms/why-am-i-seeing-the-message-fromto-pair-violates-a-blacklist-rule you may want read this https://www.twilio.com/help/faq/sms/does-twilio-support-stop-block-and-cancel-aka-sms-filtering i know read somewhere request twilio not handle them could, may have applied short codes previously. need contact twilio support

python - ImportError: No module named pytz, even though sys.path says it's there -

trying use pandas python 2.7.6 , can't seem load pytz module. here's have leading error: matts-macbook-pro-2:~ mattrosenthal$ python /library/frameworks/python.framework/versions/2.7/bin/python matts-macbook-pro-2:~ mattrosenthal$ python python 2.7.6 (v2.7.6:3a1db0d2747e, nov 10 2013, 00:42:54) [gcc 4.2.1 (apple inc. build 5666) (dot 3)] on darwin type "help", "copyright", "credits" or "license" more information. >>> import sys >>> print sys.version 2.7.6 (v2.7.6:3a1db0d2747e, nov 10 2013, 00:42:54) [gcc 4.2.1 (apple inc. build 5666) (dot 3)] >>> print sys.path #(added newlines readability) ['', '/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/cython-0.20.1-py2.7-macosx-10.6-intel.egg', '/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/python_dateutil-1.5-py2.7.egg', '/library/python/2.7/site-packages/setuptools-3.

Python - inner class is not defined? -

i have unrolled linked list 1 of classes. i'm new python, not programming, , reason cannot around little problem! i have class node node object used within unrolled linked list. unrolled linked list class performs operations on node class. class unrolledlinkedlist(object): """ inner node class """ class node(object): def __init__(self): self.array = [] self.next_node = none """ end node class """ def __init__(self, max_node_capacity=16): self.max_node_capacity = max_node_capacity self.head = node() """ other functions of unrolledlinkedlist class """ the problem comes @ last line of unrolledlinkedlist class' init function: "global name node not defined". double checked indentation , looked on internet examples of this, couldn't find any. mind explaining me what's wrong? methods do n

php - Unexpected result while joining two tables in doctrine2 -

i performing join operation on 2 tables demand , inventory . 2 records in demand table [demand1, demand2] correspond same record in inventory table [inventory1] . $em = $this->getdoctrine()->getentitymanager(); $countquery = $em->createquerybuilder() ->select('d,i') ->from('apibundle:demand', 'd') ->innerjoin('apibundle:inventory', 'i', join::with, 'd.inventoryid = i.inventoryid') i expecting query return [demand1, inventory1, demand2, inventory1] query returns [demand1, inventory1, demand2] can please tell me doing wrong?

swift - Assigning an array of structs to an array of protocols -

let's have following: protocol myprotocol { } struct mystruct: myprotocol { } var s1 = mystruct() var s2 = mystruct() var s3 = mystruct() var structarray = [s1, s2, s3] when try assign array of structs array of protocols (that each struct in structarray conforms to): var protocolarray:[myprotocol] = structarray i error: cannot convert array of type '[mystruct]' specified type '[myprotocol]' i expect since each object in array conforms protocol ok "an array of structs conform protocol" assignable expects "an array of conforms protocol". maybe doesn't apply when type "an array of " vs "thing", if makes sense. for example, valid: var p1:myprotocol = s1 because s1 conforms myprotocol . if use arrays doesn't seem hold anymore. incidentally, seems work too: var p1array:[myprotocol] = [s1, s2, s3] presumably because type of array determined [myprotocol] , isn't predetermined previous variabl

python - Jamroot (boost-bjam) linking with shared libraries -

i using jamroot/boost-bjam build python binding c++ code: alias boost_dependencies : /boost/python//boost_python /boost/thread//boost_thread ; # platform architecture provided environment variable import os ; local arch = [ os.environ arch ] ; # set project-wide requirements uses # boost_python library project global id # /boost/python. project : requirements <library>boost_dependencies <include>../ <include>../../ : requirements <library-path>../../thirdparty/opencv/lib/ <linkflags>-lm <linkflags>-lpthread <linkflags>-lcrypto <linkflags>-lssl ; # declare 3 extension modules. can specify multiple # source files after colon separated spaces. python-extension test_library : src/test.cpp i link shared libraries in opencv project (../../thirdparty/opencv/lib/) such libopencv_core.dylib, libopencv

r - How can I change `as.POSIXct` into useful format? -

i have following data, , format date/time datetime format analysis on. date vt1 02/05/15 14:00 23.611 02/05/15 15:00 28.61 02/05/15 16:00 28.61 02/05/15 17:00 19.608 i used following code: test$betterdate<- as.posixct(substr(test$date,1,14), format = "%d/%m/%y %h:%m") and keep getting error: error in `$<-.data.frame`(`*tmp*`, "betterdate", value = numeric(0)) : replacement has 0 rows, data has 3836 i believe issue 2 digit years %y not %y . works as.posixct("02/05/15 14:00", format = "%d/%m/%y %h:%m") [1] "2015-05-02 14:00:00 art" you might want check if timezone correct (argument tz of as.posixct ). good luck.

Am I calling the JavaScript file correctly? -

i have web page , wondering if calling correctly javascript3.js . file inside same folder html. when put javascript code inside html, works fine. (the ol3-layerswitcher.js being called correctly don't know why other 1 not being called.) html: <!doctype html> <html> <head> <title>map</title> <link rel="stylesheet" href="http://openlayers.org/en/v3.12.1/css/ol.css"> <link rel="stylesheet" href="ol3-layerswitcher.css"> <script src="http://openlayers.org/en/v3.12.1/build/ol.js"></script> <script src="ol3-layerswitcher.js"></script> <script src="javascript3.js"></script> </head> <body> <div id="map" style="width:100%;"></div> <div id="info"></div> </body> </html> javascript3.js: var test

python - My comand prompt exits right after I test my code -

right after start python code comand prompt exits.i can't test out or see result becaues exits fast.any help? add input("press enter continue...") to end of file. wait press enter.

msbuild - Packages not restored when building on CI queue under TFS (VS Online VS2015) -

Image
i've asked question build errors , continued investigating issue further desperate self. i have guesstimation issue packages fetched not placed correctly. looking through painfully boring logs gave me this. 2016-01-15t21:50:40.8680146z target "beforegenerateprojectprifile" listed in beforetargets attribute @ "c:\program files (x86)\msbuild\microsoft\nuget\microsoft.nuget.targets (186,61)" not exist in project, , ignored. shortly thereafter, can see first sign of going sideways. 2016-01-15t21:50:43.9631666z ##[warning] c:\program files (x86)\msbuild\14.0\bin\microsoft.common.currentversion.targets(1819,5): warning msb3245: not resolve reference. not locate assembly "microsoft.codedom.providers.dotnetcompilerplatform, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35, processorarchitecture=msil". check make sure assembly exists on disk. if reference required code, may compilation errors. 2016-01-15t21:50:43.96

c# - Regex performance issue on a really big string -

right new using regexes appreciate help. i have large string (i parsing as3 file json) , need locate trailing commas out there in objects.. this regex using public static string trimtraillingcommas(string jsoncode) { var regex = new regex(@"(.*?),\s*(\}|\])", (regexoptions.multiline)); return regex.replace(jsoncode, m => string.format("{0} {1}", m.groups[1].value, m.groups[2].value)); } the problem it's slow. without using in string time complete program : 00:00:00.0289668 , : 00:00:00.4096293 could suggest improved regex or algorithm faster replacing trailing commas. here start ( string trailing commas ) here end string need you can simplify regular expression eliminating capture groups, replacing purpose of latter 1 lookahead: var regex = new regex(@",\s*(?=\}|\])"); return regex.replace(jsoncode, " ");

github - Android Volley : comes with a .gitignore -

i have uploaded android project github repo , noticed volley folder greyed out , can't accessed. so took closer @ volley folder, inside myapplication folder , noticed .gitignore file in it. funny thing tho didn't create file. there reason this? shouldn't rid of file , upload volley folder? if downloads project , tries run it, android studio volley folder isn't there?.. missing or ? thank you! .gitignore automatically included in volley project when clone(or download) aosp repository. here content of .gitignore face to: bin gen .gradle build .settings target *.iml .idea local.properties as can see in volley repository, there no files or folders listed above. therefore, have not included none of items in project except src folder have compiled in project. so, don't worry. nothing wrong happen it.

python - how to add different base templates for different languages of same page in django cms -

how can add different base templates different languages of same page in django cms? i trying set page , show in different languages. , languages, need use different base template. i new django cms. please help. you need create different page trees per language. every page has 1 template. use {% trans %} , {% blocktrans %} translating string in it. or {% if request.language == "en" %} . if templates differ much: don't add other languages pages... create different page trees 1 language.

html5 - Possible to display Qt in an iFrame on Chrome Browser -

not sure if appropriate question stack have application runs in qt (kde system guard). want aggregate browser window lot of other monitoring systems. know typically throw down iframe such as: <iframe src="http://pathtomynetworkmonitors.com"></iframe> but since qt runs in it's own browser i'm not sure if can this. i'm wondering if out there has tried or other work around. thanks. a qt application not run 'in browser', native application other. not (typically) have web server, nor (typically) have way integrate web server, output not web browser can access. you may confused because qt applications use webkit (qtwebkit) present webpage part of ui, not how qt applications are. there emscripten-qt project, ports qt toolkit emscripten, allowing many qt apps compiled run inside browser. doubt, however, ksysguard can made functional that.

Connecting to SQL Server with pyodbc over VPN -

i have code establishes connection sql server using pyodbc . however, sql server accept connections vpn. need therefore modify connection go via vpn. how can achieve pyodbc? the vpn connection need established first, isn't problem can solved directly pyodbc .

javascript - Image behind text on hover CSS HTML -

i trying image show behind text hover effect. it simple splash page now, can't seem figure out how work. here current page. words below logo links. https://gyazo.com/8fac5b310ed8febd80032cc19b57d76e here image want behind text when user hovers. https://gyazo.com/67852dd57789458942952b1dd3b3cb55 it scribble effect in different colors. wouldn't show @ one, different 1 behind each word hover. here html: <!doctype html> <html lang="en"> <head> <link href='https://fonts.googleapis.com/css?family=open+sans:400,800,600,300' rel='stylesheet' type='text/css'> <meta charset="utf-8"> <title>lira.net</title> <link rel="stylesheet" href="css/style.css"> <script src="script.js"></script> </head> <body> <div id="middlegroup"> <div id="topimage"> <img src="images/liralogo325.png"> </

xamarin.android - No resource identifier found for attribute 'MvxBind' in package in Xamarin Android app -

i'm using xamarin studio v5.10.1 , xamarin android v6.0.0.34 , mvvmcross v3.5.1. i keep getting error message when build solution: no resource identifier found attribute 'mvxbind' in package my.package i've seen question in stack overflow regarding error nothing helped. here tried: clean , rebuild used res-auto instead of package name upgrade latest mono android it seems file mvxbindingattributes.xml not copied resources/values folder. assume supposed extract cirrious.mvvmcross.binding.droid.dll somehow doesn't. i tried creating mvxbindingattributes.xml file myself in right place. fixed compilation error runtime error complaining same thing (resource id's not found). ok. checked. doesn't seem nuget installs mvxbindingattributes.xml resources\values folder. have create yourself: the contents need this: https://github.com/mvvmcross/mvvmcross/blob/3.5/cirrious/cirrious.mvvmcross.binding.droid/resources/values/mvxbindingattr

rust - Borrowing from Weak<T> -

i feel rc::weak use (sort of) asref trait implementation. i'm trying borrow shared content weak pointer, won't compile: use std::rc::weak; struct thing<t>(weak<t>); impl<t> thing<t> { fn as_ref(&self) -> option<&t> { self.0.upgrade().map(|rc| { rc.as_ref() }) } // clarity, without confusing closure fn unwrapped_as_ref(&self) -> &t { self.0.upgrade().unwrap().as_ref() } } i understand why: upgraded rc not survive as_ref call. seems me sound. possible magic trick using unsafe compile: impl<t> thing<t> { fn unwrapped_as_ref<'a>(&'a self) -> &'a t { let rc = self.0.upgrade().unwrap(); unsafe { std::mem::transmute(rc.as_ref()) } } } so: are there downsides solution? sound? can think of simpler alternative? would make sense implement as_ref(&self) -> option<&t> in standard library? you can’t

ruby on rails 4 - Field level permissions using CanCanCan or Pundit -

i using rails 4.1.14 cancancan 1.13.1 , defined granular permissions on model/record level. admins can manage articles users can edit articles authored. to prevent regular users editing specific fields make fields visible in rails_admin depending on role. visible bindings[:object].id == bindings[:view].current_user.roles.include? :admin end i using https://github.com/aasm/aasm gem , created custom actions user can move records new states. but want enable field level permissions depending on user's role / record. can't find docs on cancancan or https://github.com/elabs/pundit pages. does have experience that? you mean admin should allowed edit fields of record, editor allowed change fields x , y? yes, possible in pundit, since integrates strong parameters (which should using anyway). there's example in pundit readme (see: strong parameters). simplified example readme: # post_policy.rb def permitted_attributes if user.admin? [:title

python - Write to csv and I get error : _csv.Error: sequence expected -

please help. error when want write dict alllistinstance csv file. code: alllistinstance= {frozenset(['offense involving children']): [(95,), (96,), (35,), (80,), (100,)], frozenset(['battery', 'theft']): [(173, 209), (173, 224)]} open('test1.csv', 'wb') csv_file: key in alllistinstance.keys(): csv_writer = csv.writer(csv_file) csv_writer.writerow(len(alllistinstance[key])) y in range(len(key)): csv_writer.writerow([x[y] x in key]) csv_writer.writerow(x[y] x in alllistinstance[key]) output expected: 5 # len(alllistinstance["offense involving children"]) count of member offense involving children 95 96 35 80 100 2 # len(alllistinstance['battery','thief']) count of member battery thief 173 209 173 224 error: csv_writer.writerow(len(alllistinstance[key])) _csv.error: sequence expected solusion expected ouput: with open('test8.csv'

How to Install rsyslog v8.15 on Amazon Linux AMI -

im trying upgrade rsyslog 5.8.10 on amazon linux ami 2015.09 v8.15. here steps: vi /etc/yum.repos.d/rsyslog.repo [rsyslog_v8] name=adiscon centos-$releasever - local packages $basearch baseurl=http://rpms.adiscon.com/v8-stable/epel-7/$basearch enabled=0 gpgcheck=0 gpgkey=http://rpms.adiscon.com/rpm-gpg-key-adiscon protect=1 sudo yum install rsyslog --enablerepo=rsyslog_v8 --setopt=rsyslog_v8.priority=1 my error output: loaded plugins: priorities, update-motd, upgrade-helper amzn-main/latest | 2.1 kb 00:00 amzn-updates/latest | 2.3 kb 00:00 rsyslog_v8/x86_64

regex - How do I extract a range of lines from a text file using sed -n but in Python? -

say have file 10gb has 20,000 lines filled digits of pi. 123123 12312312 123123 123123 12312312 123123 how extract lines 10,000 20,000 using unix command sed -n ? i'd each line newline character export file using code below. so far, have following: com = "sed -n \' " + str(window[0]) + "," + str(window[1]) + "p\' " + "sample.txt" + ">" + "output.txt" os.system(com) but throwing concatenation errors. how should phrase command sed -n python in program below? inputfilename = "sample.txt" import itertools import linecache def sliding_window(window_size, step_size, last_window_start): in xrange(0, last_window_start, step_size): yield (i, + window_size) yield (last_window_start, total_pi_digits) def picrop(window_size, step_size): f = open(inputfilename, 'r') first_line = f.readline().split() total_pi_digits = int(first_line[0])

eclipse - Java: Proper organization of external libraries? -

so took coursera course had me work external libraries. 2 .jar files of weekly projects depended upon. i'm not entirely sure how eclipse compiles , runs files, , how links these external libraries -- proper way of organizing this? put copy of each .jar file in each project directory? is there another, cleaner way should organizing this? thanks -- as beginner programmer ok put in each project. consider ongoing work , @ time in future want upgrade new version of these external libraries. have copy everywhere. instead option store them in 1 place , add in classpath in each project. have 1 copy of it, better. now, if , when new version file names might change, still have change classpath of each project. but advise worry these , other such problems later. now, focus on programming related problems rather configuration.

language lawyer - C "observable behavior" in the context of UB "undefined behavior" -

(question prompted comments under answer are there race conditions in producer-consumer implementation? being asked here strictly c language perspective, without concurrency or multi-threading involved.) consider minimal code: #define bufsiz 10 char buf[bufsiz]; void f(int *pn) { buf[*pn]++; *pn = (*pn + 1) % bufsiz; } int main() { int n = 0; f(&n); return n; } question: c "as-if" rules allow compiler rewrite code follows? void f(int *pn) { int n = *pn; *pn = (*pn + 1) % bufsiz; buf[n]++; } on 1 hand, above not change observable behavior of program written. on other hand, f called invalid index, possibly translation unit: int g() { int n = -1001; f(&n); } in latter case, both variants of code invoke ub when accessing out-of-bounds array element. however, original code leave *pn @ value being passed f (= -1001) while rewritten code step ub-land after modifying *pn (to 0 ). would such difference coun

java - Filling a square with tiles -

Image
i have 2d tile game trying create brush sizes for. currently, code looks this: if (ismouseclicked0) { int grid_x = math.round(mousex / blocksize); int grid_y = math.round(mousey / blocksize); (int x = 0; x < brushsize; x++) { (int y = 0; y < brushsize; y++) { world.setat(grid_x, grid_y, b[inventoryselect]); grid_x += x; grid_y += y; } } } the setat() method looks this: public void setat(int x, int y, blocktype b) { if (x <= display.getwidth() / blocksize && y <= display.getheight() / blocksize) { blocks[x][y] = new baseblock(b, x * blocksize, y * blocksize); } render(); } this produces output: the tile above first tile on top left clicked mouse, can see next tile isn't rendering. i've been @ hours, i'm missing simple. help? edit: brush size 2 , should creating 4 tiles. blocksize 32 , it's how big blocks are. the problem : grid_x += x

android - Amazon ads integration not working -

i'm testing amazon ads first time , i'm following amazon quick start guide sample project given in sdk but still i'm getting these errors- logcat 01-16 12:37:11.359: e/amazonmobileads sisgeneratedidrequest webrequest httpurlconnectionwebrequest(6212): problem while creating output steam request body: aax-eu.amazon-adsystem.com/127.0.0.1:80 - connection refused 01-16 12:37:11.359: e/amazonmobileads adrequest webrequest httpurlconnectionwebrequest(6212): problem while creating output steam request body: aax-eu.amazon-adsystem.com/127.0.0.1:80 - connection refused 01-16 12:37:11.359: e/amazonmobileads adloader(6212): not contact ad server 01-16 12:37:11.367: w/simpleadsample(6212): ad failed load. code: network_error, message: not contact ad server here layout.xml - <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:amazon="http://schemas.android.co

c - Why does some characters change? -

i'm programming c language in codeblocks gnu gcc compiler.i writing function create link list consisting token nodes.for example, below text file: main ( ) { int ; int b ; } the link list of tokens be main -> ( -> ) -> { -> int -> -> ; -> int -> b -> ; -> } for delimiter space character. decided make other link list called line . each line consisting successive tokens separated space finished ; character. example , @ same text file relevant tokens lines be: main ( ) { int ; -> int b ;-> } you see code below: //including related header files typedef struct token { char *tok; struct token *next; int tp; } token; typedef struct line { char *ls; struct line *next; int parent; } line; token *start; line *lstart; void addline (line * a); void showline (void); void setline (void); int main (void ) { int = 0; // next 4 lines allocates space start(pointer of type token) // , lstart(pointer

android - How to send string from one activity to another? -

so have string in activity2 string message = string.format( "current location \n longitude: %1$s \n latitude: %2$s", lat, lng); i want insert string text field in activity1. how can that? thank in advance. you can use intents, messages sent between activities. in intent can put sort of data, string, int, etc. in case, in activity2 , before going activity1 , store string message way : intent intent = new intent(activity2.this, activity1.class); intent.putextra("message", message); startactivity(intent); in activity1 , in oncreate() , can string message retrieving bundle (which contains messages sent calling activity) , call getstring() on : bundle bundle = getintent().getextras(); string message = bundle.getstring("message"); then can set text in textview : textview txtview = (textview) findviewbyid(r.id.your_resource_textview); txtview.settext(message); hope helps !

libreadline - readline: remapping \C-m (Ctrl+m) -

i want have custom binding \c-m in ~/.inputrc. however, moment replace can no longer enter commands. e.g., "\c-m": vi-forward-word the problem seems there exists default binding "\c-m": accept-line that not problem in appears other programs (the terminal?) send ^m (ctrl-m) indicate carriage return. in setup have urxvt tried xterm, behavior same (return no longer works once add "\c-m" vi-forward-word binding @ end of inputrc). now want changed, willing patch program/library involved. question is: should relevant pieces? checked readline source code not find indicating \c-m reused internally. similarly, checked urxvt cannot find mapping carriage return \c-m in code (which best guess happening cause behavior). interestingly there rxvt.7.pod containing kp_enter ^m esc o m and rxvt-unicode.termcap with ...:cr=^m:... however, both files seem documentation or @ least not installed. knowledge of terminfo files , involvement in overall

php - Autofill data gets overwritten by onchange event of javascript -

so facing annoying issue. have form empty field initially. user has option use default set of values choosing radio button 'yes' option. if user chooses use default set of values fill form fields default set of values using script. goes fine till now. the problem select drop-down not getting set default value. after debugging found out getting set on change event of js gets fired populating drop down dataset ajax response. how stop on-change event fired if user not clicked on drop down , changed something. <!doctype html> <html> <head> <title></title> </head> <body> <input type="radio" value="1" name="rdchoice"> yes! set default value <input type="radio" value="0" name="rdchoice"> no! have fill data <hr> first name : <input type="text" name="txtfirstname" id="txtfirstname"><br> last name : <

android - ANR's frameDelay(); -

getting anr's when framedelay(); being called. can on code , see going wrong stumped! p.s stackoverflow details needed silly input box error correction. public final class drawthread extends thread { private boolean mpause = false; private boolean mrun = true; @override public void run() { while (mrun) { framedelay(); canvas canvas = null; waitforbitmap(); try { while (mrun && mpause) { sleep(100); } canvas = surfaceholder.lockcanvas(null); if (canvas != null) { synchronized (surfaceholder) { if (mrun) { controller.draw(); canvas.drawcolor(color.ltgray); canvas.drawbitmap(mbitmap, panhelper.mrectsrc, panhelper.mrectdst, paint);

javascript - Syntax error: Unexpected number at Object.parse, PHP to AngularJS -

i have built contact form using angularjs frontend , php mail client sends email. want pass data php angular, telling angular whether or not email sent. however, when try that, "syntax error: unexpected number". my php: <?php require_once "../vendors/phpmailer-master/phpmailerautoload.php"; print_r($_post); $data = array(); $sender_name = isset($_post['sender_name']) ? $_post['sender_name'] : ''; $sender_email = isset($_post['sender_email']) ? $_post['sender_email'] : ''; $sender_tel = isset($_post['sender_tel']) ? $_post['sender_tel'] : ''; $sender_message = isset($_post['sender_message']) ? $_post['sender_message'] : ''; $mail = new phpmailer; //enable smtp debugging. $mail->smtpdebug = 3; //set phpmailer use smtp. $mail->issmtp(); //set smtp host nam

json - Creating a collection of nested resources in roar-rails -

i trying create new objects collection of nested resources. when post json, get: activerecord::associationtypemismatch: formlabel(#70306552439440) expected, got hash(#70306480154920) here's code: # form.rb class form < activerecord::base has_many :form_labels validates_presence_of :name end # form_label.rb class formlabel < activerecord::base belongs_to :form validates_presence_of :form validates_presence_of :text end # form_representer.rb module formrepresenter include roar::json property :id property :name collection :form_labels end # form_label_representer.rb module formlabelrepresenter include roar::json property :text end # form_controller.rb class formscontroller < applicationcontroller include roar::rails::controlleradditions def create form = form.new consume!(form) respond_with(form) end when debug, these params: 0> params => {"name"=>"address", "form_labels"=>[{

python - How to write in new line in a file? -

i need create program saves people's information e.g. name in text file depending on first letter of surname if surname starts k goes myfile1 . i need loop have done because it's unknown number of people want each person written in different line in text file there way this. the code @ bottom puts each separate information new line , don't want want each different person in new line. myfile1 = open("al.txt", "wt") myfile2 = open("mz.txt", "wt") mylistal = ([]) mylistmz = ([]) while 1: surname = input("enter surname name.") if surname[0] in ("a","b","c","d","e","f","g","h","i","j","k","l"): title = input("enter title.") mylistal.append(title); firstname = input("enter first name.") mylistal.append(firstname); mylistal.append(sur