Posts

how to join various bits of string and data together using python -

python newbie here. i've been working way through code create string includes date. have bits of code working data want, need formatting string tie in data together. this have far: def get_rectype_count(filename, rectype): return int(subprocess.check_output('''zcat %s | ''' '''awk 'begin {fs=";"};{print $6}' | ''' '''grep -i %r | wc -l''' % (filename, rectype), shell=true)) str = "my values (" rectypes = 'click', 'bounce' myfilename in glob.iglob('*.gz'): #print (rectypes) print str.join(rectypes) print (timestr) print([get_rectype_count(myfilename, rectype) rectype in rectypes]) my output looks this: clickmy values (bounce '2015-07-01' [222, 0] i'm tr...

Where am I going wrong with Sentinel or break in this Python code -

okay program done keeps running. need figure out sentinel or break needs go. have far in python. program suppose read pres on list , print them. there slice removing first 2 , last two.then prints list size 6 , proceeds give me 6 pres in alpha reverse order. have working other repeating end indefinitely. there has while loop display elements in list returned playlist. pres = ['kennedy','johnson','nixon','ford','carter','reagan',\ 'bush','clinton','bush','obama'] pres2 = pres[2:8] def main(): names in pres: print(names) pr3=playlist(pres2) while playlist !='6': pr3 in pres2: print(pr3) def playlist(pr): size = len(pr) print('list size now', size) pr.sort() pr.reverse() return pr main() now should when run it. kennedy johnson nixon ford carter reagan bush clinton bush obama list size 6 reagan ...

php - CSV import in Yii2 -

did? i have trying upload csv file in project module.the csv format given below.at time of upload getting error message "1 row has validation error". values not inserted in db. what want? i want upload csv file data in mysql db. **my csv format** ============================================================================== model_name|imei_no|promoter_vendor_id|device_report_id|allocation_date ============================================================================== sam | 2342 | 7 | 3 |2015 ============================================================================== insert query mysql insert `dbname`.`tbl_device` (`device_id`,`model_name`,`imei_no`,`promoter_vendor_id`,`device_report_id`, `allocation_date`,`inserted_date`,`inserted_ip`,`inserted_by`,`updated_date`, `updated_ip`,`updated_by`,`status_in`,`record_status`)values (auto_inc,sam,34234,7,3,2015,?,?,?,?,?,?,?,?); model import function in m...

AngularJS: $filter 'date' won't change format -

i'm trying filter current date format can accepted web api, format being 01/01/0001 00:00:00. here attempted code @ - var today = date(); var completedt = $filter('date')(today, 'mm/dd/yyyy hh:mm:ss'); however completedt hold "tue jul 14 2015 15:37:36 gmt+0100 (gmt daylight time)" can't seem find answer online, assume simple doing wrong. change today this: var today = new date();

docker - What does the DOCKER_TLS_VERIFY and DOCKER_CERT_PATH variable do? -

i new docker, using boot2docker on windows 7. while trying configure docker build through spotify maven plugin, asked set below env variables : docker_host docker_cert_path docker_tls_verify configuration successful not sure docker_tls_verify , docker_cert_path variables ? as mentioned in readme : by default, boot2docker runs docker tls enabled . auto-generates certificates , stores them in /home/docker/.docker inside vm. boot2docker up command copy them ~/.boot2docker/certs on host machine once vm has started, , output correct values docker_cert_path , docker_tls_verify environment variables. eval "$(boot2docker shellinit)" set them correctly. we recommend against running boot2docker unencrypted docker socket security reasons, if have tools cannot switched, can disable adding docker_tls=no /var/lib/boot2docker/profile file. in more dynamic environment, boot2docker ip can change, see issue 944 .

numpy - Meijer G-function in Python and scipy -

Image
i'm in need of meijer g function in scipy. read somewhere on internet due generality, meier g function not supported special function in scipy, should write according personal use case. my problem have no experience whatsoever complex integration. latex forbidden here, here's i'm trying solve numerically: (the first line being general case, second line case i'm trying compute), p(a), k, k2 given as wikipedia states , there 3 ways l : l runs −i∞ +i∞ such poles of Γ(bj − s), j = 1, 2, ..., m, on right of path, while poles of Γ(1 − ak + s), k = 1, 2, ..., n, on left. l loop beginning , ending @ +∞, encircling poles of Γ(bj − s), j = 1, 2, ..., m, once in negative direction, not encircling pole of Γ(1 − ak + s), k = 1, 2, ..., n. l loop beginning , ending @ −∞ , encircling poles of Γ(1 − ak + s), k = 1, 2, ..., n, once in positive direction, not encircling pole of Γ(bj − s), j = 1, 2, ..., m. how l , solve integral? way i'm used compute integrals on...

How to reference a model instance at a given point of time in rails? -

i creating two-sided rental platform, owner sets price product freely. whenever renter creates booking, need lock in snapshot of product model sensitive information pricing locked in rental. 1 thing tried storing every information again @ rental model, seems vulnerable future changes , updates. is there better way overcome problem? --- edit, make more specific --- so in products table: def change create_table :products |t| t.integer :hourly_rate t.integer :daily_rate end end and in rental_requests table, need have similar columns. def change create_table :rental_requests |t| t.integer :hourly_rate t.integer :daily_rate end end which may cause problems when have update columns in product, means have update both tables. your product can have many prices, , expose price method returns latest price. rental can belong price.