Posts

Showing posts from March, 2010

javascript - Accessing a previously fullfilled promise result in a promises chain -

this question has answer here: how access previous promise results in .then() chain? 15 answers what correct pattern, when coding promises, access data coming long before in chain of promises? for example: do_a.then(do_b).then(do_c).then(do_d).then(do_e_withthedatacomingfrom_a_and_c_onlywhen_d_issuccesfullycompleted) my current solution: passing along single json structure through chain, , let each step populate it. opinion that? i don't think there's 1 "correct" pattern this. solution sounds neat, however, it's bit tightly coupled. may work great situation, see few problems general pattern: participating steps need agree on structure of collector object. every step needs participate in @ least forwarding of object, can tedious if chain long , need previous data occurs sporadically. inflexible insertion of steps not written (c

tabbar - xcode title bar / collection view -

probably easy solution this, not sure how. i'm using colelction view tab bar. i'm unable drag navigation bar on view objects pannel, , selecting navigation bar properties pannel works, doesn't display in simulator mode. any thoughts? many thanks, again. well, 1 way achieve you're looking embed view controller or collection view controller contains collection within navigation controller (editor->embed in>navigation controller). then instead of linking controller collection directly tab bar, link navigation controller contains it.

What's the best way to generate random strings of a specific length in Python? -

for project, need method of creating thousands of random strings while keeping collisions low. i'm looking them 12 characters long , uppercase only. suggestions? code: from random import choice string import ascii_uppercase print(''.join(choice(ascii_uppercase) in range(12))) output: 5 examples: qpupzvvhunsn efjaczebyqeb qbqjjeeoytzy eojusueajeek qwrwliwdtdbd edit: if need digits, use digits constant instead of ascii_uppercase 1 string module. 3 examples: 229945986931 867348810313 618228923380

java - Progress bar on console using Log4J or LogBack -

i have console application prints output using log4j. useful can implement switch optionally show debug messages, though hidden default. this application has long running actions progress bar appropriate. what best way implement using either log4j or logback ? to write progress bar or sort of updating text console, end output \r (carriage return) instead of \n (new line) next line overwrites it. question goes more detail. f-ansi library enables generate nice-looking console output including overwriting previous line. but if set on using logging framework, not not possible, it's not want. chrism suggests, right way log progress log new line every percent done far. way, can see both program doing , how far along in context. what sounds want separate logging program's actual output (this idea, disregarding progress bar issue). use logging framework log information program's execution; things or debugging interested in. actual program's out

c# - Remove duplicates with conditions using ASP.NET Regex -

i searching remove duplicates in document using regex or similar; remove following: first line <important text /><important text />other random words i need remove duplicates of <some text/> , keep else remain is. text may or may not on multiple lines. it need work off of several different words use < > tags. edit: i not know words be. nested inside < > tags , not be. need remove duplicates repeat 1 after each other like: <text/><text/><words/><words/><words/> and output should be: <text/><words/> this regex search duplicate tags, (<.+?\/>)(?=\1) , , here regex 101 prove it .

c# 4.0 - Why don't ODataQueryOptions work for both sides of a 1..* relationship? -

