Posts

Showing posts from March, 2012

mysql - select columns dynamically based on list of column names obtained from -

i need simple select statement, based on list of column names dynamic , filtered lower case column names in table. table structure out of control , varies. not possible me know column names before hand - there upper case names (not wanted) , lower case names (wanted). the_table: col_uppercase_1 col_uppercase_2 col_lowercase_1 col_lowercase_2 data1 data2 data3 data4 data5 data6 data7 data8 i can list of column names want using this: select group_concat(column_name) `information_schema`.`columns` (`table_schema` = 'the_database' , `table_name` = 'the_table' , column_name = binary lower(column_name)); which returns list of columns want: +---------------------------------+ | group_concat(column_name) | +---------------------------------+ | col_lowercase_1,col_lowercase_2 | +---------------------------------+ my question: how insert results of query select statement? e.g. select <colum

android - HttpService - not able to play online videos -

i using httpservice send responses android devices , browsers share files. service works on android device. works fine exclude video files. listening online music works perfect. when try watch online video webservice fails error can see below: java.net.socketexception: sendto failed: epipe (broken pipe) @ libcore.io.iobridge.maybethrowaftersendto(iobridge.java:506) @ libcore.io.iobridge.sendto(iobridge.java:475) @ java.net.plainsocketimpl.write(plainsocketimpl.java:507) @ java.net.plainsocketimpl.access$100(plainsocketimpl.java:46) @ java.net.plainsocketimpl$plainsocketoutputstream.write(plainsocketimpl.java:269) @ org.apache.http.impl.io.abstractsessionoutputbuffer.write(abstractsessionoutputbuffer.java:109) @ org.apache.http.impl.io.contentlengthoutputstream.write(contentlengthoutputstream.java:113) @ org.apache.http.entity.fileentity.writeto(fileentity.java:83) @ org.apache.http.impl.entity.entityserializer.serialize(entityserializer.java:97) @ org.apache.http.impl.abstracth

ruby - How would I design this scenario in Twilio? -

i'm working on yrs 2013 project , use twilio. have twilio account set on $100 worth of funds on it. working on project uses external api , finds events near location , date. project written in ruby using sinatra (which going deployed heroku). i wondering whether guys guide me on how approach scenario: user texts number of twilio account (the message contain location , date data), process body of sms, , send results number asked them. i'm not sure start; example if twilio handle of task or use twilio's api , checking smss , returning results. thinking not using database. could guide me on how approach task? i need present project on friday; i'm on tight deadline! our help. they have great documentation on how of this. when receive text should parse format need put existing project , when returns event or events in area need check how long string due constraint twilio has of restricting messages 160 characters or less. ensure split message elega

mysql - SQL select first found value in 'in group' -

