Posts

Rails design of an online newspaper -- controllers -

i have started ruby on rails 3 project make online version of newspaper. front page has news headlines, sports headlines , life headlines. has headlines different sections of site. all stories stored in 1 table , photos in table. simple set up. trying dry can't seem avoid it. on index action page have sports stories , on sports action page have sports. my question should make different controller every category? or have main controller categories actions? ( doing now? ) i have single story controller takes querystring determine category. in other words, if go /stories/ you front page, lists (or portion of all) stories. if want sports go /stories/?category=sports and story controller filters list of stories (and presumably alters view headings, etc.) based on querystring.

Should I put all Android view attributes into the style? -

i've seen android devs promote form of declarative layout: <textview style="@style/my_textview_style" /> i.e. pretty attributes (including id) go style definition. makes shorter layout files, step far? what recommend goes in style definition, , should stay in layout, , why? i've started doing android dev year, have prior experience of development. issues important, "way" use tools, habits, more efficient. appreciate sharing views on works you, clarity, efficiency, maintainability, app reliability. i've pondered question , becomes more pertinent when dealing multiple device sizes , densities. putting information styles can limit use, when dealing landscape , portrait layouts. example landscape layout may in fact wholly different in composition require similar styles. in these cases helps use . notation ammend style differences, example. <mypage> <mypage.portrait> <mypage.landscape> see below information...

iphone - Correct format for loading vertex arrays from file -

Image
i've been banging head on keyboard past couple of weeks on this. i'm trying load array of floats (glfloat) , array of unsigned shorts (glushort) text file equivalent arrays in objective-c can render contained objects. i've got arrays loaded vector objects as vector<float> vertices; and vector<glushort> indices; but reason can't figure out why can't these render. here code rendering above: glvertexpointer(3, gl_float, sizeof(vertices[0])*6, &vertices[0]); glnormalpoitner(gl_float, sizeof(vertices[0])*6, &vertices[3]); gldrawelements(gl_triangles, sizeof(indices)/sizeof(indices[0]), gl_unsigned_short, indices); sample arrays below: vertices: (vx, vy, vz, nx, ny, nz) {10, 10, 0, 0, 0, 1, -10, 10, 0, 0, 0, 1, -10, -10, 0, 0, 0, 1, 10, -10, 0, 0, 0, 1}; indices: (v1, v2, v3) {0, 1, 2, 0, 2, 3}; the text file want load these arrays rendering looks this: 4 //number of vertices ###vertices### v 10 10 0 0 0 1 v -10 10 0 0 0 1 v -10...

ruby - Forwarding requests UDPSocket -

i have basic ruby program, listens on port (53), receives data , sends location (google dns server - 8.8.8.8). responses not going original destination, or i'm not forwarding them correctly. here code. nb i'm using eventmachine require 'rubygems' require 'eventmachine' module dnsserver def post_init puts 'connected' end def receive_data(data) # forward data conn = udpsocket.new conn.connect '8.8.8.8', 53 conn.send data, 0 conn.close p data.unpack("h*") end def unbind puts 'disconnected' end end em.run em.open_datagram_socket '0.0.0.0', 53, dnsserver end any thoughts why or tips debug, appreciated. the obvious problems are: udp comms connectionless, use 4 argument version of send instead of connect you're not receiving data socket talking 8.8.8.8 you're not sending data ( #send_data ) original c...

javascript - Lose the Ajax-SliderExtender after Page Refresh (F5) -

i'm using ajax sliderextender in updatepanel. set behaviorid , call $find('behavorid').add_valuechanged function in $document.ready. fine when press f5 , refresh page, lose slider in 1/3 (wtf) chance. if set var slider = $find('behavorid') , recognises slider null. i've run in chrome, ie8 , met same problems. any ideas? solutions? regards didn't find solution. used jquery slider instead.

Multiple magento stores on single domain -

i'm setting website has retail store , wholesalers store. products in each different not matter of adjusting pricing user types. need have wholesale section password protected available logged in users. i'm using module achieve works @ store level hence need 2 stores rather separate categories. my directory structure follows: www.mysite.com - wordpress install current cms pages , blog etc www.mysite.com/store - magento install i want www.mysite.com/store/retail & www.mysite.com/store/wholesale 2 shops. so question - firstly sound the right reasonable approach achieve this. secondly - still trying head around website/store/view system correct in need 1 website, , 2 stores view each. know of tutorial doing sort of setup, i've found few they're setting different domains same install. thanks advise. the simplest way (and used) give 2 stores store codes "retail" , "wholesale". done in admin menu system > manage stores . ...

How can I find missing or mismatched braces / parens in emacs? -

when code fails compile , tells me missing closed brace, there easy way find in emacs? for languages c, c++, , java, command check-parens check parens ( () ), brackets ( [] ), , braces ( {} ): m-x check-parens <ret> the point move bracketing character unmatched, , status line report problem. it's idea use in conjunction show-paren-mode others have said.