i have 2 tables joined link table , exposed through odata / entity framework: users usergroup using ~/api/users, following [user] api controller action returns results: public ienumerable<user> get(odataqueryoptions<user> options) { var unitofwork = new atms.repository.unitofwork(_dbcontext); var users = options.applyto(unitofwork.repository<user>().queryable .include(u => u.usergroups) .orderby(order => order.username)) .cast<user>().tolist(); unitofwork.save(); // includes dispose() return users; } i am, however, unable apply odataqueryoptions following [usergroup] api controller action: public ienumerable<usergroup> get(odataqueryoptions<user> options) { var unitofwork = new atms.repository.unitofwork(_dbcontext);

c++ - SSE and AVX intrinsics mixture -

in addition sse-copy, avx-copy , std::copy performance . suppose need vectorize loop in following manner: 1) vectorize first loop-batch (which multiple 8) via avx. 2) split loop's remainder 2 batches. vectorize batch multiple of 4 via sse. 3) process residual batch of entire loop via serial routine. let's consider example of copying arrays: #include <immintrin.h> template<int length, int unroll_bound_avx = length & (~7), int unroll_tail_avx = length - unroll_bound_avx, int unroll_bound_sse = unroll_tail_avx & (~3), int unroll_tail_last = unroll_tail_avx - unroll_bound_sse> void simd_copy(float *src, float *dest) { auto src_ = src; auto dest_ = dest; //vectorize first part of loop via avx for(; src_!=src+unroll_bound_avx; src_+=8, dest_+=8) { __m256 buffer = _mm256_load_ps(src_); _mm256_store_ps(dest_, buffer); } //vectorize remainder part of loop via sse for(; sr

Visual Studio 2012 & Classic ASP indentation (Smart) -

Image
first of all, known issue in 2012 (worked fine in vs 2008) (although it’s not reported classic asp being old): http://connect.microsoft.com/visualstudio/feedback/details/766046/indentation-in-visual-studio-2012 ms have closed "not reproducible" bull! just explain issue, take following example: say cursor on line 60 after ") pressing enter there placing cursor @ 'a - should placing @ 'b ! now then, can force vs place cursor @ 'b changing indenting "smart" "block": unfortunately; "block" infuriating, i.e. pressing enter after writing if x = y then puts cursor @ same indentation level if instead of if + 1 my question: has managed "smart" indenting working in classic asp files, if - how? edit: here little video demonstrating problem (i type "???" every time cursor has moved wrong location) http://www.heavencore.co.uk/filehub/videos/tech/visualstudio2013_classicasp.mp4 try

report - Getting the affected rows when altering a table in mysql -

i need retrieve report of affected rows when table has been altered following commands: 1.- changing engine: alter table <table> engine=innodb; 2.- adding constraints: alter table nombre_tabla add primary key símbolo_clave_foránea; alter table nombre_tabla drop primary key símbolo_clave_foránea; alter table nombre_tabla add foreign key símbolo_clave_foránea; alter table nombre_tabla drop foreign key símbolo_clave_foránea; 3.- adding unique constraint. primary or unique key failure duplicates, if have nulls in there you'll need sort them first. e.g given mytable(keyfield int not null) then select keyfield mytable inner join (select keyfield,count() numberoftimes group keyfield) duplicates numberoftimes > 1 then you'll have come them. delete or rekey. foreign keys outer join query key null e.g given mytable (keyfield int not null, foreignkeyfield int not null) , mylookuptable(lookupkey int not null, description varchar(32) not null) t

java - How to directly write to a JSON object (ObjectNode) from ObjectMapper in Jackson JSON? -