is possible select first row matched in list? table bar : column 'bar' values: value2, value3 select * `foo` `bar` in ('value','value2','value3'); it select value2 , returns. thanks in advance edit: the values expecting are: foo foobar foobarsome foobarsomething i determine based on length of strings need default value if nothing found. lets 'nothing' nothing bigger foobar , valid value. you can use case statement in order clause specify order based on column values. use can use limit select 1 row in result. select * foo bar in ('value','value1','value2') order case bar when 'value' 1 when 'value1' 2 when 'value2' 3 else 100 end limit 1; i tested example on sql fiddle . update: original poster edited question , added wants sort on string length , have default value of 'nothing' returned if there no results. select * foo bar in ('value','va

c# - Modified Data Table -

for example have table employeename empoyeeid john mark 60001 bent ting 60002 don park 60003 how can show employeeid have leading asterisk in data table? sample: *60001 *60002 *60003 public datatable listofemployee() { dataset ds = null; sqldataadapter adapter; try { using (sqlconnection mydatabaseconnection = new sqlconnection(myconnectionstring.connectionstring)) { mydatabaseconnection.open(); using (sqlcommand mysqlcommand = new sqlcommand("select * employee", mydatabaseconnection)) { ds = new dataset(); adapter = new sqldataadapter(mysqlcommand); adapter.fill(ds, "users"); } } } catch (exception ex) { throw new exception(ex.message); } return ds.tables[0]; } i need show data

asp.net mvc - MVC3 Razor ViewBag.Model not making into the Page -

i have modified model system i've inherited, , reason viewbag.model not making page. i've reverted code before started tinkering, , still no luck. the call view follows: public virtual actionresult edit(long id) { var _news = _newsrepository.getnewsbyid(id); viewbag.model = automapper.mapper.map<news, newsmodel>(_news); viewbag.model.currentnewsimagefile = configsettings.hostdomainname + configsettings.newsimagebasepath + _news.image_file; return view(); } the view has following code: @model mymodels.models.newsmodel @{ bool iscreate = model == null || model.id == 0; viewbag.title = iscreate ? "add news" : "edit news"; } the problem "model" null in view code... have missed? missing fundamental here? when tracing through actionresult code, right until return view() debug inspector correctly shows model containing expect too. you need return view(themodel) . if don't pass model view() d

javascript - CKEditor Add new list plugin using UL tag -

i'm trying add new list plugin similar bulletedlist i've created new button i'm trying use ul tag pairs new button called arrowedlist bulletedlist button. the reason doing can add class (which know how do) can have 2 different buttons 1 applies default bullet list , other applies ul tags class. the basic question is: there way can add button uses ul same way bulletedlist without pairing buttons together? // register commands. editor.addcommand( 'numberedlist', new listcommand( 'numberedlist', 'ol' ) ); editor.addcommand( 'bulletedlist', new listcommand( 'bulletedlist', 'ul' ) ); editor.addcommand( 'arrowedlist', new listcommand( 'arrowedlist', 'ul' ) ); // register toolbar button. if ( editor.ui.addbutton ) { editor.ui.addbutton( 'numberedlist', { label: editor.lang.list.numberedlist, command: 

Count of patients department wise in SQL Server -

select distinct patient_ref_master.dept_id 'dept', patient_ref_master.male_femal 'gender', count(patient_ref_master.pat_id) 'count' patient_ref_master left join patient_master on patient_master.pat_code=patient_ref_master.pat_id (patient_ref_master.age > 16 , dbo.patient_master.pat_sex = 2 , patient_ref_master.creation_date = '2013/08/02') or (patient_ref_master.age > 16 , dbo.patient_master.pat_sex = 1 , patient_ref_master.creation_date = '2013/08/02') or (patient_ref_master.age >= 0 , patient_ref_master.age <= 16 , dbo.patient_master.pat_sex = 2 , patient_ref_master.creation_date = '2013/08/02') or (patient_ref_master.age >= 0 , patient_ref_master.age <= 16 , dbo.patient_master.pat_sex = 1 , patient_ref_master.creation_date = '2013/08/02') group patient_ref_master.male_femal, patient_ref_

c - WSA Connection refused even though the host is not present -

i'm writing code discover devices on network , part of it. i'm trying discover host establishing socket connection host on port 80. it connects on of hosts on port 80 devices listening on port 80. @ times connect function returns error wsaconnectionrefused there no web service running on host. it surprising see when try establish socket connection on invalid ip addresses wsaconnectionrefused instead of wsaetimedout . i googled , found out antivirus , firewall can cause problems , have disabled both on scanning machine no luck causing problem? i have posted code below: #ifndef unicode #define unicode #endif #define win32_lean_and_mean #include <winsock2.h> #include <ws2tcpip.h> #include <stdio.h> #pragma comment(lib, "ws2_32.lib") int main() { wsadata wsadata; int iresult = wsastartup(makeword(2, 2), &wsadata); if (iresult != no_error) { wprintf(l"wsastartup function failed error: %d\n", iresult); r

Read DigitalProductId Value From Windows Registry in Ruby -

so far have code require 'win32/registry' win32::registry::hkey_local_machine.open('software\microsoft\windows nt\currentversion',win32::registry::key_all_access) |reg| puts reg['digitalproductid'] end but doesn't allow me digitalproductid value. of values available of them not. currentversion currentbuild softwaretype currenttype installdate registeredorganization registeredowner systemroot installationtype editionid productname currentbuildnumber buildlab buildlabex buildguid csdbuildnumber pathname it because running on 64 bit machine. not identify key "digitalproductid" registry untill change tragetplatform x64 bit cpu. hope helps

Reduce TCP maximum segment size (MSS) in Linux on a socket -

in special application in our server needs update firmware of low-on-resource sensor/tracking devices encountered problem in data lost in remote devices (clients) receiving packets of new firmware. connection tcp/ip on gprs network. devices use sim900 gsm chip network interface. the problems possibly come because of device receiving data. tried reducing traffic sending packages more error still occured. we contacted local retailer of sim900 chip responsible giving technical support , possibly contacting chinese manufacturer (simcom) of chip. said @ first should try reduce tcp mss (maximum segment size) of our connection. in our server did following: static int create_master_socket(unsigned short master_port) { static struct sockaddr_in master_address; int master_socket = socket(af_inet,sock_stream,0); if(!master_socket) { perror("socket"); throw runtime_error("failed create master socket."); } int tr=1; i

java - Communication between different Jar's/Classloaders -

i've got following problem solve: there 2 jar files. these jar's start independently each other. now, let's first jar a.jar calculates or computes , has commit results b.jar . i tried communicate via central singleton (enum singleton , singleton uses own classloader mentioned here: singleton class several different classloaders ). but didn't seem work me. when start 2 jar's hashcode of instances different. can tell me i'm doing wrong? or other ideas how solve problem? there 2 jar files. these jar's start independently each other. so they're separate processes . won't share instances of classes, variables etc. need form of inter-process communication communicate between them. that mean form of network protocol (e.g. tcp/udp sockets, http etc.). simple reading/writing shared file (that's not particularly nice, straightforward simple cases)

java - How to handle categories inside properties file? -

there new process implement involves writing , reading excel file. this, process needs properties define sheets , cells use write/read values. there fixed number of properties use based on category. show example: category1.sheet1=customer info category1.cell1=a10 category1.cell2=b10 category1.cell3=a20 category2.sheet1=customer data category2.cell1=a20 category2.cell2=b20 category2.cell3=a25 //more categories... in process, @ step, decide category i'm using , must consume properties category only. how load properties single category? currently, have approach (code simplified better understanding): //get category1 or category2 based on rules... string category = getcurrentcategory(); //define name of properties use string sheet1 = category + "sheet1"; string cell1 = category + "cell1"; string cell2 = category + "cell2"; string cell3 = category + "cell3"; //use properties... string sheet1value = getproperty(sheet1); string cell1va

iphone - UITextView Autocomplete modification -

i'm using htautocompletetextfield fill in uitextfield predefined list, should user start typing in entry exists. there couple of problems i've been having however. first seems stop when comma typed in (but not apostrophes). i've been looking around , i'm not sure why it's doing it. thought @ 1 point comma different comma, apostrophe issue had due importing list word document. however, wasn't case. second issue more of addition i'm not sure how implement. want autosuggest detect suggestions words in mid string, not beginning. instance typing in "string" suggest "this string". how auto suggest, have no idea how above things. nsstring *prefixlastcomponent = [componentsstring.lastobject stringbytrimmingcharactersinset:space]; if (ignorecase) { stringtolookfor = [prefixlastcomponent lowercasestring]; } else { stringtolookfor = prefixlastcomponent; } (nsstring *stringfromreference in coloraut

Custom exceptions with kwargs (Python) -

is safe? class specialalert(exception): def __init__(self, message, **kwargs): exception.__init__(self, message) kw in kwargs: if kw == 'message': continue setattr(self, kw, kwargs[kw]) related to: proper way declare custom exceptions in modern python? butt.. safe? mean i'm overriding attributes of self? in specialalert want pass kinds of things (this exception done doing long series of different checks, "try..except specialalert error" in loop , details out of error in handlers) i have basic check if i'm not overriding "message", should skip setting other attrs on self too? they? this work fine; it's cromulent put additional attributes on object. however, rather checking standard attributes don't want clobber, call exception.__init__ last, , let clobber yours if accidentally set them. __init__() can be: def __init__(self, message, **kwargs): self.__d

wordpress - Combining tags and categories -

i have set custom post type custom tags , categories. i want show posts country , category , categories need common countries. if user chooses country drop down (or something) categories of country should listed. south africa - sport -- golf --- irons one option make countries parent categories unique child categories each country. complicated , show looooong lists of duplicated category names in post editor. not smart way you'll agree. the other option thought using tags , categories together, countries added tags , categories common. question how make dynamic list of countries display categories particular tag/country? is there maybe simpler/better option can suggest? edit @mike this. route have been playing since posting q, kind of. have set custom post type custom hierarchical taxonomy called product categories , custom non-hierarchical taxonomy (tags) called countries. created new archive template displays tagged posts. @ moment displays tagged

java - Does the DispatcherServlet creates new instance of controller and methods inside for each user? -

good day folks. have controller in application: @controller public class loginsearchcontroller { //list store data resulthtml method list<cars> listcars = null; @autowired private educationwebserviceinterface educationwebservice; //this method render jsp page user , create model resulthtml @requestmapping(value="/search", method=requestmethod.get) public string search(formbackingobjectsearch fbos, model model) { model.addattribute("fbosattributes", fbos); return "search"; } // method name form form object , use fetchcarsbynameservice method // after if found stores in listofserchobjects , after listofserchobjects stores in listform list @requestmapping(value="/result", method=requestmethod.get)

PHP GD watermark script produces blank watermark -

Image
i'm trying add watermark images right after uploading them website, seems watermark keeps coming out black object no details. believe script working little bit because if wasn't, wouldn't see kind of watermark or script fail. this script far: $watermark = imagecreatefrompng('preview-watermark.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($portfolio_preview_dir.'/'.$file); $size = getimagesize($portfolio_preview_dir.'/'.$file); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); imagejpeg($image, $portfolio_preview_dir.'/'.$file); imagedestroy($image); imagedestroy($watermark); this it's producing. shape of watermark correct, waterm

malloc - Vxworks getting stuck in memory routines -

i'm running vxworks 6.3 , have run problem. have series of tasks running in rtp. create task, stuff destroy task. create 2 tasks, close together, stuff , destroy them. these tasks have crazy things like, malloc , free memory. unfortunately, if enough times, 1 of tasks stuck in memory (both malloc , free) routines on semaphore. it's second task gets "lost" @ start of task in either free or malloc. after failure, can still create tasks , can still malloc memory. failing task sits forever, waiting semaphore... semaphore other tasks must using. does have idea how task can stuck in memory routines? 0x08265e58 malloc +0x2c : 0x082416f4 () 0x08267e50 mempartalloc +0x28 : 0x08241734 () 0x08267e0c mempartalignedalloc+0x70 : 0x08267c04 () 0x08267c7c mempartfree +0xfc : 0x08240654 () 0x082753c0 semtake +0x90 : 0x08242534 () 0x082752ec semumtake +0xd8 : 0x08242514 () ---- system call boundary ---- -> tw 0x69d21b0 name entry tid

mvvmcross - UITextField binding to a decimal. Can I automatically turn empty string to zero -

i have standard binding set in android on uitextview local:mvxbind="text quantity" where quantity int property. if enter 123 say, gets assigned , setter called. delete text, 123 -> 12 -> 1 -> empty string, setter called each number not empty string infact following exception occurs: mvxbind:error: 48.84 setvalue failed exception - formatexception: input string not in correct format is there way of automatically converting empty string value 0 in binding? need value converter this? in fact bug? thanks in advance. this area has been discussed in https://github.com/slodge/mvvmcross/issues/350 nullable additions in https://github.com/slodge/mvvmcross/issues/373 - people welcome contribute opinions (and/or code) there. the current 'status quo' mvvmcross parse , represent valid decimal numbers. however, if number isn't valid - eg if it's string.empty or set of non-numeric characters - mvvmcross won't interpret these 0 (shou

javascript - Missing scrollbar with jScrollPane -

i posted question focused on problem, nobody answered. re-post attention back. my old post can found here: link my js code: $(document).ready(function() { $('.con').load('views/startseite.html',function(){ $('.scroll').jscrollpane(); }); $('nav a').click(function(e) { e.preventdefault() var inc = $(this).attr('href').split('/').pop().split(".").shift(), href = "views/" + inc + ".html" $('.con').hide().load(href, function(){ $('.con').fadein('fast',function(){$('.scroll').jscrollpane();}); }) document.title = 'robert-richter.com | ' + firsttouppercase(inc) location.hash = inc return false; }); function firsttouppercase( str ) { return str.substr(0, 1).touppercase() + str.substr(1); } }); my css of scrollbox: .scroll { position: re

git - Why are files with CRLF not available to add to the index when normalizing? -

so i've been following instructions of various pages covering end of line normalization. .gitattributes contains following , has been committed. * text=auto core.autocrlf = input core.eol unset (defaults native) my objective normalize text files in repository contain lf's , future checkins same. what find files exist in working area (this after deleting working files , performing git reset --hard ) contain crlf not listed when perform "git status". i can checkout branch return branch , (this inconsistent) file listed ought committed. it gets more interesting... after commit files git notes converting crlf's lf's, checkout branch, checkout first branch again , whole new set of files listed via get status indicating have crlf's normalized lf's. why weren't these caught first time? it seems files, on checkout, leak through cr , not flagged needing committed (sometimes). am missing something? (or, rather, missing?) using git

javascript - Make a tiny arrow move left to right as user scrolls up and down page -

i'm looking incrementally move/slide small arrow shaped element left right user scrolls , down page. for example if scroll down 20px arrow moves right 5px , if scroll 40px arrow moves left 10px my site navigation use smooth scroll page jumps, arrow needs respond , position navigated menu heading(such default pixel location each nav link). can provide direction , best coding this? thanks .arrow { enter code here width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 5px solid #7ac943; position:relative; margin-top: -5px; margin-left: 41px; position: fixed; } .arrow:after { content:''; position:absolute; top:2px; left:-5px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 4px solid black; } this jquery code need $(window).scroll(function(){ $('.arrow').css('margin-left',$(this).scrolltop() / 4 + 'px'); });

json - Hibernate Relation cycle via Restful -

the code this: db: persons(id, name) phonenumbers(number, id_persons) fk id_person references persons(id) java code: package com.app.model; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.fetchtype; import javax.persistence.id; import javax.persistence.joincolumn; import javax.persistence.manytoone; import javax.persistence.table; import org.jboss.resteasy.annotations.providers.jaxb.jaxbconfig; @entity @table(name = "phonenumbers", catalog = "test") public class phonenumbers implements java.io.serializable { private static final long serialversionuid = -8122359598003938895l; private string number; private persons persons; public phonenumbers() { } public phonenumbers(string number) { this.number = number; } public phonenumbers(string number, persons persons) { this.number = number; this.persons = persons; } @id @column(name = "num

c# - StreamReader and Portable Class Library -

i writing configmanager class using portable class libraries. pcl supports streamreader , streamwriter classes want use, pcl version of classes not support passing in string during construction. pcl not support reader.close() , writer.close() . lastly doesn't support filestream class. so looking answer 1 of following questions: how can streamreader , streamwriter classes working in pcl? how can create new stream using pcl? what other alternitives have load , save files in pcl? use dispose() instead of close() (or wrap in using statement). we've hidden/removed close() in windows store apps , newer pcls, because same thing , people confused 1 call. consider using pcl storage cross platform file system access. here blog posts may want refer how approach platform-specific functionality in pcls: how make portable class libraries work you portable class library enlightenment / adaptation using target-specific code in portable library

Putting a message in an inbox (Django models) -

i have couple of models , little confused how create of associations. have profiles, events, messages, , inboxes. each profile has eventlist holds events. each message associated event too. each inbox associated profile , multiple messages. want is, whenever message object created, inserted inbox of every user holds event message associated in eventlist. providing models , view i'm writing: class profile(models.model): user = models.onetoonefield(user) name = models.charfield(max_length=50) eventlist = models.manytomanyfield(event, blank="true", null="true", related_name='event_set+') ownedevent = models.manytomanyfield(event, blank="true", null="true", related_name='owned_set') def __unicode__(self): return self.name class inbox(models.model): def __unicode__(self): return self.user.name user = models.onetoonefield(profile) message = models.manytomanyfield(message, bl

javascript - PHP Infinite scroll pulling random results? -

i have page returns 16 records table. as user scrolls bottom, pull 12 records table , append them previous results, problem results being duplicated, , not in correct order. js // ajax getentries.php var url = location.pathname; if(url.indexof('missing-people.php') > -1) { didscroll = false; $(window).scroll(function () { didscroll = true; }); setinterval(function () { if(didscroll) { didscroll = false; if(($(document).height() - $(window).height()) - $(window).scrolltop() < 100) { var number = $(".directory").children().length; $.ajax({ type: "post", url: "getentries.php", data: "count=" + number, success: function (results) { $('.directory').append(resul

testing - How do I convince Erlang's Common Test to spawn local nodes? -

i'd have common test spin local nodes run suites. end, i've got following spec file: {node, a, 'a@localhost'}. {logdir, [a,master], "../logs/"}. {init, [a], [{node_start, [{callback_module, slave} %% , {erl_flags, "-pa ../ebin/"} %% , {monitor_master, true} ]}]}. {suites, [a], "." , all}. which works okay : > erl -sname ct@localhost erlang r15b03 (erts-5.9.3) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] eshell v5.9.3 (abort ^g) (ct@localhost)1> ct_master:run("itest/lk.spec"). === master logdir === /users/blt/projects/us/troutwine/locker/logs === master logger process started === <0.41.0> node a@lo

c++ - Program crashes while destructor calls delete function -

i working large code , program crashes, when destructor called. specifying place, fails: application::~application() { ( int blockid=0; blockid< m_noblocks; blockid++ ) { if ( m_blocks[ blockid ] ) { delete m_blocks[ blockid ]; //error here m_blocks[ blockid ] = null; } if ( m_methods[ blockid ] ) { delete m_methods[ blockid ]; m_methods[ blockid ] = null; } } } the program crashes @ delete operation mentioned @ 'error here'. however, if comment line, program seems work fine. throw light, possible problem? edit: allocated in constructor using new . m_noblocks defined value , not specified here: application::application(){ m_blocks = new zfsblock*[m_noblocks]; m_methods = new zfsmethods*[m_noblocks]; ( int blockid=0; blockid< m_noblocks; blockid++ ) { m_methods[ blockid ] = null; m_blocks[ blockid ] = null; } } however, there actual assignment of m_methods , m_blocks insi

Is it possible to transfer data via rtmp? -

i building project requires constant connection server. there 2 major ways achieve this: ajax pull ajax push i have decide between pinging server (expensive) , maintaining keep-alive connections (firewalls block that.) i thinking live video streams. not keep-alive connections, nor frequent pings. is possible, send data, json strings through rtmp? it theoretically possible implement rtmp's amf3 , amf0 message types carry data. rtmp [wikipedia] the problem using protocol typically used streaming video might connection blocked or throttled service providers limit such protocols conserve bandwidth (and prevent employees watching internet videos @ work).

php - Is it possible to fill a table with values in column wise? -

is possible fill table values in column wise. example <?php echo "<table>"; ($j=0;$j<6;$j++) { echo "<tr>"; ($i=0;$i<6;$i++) { echo "<td>".$j.$i."</td>"; } echo "</tr>"; } echo "</table>"; ?> the output becomes 00 01 02 03 04 05 10 11 12 13 14 15 20 21 22 23 24 25 30 31 32 33 34 35 40 41 42 43 44 45 50 51 52 53 54 55 but wanted table 00 10 20 30 40 50 01 11 21 31 41 51 02 12 22 32 42 52 03 13 23 33 43 53 04 14 24 34 44 54 05 15 25 35 45 55 i came condition not changing values fill in table. (altering echo $j.$i $i.$j brings appearance wanted fill data in column wise). how become possible? without going details of js issues, php wrong (which should able see if looked @ html php generating): echo '<li value"'.$i.'" id="'.$i.'" onclick=loadxmldoc("&#

javascript - jquery toggle in a for loop using Jinga2 template -

i trying hide/show div within loop using jquery's toggle. when click button toggle, div slides out quick moment, hides again. when happens, toggle button seems disabled next click...then works again same problematic div display. used {{email.sender}} template value because when clicked on toggle button, items in list activated instead of one. below code inserted tab jquery (this part working). advice can give on this- <div id="email_received_list"> {% email in email_received_list %} <p> <input type="button" id="{{email.sender}}" value="show message"> {{email.sender}}: {{ email.subject }} </p> <script> $(document).ready(function(){ $('#{{email.sender}}').click(function() { $('.{{email.sender}}').slidetoggle('fast'); return false; }); }); </script>

ruby on rails - Before filter syntax difference -

what difference between these 2 clips of code? first clip labeled "this one:" , second clip labeled "and this:". (.rb) class reseller < activerecord::base attr_accessible :blah, :blah, :contact_email this one: before_save { |reseller| reseller.contact_email = contact_email.downcase } and this: before_save { contact_email.downcase } thank you the first sets value back persisted property (or @ least should; i'd double check). the second downcases , nothing result. if second read contact_email.downcase! should modify actual property. http://apidock.com/ruby/string/downcase http://apidock.com/ruby/string/downcase%21 the "bang" method follows ruby convention of naming destructive methods, e.g., methods alter underlying data, trailing ! . note: tadman points out, you'd need vet against ar tests make sure app still functions expected, since may bypass of ar's magic.

python - sqlalchemy map object which contains dicts -

i'm trying map object looks this: self.user = {lots of stuff in here} self.timestamp = date object self.coordinates = {lots of stuff in here} self.tweet = {lots of stuff in here} self.favourite = 0 self.retweet = 0 the non dictionaries seem simple map __tablename__ = 'tweet' id = column(integer, primary_key=true) timestamp = column(datetime) favourite = column(integer) retweet = column(integer) however have no idea how can map dictionary objects. idealy objects should proberly go there own tables obey 3rd normal form. have no idea begin. can point me in right direction? should turn these dictionaries there own objects , map them well? many thanks for storing dictionary objects, have several options: use text field, write dict via json.dumps(value) , read using json.loads(db_value) create own json type , suggested in thread: sqlalchemy json blob/text import jsonpickle import sqlalchemy.types types class jsontype(types.