i'm trying output json object in jackson json. however, couldn't json object using following code. public class myclass { private objectnode jsonobj; public objectnode getjson() { objectmapper mapper = new objectmapper(); // code generate object user... mapper.writevalue(new file("result.json"), user); jsonobj = mapper.createobjectnode(); return jsonobj; } } after program runs, file result.json contains correct json data. however, jsonobj empty ( jsonobj={} ). looked javadoc of objectmapper couldn't find easy way write objectnode (json object in jackson). there no method in objectmapper following: public void writevalue(objectnode json, object value) how write objectnode directly objectmapper ? you need make use of objectmapper#valuetotree() instead. this construct equivalent json tree representation. functionally same if serializing va

meteor - Publications Subscriptions Observe -

i working on project want show markers on map. these markers should published server viewport-constraint. means markers published inside current users viewport. the publication looks this: //server meteor.publish('posts', function(bottom_left_x, bottom_left_y, upper_right_x, upper_right_y, limit) { return posts.find({locs: {$geowithin: {$box: [[bottom_left_x, bottom_left_y], [upper_right_x, upper_right_y]]}}}, {sort: {submitted: -1}, limit: limit}); }); i call function via subscription when map_center changes: //client google.maps.event.addlistener(map, 'idle', function(event) { var bounds = map.getbounds(); var ne = bounds.getnortheast(); var sw = bounds.getsouthwest(); postshandle= meteor.subscribe('posts', sw.lat(), sw.lng(), ne.lat(), ne.lng(), 10); }); till works fine. further created observefunction on posts, renders marker when "add

c++ - Odd behavior with classes in separate files -

this question has answer here: when can use forward declaration? 12 answers i have classes this: world.h: #ifndef world_h_ #define world_h_ #include "gameobject.h" #include <vector> class world { public: std::vector<gameobject*> objects; world(); virtual ~world(); void add(gameobject*); void initialize(); void update(); void render(); }; #endif /* world_h_ */ gameobject.h: #ifndef gameobject_h_ #define gameobject_h_ #include "util/point.h" #include "world.h" class gameobject { public: world *world; point *position; gameobject(); virtual ~gameobject(); virtual void update(); virtual void render(); }; #endif /* gameobject_h_ */ why give error: "world.h, line 9 - 'gameobject' has not been declared " and "world.h, line 13 - 'gameobject' not declared in scope"? i using linu

animation - Pygame/Python. Left seems to move faster than right. Why? -

i've coded bit c++ , java during past few years , i've started python. goal make game. i've noticed, however, @ basic animation part of player moving left , right, left "speed" faster right "speed". although "speed" values same. the update function: def update(self,dt,game): last=self.rect.copy() self.time+=dt if self.left: self.rect.x-=300*dt if self.right: self.rect.x+=300*dt i've noticed if change left speed 250, instead of 300, run same. example if press both left , right keys player stay on exact same spot. if have left , right speed both @ 300. player move left. my game loop: while 1: dt=clock.tick(60) if dt>1000/60.0: dt=1000/60.0 event in pygame.event.get(): if event.type==pygame.quit: return if event.type==pygame.keydown , event.key==pygame.k_escape: return if event.type==pygame

node.js - Execute callback once every async tasks are finished in a forEach -

i'm writing postgresql transactions, , need execute callback once every function in foreach have been executed. here code : var sql = "begin;update object set name = "+data.name+", object_subtype_id = "+data.object_subtype_id+" id = "+data.id+";"; db.driver.execquery(sql, function(err, result) { data.object_subtype.object_property_type.foreach(function(item) { db.driver.execquery("with upsert (update object_property set value = '"+item.value+"' object_property_type_id = "+item.id+" , object_id = "+data.id+" returning *) insert object_property (object_property_type_id, object_id, value) select "+item.id+", "+data.id+", '"+item.value+"' not exists (select * upsert);", function(err, nb) { // need send commit; here once functions in foreach have been executed }); }); }); i had @ async i'm not sure how, or if can, apply situation.

javascript - Real Time mySQL, PHP Google Maps API Update -

i have android app sending gps coordinates in 1 sec. interval php , mysql on server. them have site location of device can tracked in real time on google maps. problem when call php script query new coordinates in mysql, runs perfect first time , gives me latest coordinates use on google maps, after first loop , keep on givimg me same value , if database has been updated. <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>horse tracker © 2013 abiapps</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link type="text/css" href="style.css" rel="stylesheet" media="all" /> <script type="text/javascript"src="http://maps.google.com/maps/api/js?********&sensor=false"></script> <script type="text/javascript" src="map.js"></script>

javascript - Adding Event Listener is not working in Chrome for audio tags -

i developing music application playing songs on browser using html5. after creating playlists wanted play songs 1 one. using eventlistener work done. code given below : document.getelementbyid('myplayer').addeventlistener('ended',function() { alert("hi"); }); here myplayer id of audio tag when 1 song completed wanted put next song on player. method not getting triggered unable see alert on screen when song ends. using google chrome v28 this. can me this.

css - How to make same website layout for mobile devices (not responsive) -

Image
i've tired finding answer of question. want website can seen same mobile or similar device. don't mean responsive rather mean, mobile visitor can see same layout of website horizontal mouse scrolling. possible every website. not need code that. same layout seen mobile horizontal mouse scrolling. but, i've troubled 1 scenario. i've built example. here it.. if see website mobile or similar device small notebook etc(or resizing small browser), you'll see this: you're seeing blue div can't able fill 100% width of browser though div defined 100% width! grey div below portion of images. @ normal stage both blue(div.top) , grey(div#gcontent) div center of browser @ small screen, grey div fill 100% width blue div has failed fill 100% width. what's reason. how can fix it? structure of it: <body> <!-- top start --> <div class="outer top"> <div class="inner"> <div class="nav

ios - Is NS_AVAILABLE_IOS undocumented API? -

i want use part of xcode documentation detects , adds part of document, i'm not sure if apple considers undocumented. it's not undocumented, it's defined in foundation.framework -> nsobjcruntime.h #define ns_available_ios(_ios) __osx_available_starting(__mac_na, __iphone_##_ios)

html - Why are my columns wrapping? -

i had quick question website taking design code. using simple grid layout few fixed-width columns, reason when browser wraps below 1500 pixels, columns start wrapping. i'm super confused why happening have width set on container , columns fixed-width. here link site on staging server: http://staging.slackrmedia.com/halfpast/ here link jsfiddle: http://jsfiddle.net/pafkw/ please note "external resources" located in jsfiddle here code: html: <body class="transition"> <div class="container center"> <header class="row"> <div class="col-1-3-fixed"> <nav> <ul class="inline text-left"> <li> <a href="">the chronique</a> </li> <li> <a href=&

javascript - Minifying for{} loops -

i've got javascript for {} loops use repeatedly throughout project, similar this: for (var = 0; < things.length; i++) { console.log(things[i]); // may different in different areas of project } i minified code, loops take lot of minified code. there way shorten above code this: loop { console.log(things[i]); // may different in different areas of project } probably not above, idea. appreciated :) a jquery-ish way that: function each(arr, func) { ( var = 0; < arr.length; ++i ) { func(arr[i]); } } can called like: each( things, function(thing) { console.log(thing); } ); or each( things, function(thing) { console.log(thing); alert(thing); } ); etc.

asp.net mvc - Adding two new elements to a List in Entity Framework -

in model, have following section class: public partial class section { public section() { steps = new list<sectionstep>(); } public int id { get; set; } public int sortid { get; set; } public string name { get; set; } public string title { get; set; } public string html { get; set; } public nullable<int> tutorial_id { get; set; } [jsonignore] public virtual tutorial tutorial { get; set; } public virtual icollection<sectionstep> steps { get; set; } [notmapped] public bool _destroy { get; set; } } and following sectionstep class: public class sectionstep { public int id { get; set; } public int sortid { get; set; } public string name { get; set; } public string title { get; set; } public string html { get; set; } [jsonignore] public virtual section section { get; set; } [notmapped] public bool _destroy { get; set; } } i have asp.net application in users c

cql - Inserting special characters in Cassandra -

hi trying insert following text cassandra using cql (cqlsh 3.0.2 | cassandra 1.2.5) insert "mediacategory" ("mcategoryid", "submcategoryname", "photorankid", "virtualtourid", "langid") values (14,'vue depuis l'hôtel',92002,192002, 1036); but when try doing error saying invalid syntax .basically unable unsert has "l'" you can use double ' (i.e., '' ) represent ' in cql. example: insert text_table (text_data) values ('vue depuis l''hôtel');

c# - Sort a Custom DataGridColumn in WPF -

i have custom datagridcolumn created facilitate animation. before updated column column sortable (provided framework), mark-up below <controls:resourcedatagrid x:name="resourcedatagrid" horizontalalignment="stretch" verticalalignment="stretch" autogeneratecolumns="false" gridlinesvisibility="none" rowheaderwidth="0" canuseraddrows="true" canuserdeleterows="true" itemssource="{binding path=resources, mode=twoway, updatesourcetrigger=propertychanged, isasync=true}" dataaccess:datagrid

java - How to set Eclipse code formatter to support fluent interfaces -

Image
this question has answer here: how indent fluent interface pattern “correctly” eclipse? 1 answer i've started working api uses " fluent interface ". i'm struggling find how configure eclipse code formatter support properly. what want this: foo myfoo = new foo() .setthis() .setthat() .settheother() .setonemorething(); but can't hit on right settings: end this: foo myfoo = new foo().setthis().setthat() .settheother().setonemorething(); which near readable. has solved this? sorry: turns out near-duplicate of this: how indent fluent interface pattern "correctly" eclipse? here's answer worked me: the place set on "line wrapping" tab of code formatting preferences page, in "qualified invocations" section

python - Substracting the last element form a list of lists -

i need subtract last element , buid vector [1,1,1,...] . have function: def vectores(lista): r=[] e in lista: r.append(e[2]) return r where lista = [['pintor', 'ncms000', 1], ['ser', 'vsis3s0', 1], ['muralista', 'aq0cs0', 1], ['diego_rivera', 'np00000', 1], ['frida_kahlo', 'np00000', 1], ['caso', 'ncms000', 1]] but function returning [1] ; can do? you're returning on first iteration of loop. move return statement outside for -loop: def vectores(lista): r=[] e in lista: r.append(e[2]) return r # here or use list comprehension: def vectores(lista): return [e[2] e in lista]

garbage collection - java.lang.OutOfMemoryError: GC overhead limit -

i have program reads large list of sequences file , calculation among of pairs in list. stores of these calculations hashset. when running program halfway through, gc overhead limit error. i realize because garbage collector using 98% of computation time , unable recover 2% of heap. here code have: arraylist<string> c = loadsequences("file.txt"); // loads 60 char dna sequences hashset<dnapair,double> lsa = new hashset<dnapair,double>(); for(int = 0; < c.size(); i++) { for(int j = i+1; j < c.size(); j++) { lsa.put(new dnapair(c.get(i),c.get(j)),localseqalignmentsimilarity(c.get(i),c.get(j))); } } and here's code actual method: public static double localseqalignmentsimilarity(string s1, string s2) { s1 = " " + s1; s2 = " " + s2; int max = 0,h = 0,maxi = 0,maxj = 0; int[][] score = new int[61][61]; int[][] pointers = new int[61][61]; for(int = 1; < s1.length(); i++) {

android - DISTINCT values with ", " divider in GROUP_CONCAT -

group_concat(g_value,", ") this gives me values [comma]+[space] divider apple, orange, banana, apple, apple group_concat(distinct g_value) this gives me distinct values "," divider without space. apple,orange,banana how distinct values ", " divider? apple, orange, banana correct syntax is group_concat( distinct g_value separator ', ')

java - Getting cookie value or getting data from DB? -

which of these operations require more time , resources? getting cookie value or getting data db? they both serve different purpose. cookies used store preferences , disposable in sense if aren't available (like client deleted them) preferences switch defaults. database on other hand store data should persist through-out application's life. example, user login data. can't save cookies security reasons may lose them time. cookies can save text whereas can practically save in database binary objects. any preferences saved cookies take effect if user uses same browser cookies stored on. so, databases more suited preferences should mobile.

database - Re-using rails db :id's -

can re-use rails database record's :id if record deleted? for instance, if have 5 records id's 1-5 , delete items 2 , 4 database, activerecord use id's again? if so, automatic, or need tell activerecord this? in advance! the id generation typically function of database using. sql based databases not able configured reuse id's this, incur huge performance penalty. activerecord doesn't have configuration perform type of behavior, need implement custom query find lowest id doesn't exist, or have other method of managing freed ids. it depends on needs, easiest never reuse id's.

objective c - ios make navigation bar clickable -

just trying make navigationbar of navigationcontroller clickable. works uitapgesturerecognizer* taprecon = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(togglemenu)]; taprecon.delegate = self; taprecon.numberoftapsrequired = 1; [self.navigationbar addgesturerecognizer:taprecon]; but when have button, impossible click on (the gesture might take on button). so, tried found here : - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldreceivetouch:(uitouch *)touch { return (![[[touch view] class] issubclassofclass:[uibutton class]]); } and nothing, because [touch view] alway uinavigationbar... last thing tried setting cancelstouchesinview no . it's ok, can click on button, togglemenu action of uitapgesturerecognizer still called. do have idea make button works again, not calling togglemenu @ same time ? thanks ! edit : juste found how : - (bool)gesturerecognizer:(uigesturere

smarty - reformat date that is pulled from database table -

i have website uses smarty templates. i have table in db called posts has various columns, 1 being " date_added ". managed have displayed on posts editing 1 of smarty templates " posts " however, date format yyyy-mm-d d. is there easy way me change this? perhaps jquery? ideally, want show abbreviated month , day positioned next it. blog style post, isn't wordpress. right smartytemplate shows date_added reads this: {$posts[i].date_added|stripslashes|nl2br} where posts table , date_added column in table. an exact example can seen here in top right corner of each post. http://www.elegantthemes.com/preview/lightbright/ does have suggestion of how can achieve desired request? if looking javascript solution, can take @ incredible js library momentjs. lightweight , numerous date , time formats. http://momentjs.com/ just include minified script file in html . for exact case, use momentjs such: first create momentjs date object:

php - base_url doesn't work in external js and css file -

i trying call " base_url() " inside of external .js file. ' test.js ' file path " js/test.js ". my test.js code was: function download(s){ var w=window.open('<?php base_url(); ?>home/download?f='+s+'.ogg','download','height=100,width=100'); } and linked file(my js file working fine when trying simple javascript codes) : <script src="<?php echo base_url(); ?>js/test.js" type="text/javascript"></script> but said access denied , asked server permission. i tried ' site_url() ' too, tried echo " hello " in ' download ' function didn't work. when add code inside of header.php view file like: <script type="text/javascript"> function download(s){ var w=window.open('<?php base_url(); ?>home/download?f='+s+'.ogg','download','height=100,width=100'); } </scr

sql - How to select different percentages of data based in a column value? -

i need query table have "gender" column, so: | id | gender | name | ------------------------- | 1 | m | michael | ------------------------- | 2 | f | hanna | ------------------------- | 3 | m | louie | ------------------------- and need extract first n results have, example 80% males , 20% females. so, if needed 1000 results want retrieve 800 males , 200 females. is possible in single query? how? if don't have enough records (imagine have 700 males on example above) possible select 700 / 300 automatically? basically, want many 'm' can, not more percentage , enough 'f' have total 1000 rows: with cte_m ( select * table1 gender = 'm' limit (1000 * 0.8) ), cte ( select *, 0 ord cte_m union select *, 1 ord table1 gender = 'f' order ord limit 1000 ) select id, gender, name cte sql fiddle demo

Fedex WSDL C# - Setting the Invoice # value -

Image
i'm using fedex's wsdl in c# generate cod shipping labels. on fedex shipping labels there "invoice #" string on both shipping label , cod return label. want set orderid in request fedex such orderid shows invoice #. it's not obvious me how set invoice # in fedex's wsdl request. has done this? the way in place order id or invoice number in labels following: set invoice number in package customer reference. specify on cod details node (on reference indicator) want cod label include invoice number 1 of reference. please, note can include other references invoice number (e.g.: po, customer reference, , tracking). here sample soap envelope request depicting said before: <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"&

css - Font awesome selector color -

Image
i wondering if possible change selector color of font awesome icon i know possible change of except font awesome using code ::selection{ background: #ffb7b7 !important; /* safari */ } ::-moz-selection { background: #ffb7b7; /* firefox */ } i tested following: .icon-2x::selection { background: #ffb7b7 !important; } i::selection { background: #ffb7b7 !important; } the problem appears font-awesome css injects icon using ::before pseudo-element, , browsers seem fail select that. note if there line-break before icon , select previous line too, works (sort of). a workaround add character directly on markup (in case, it's &#61459; ). demo . if course work on elements font-family: fontawesome (the font awesome css adds elements class icon-[something] ).

python - Comparing sub items from a list of lists -

i,ve 2 lists: l = [['red','a1',1],['red','a2',1],['blue','a3',1],['yellow','a4',1]] and k = [['red','a2',1],['blue','a3',1],['yellow','a4',1]] so want return this: result = [0, 1, 1, 1] sorry i´ve practice list comprehension little more!! my function: def vectors(doc1,doc2,consulta): res=[] r = doc1 + doc2 + consulta e in r: in doc1: if i[0] == e[0]: i[2] = i[2] + 1 else: i[2] = 0 return res.append(i[2]) the order doesn´t matter, important thing comparison. best regards! inefficient easy: result = [x in k x in l] efficient (for large k ) more complicated: kset = set(tuple(x) x in k) result = [tuple(x) in kset x in l]

My blogspot main page shows only 3 post -

Image
i want show 12 posts on each page show 3 posts. have change number of post on main page in blog post widget isn't working, blog show 3 post in main page, blog: http://onepiece-data.blogspot.com/ . you need change default settings. go blogger >> blog >> layout >> 'blog posts' , click on 'edit' change number want.

ruby on rails - Ancestry Gem saves all threaded messages as Parent -

currently implementing threaded messaging. via railscast i've installed ancestry gem, messages create parents. ie.) ancestry = nil even after passing parent:id new action message controller def index @message = message.new @user = current_user @sent_messages = current_user.sent_messages @received_messages = current_user.received_messages end def new @message = message.new @message.parent_id = params[:parent_id] end index.html <% incoming in @received_messages %> <%= render partial: "message", locals: {incoming: incoming} %> _message.html.erb </div> <%= link_to "reply", new_message_path(:parent_id => incoming) ,class: "regular" %> </div> new.html.erb <%= form_for @message |f| %> <p> to:<br /> <%= f.hidden_field :parent_id %> <%= f.hidden_field :recipient, :value => (@message.parent.sender.name) %> </p> <p> me

Project Euler #4 in C# -

i'm attempting project euler problem #4 in c#. problem i'm having when code runs console window briefly appears , goes away. don't know problem i'm relatively new programming. using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace consoleapplication1 { class program { static void main(string[] args) { (int = 1000; > 100; i--) (int j = 1000; j > 100; j--) palcheck(i * j); } static void palcheck(int original) { var reversed = new string(convert.tostring(original).tochararray().reverse().toarray()); if (convert.tostring(original) == reversed) console.writeline(original); console.readkey(); } } } the code seems stuck @ line console.readkey() @ line of code, program waiting input key. since have not used message before read

linux - Segmentation fault happens when accessing array in a fortran program -

i have fortran program. subroutine below.the program gives segmentation fault after executing line 1434 , printing below: i: 115 256 2 segmentation fault (core dumped) the parameters n1=258, n2=258, , n3=258. nr=46480. why segmentation fault happen? 75 double precision u(nr),v(nv),r(nr),a(0:3),c(0:3) 76 common /noautom/ u,v,r ...... 196 call zero3(u,n1,n2,n3) ...... 1418 subroutine zero3(z,n1,n2,n3) 1419 1420 c--------------------------------------------------------------------- 1421 c--------------------------------------------------------------------- 1422 1423 implicit none 1424 1425 1426 integer n1, n2, n3 1427 double precision z(n1,n2,n3) 1428 integer i1, i2, i3 1429 1430 !$omp parallel default(shared) private(i1,i2,i3) 1431 i3=1,n3 1432 i2=1,n2 1433 i1=1,n1 1434 print*,"i: ",i1, " ", i2 , " " ,i3 1435