Posts

Showing posts from May, 2015

how to display the content of session[:intented_url] using rails 4 -

i want display page user logging in ... a user has login before viewing pages. if not, user redirected login. @ point want display name of page want go , view once logged in. in session controller, under create def - created following instant variable: @intended_url = session::get('url.intended', url('/')); and view page contains following: <h4>sign in go <%= @intended_url %>. unfortunately, nothing showing up? if want store in session, must in controller has access it. means setting session takes place in controller page. by session[:page_name = @intended_id then can retrieve with display ------> session[:page_name] your problem can solved instead calling controller page. controller.controller_action this displays controllers action name if follow ruby on rails design page name.

shell - How to validate a file format -

i wrote shell script. got error message line 14 , 18, not see wrong. script supposed analyze each file of *.fq . if first 3 characters of given file not match "hwi" script reply "invalide format", if match script give me number of "hwi" lines in file. !/bin/sh f in *.fq a="$(head -n1 $f)" c="$(expr substr $a 2 3)" echo $c nr="$(grep -w "hwi" $f | wc -l) if [ "$c"="hwi" ] ; echo $f | "the number of read of $f $nr" else echo"invalide format" fi done can explain errors are? there several syntax issues in script, can use tool http://www.shellcheck.net/ detect mistakes. after indenting code, here more correct (not perfect) version of wrote: for f in *.fq a=$(head -n1 "$f") c=$(expr substr "$a" 2 3) echo "$c" nr=$(grep -w "hwi" "$f" | wc -l) if [ "$c" == "hwi" ];

python - Is there a built-in method to plot symmetric functions? -

i'm plotting symmetric function (odd/even), have like: plt.plot(np.concatenate([-x[::-1],x]),np.concatenate([y[::-1],y])) is there easier way this, have waste less memory? why not plot 2 lines: def plot_odd(x,y, *args, **kwargs): plt.plot(x,y,*args,**kwargs) plt.plot(-x[::-1], -y[::-1], *args, **kwargs) def plot_even(x,y, *args, **kwargs): plt.plot(x,y,*args,**kwargs) plt.plot(-x[::-1], y[::-1], *args, **kwargs) x = np.linspace(0,6,100) plot_odd(x, np.sin(x), 'b') plot_even(x, np.cos(x), 'r') plt.show()

css - How to get rid of text form borders in Chrome and Firefox? -

i have created text forms in html , css , appear working fine in safari, in firefox , chrome have looks 1 2px white border around them. default browser styling? how rid of it? here css reference.... .forms input[type="text"] { display:block; margin: 0 auto; margin-bottom: 10px; background-color:#3a3a3a; color: white; padding-right:30px; font-family:inherit; text-transform:uppercase; font-size:14px; height:50px; width:540px; } .shortforms input[type="text"] { display:inline-block; margin: 0 auto; margin-bottom: 10px; background-color:#3a3a3a; color: white; font-family:inherit; text-transform:uppercase; font-size:14px; height:50px; width:242px; } it page black background , text fields light shade of grey white placeholder text. thanks in advance help! try adding fieldset { border: 0px; } to css.

java - Can't Delete local File - Error "Is a Directory" -

i have searched vast internet no success. writing file , trying delete it. code has commented out statements have tested writing file contents both simple string, works. however, when try make create file edittext (casted string) has error. don't understand. someone please me issue. when press delete button, error comes up: 04-14 11:40:38.086 24584-24584/com.test.dev.write_delete_local_file e/exception﹕ file write failed: java.io.filenotfoundexception: /data/data/com.test.dev.write_delete_local_file/files: open failed: eisdir (is directory) mainactivity.java: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); editname = (edittext)findviewbyid(r.id.nameedit); editcontent = (edittext)findviewbyid(r.id.contentedit); btnwrite = (button)findviewbyid(r.id.btnwrite); btndelete = (button)findviewbyid(r.id.btndelete); filecontents = (string) editcontent.gettex

npm - Error: EACCES, open '/build/bundle.js' when running webpack -

unable run webpack subdirectory in project. error i'm getting: error: eacces, open '/build/bundle.js' and webpack configuration file: module.exports = { entry: ['./app.ts'], output: { filename: 'bundle.js', path: '/build' }, resolve: { extensions: ['', '.ts', '.js' ] }, devtool: 'source-map', module: { loaders: [ { test: /\.ts$/, loader: 'ts?sourcemap!ts-jsx' } ] } }; trying use command: 'sudo chown -r whoami ~/.npm' didn't help. a late answer, looks you're trying build in root of system ( /build ). older versions of webpack use ./build on property path . latest version of webpack (3.0 today) path: path.resolve(__dirname, 'dist'), should work.

vba - Remove the "same as the whole table" property from Outlook table -

Image
i've got following code "codeize" block of code in outlook message: on error goto catch dim oselection word.selection set oselection = application.activeinspector.currentitem.getinspector.wordeditor.application.selection oselection .font .name = "courier new" '.color = 10027008 '13369344 .size = 10 end end dim otable word.table set otable = oselection.converttotable(, 1, 1) otable .borders.outsidelinestyle = wdlinestyledot .shading.backgroundpatterncolor = wdcolorgray05 .toppadding = inchestopoints(0.1) .bottompadding = inchestopoints(0.1) .leftpadding = inchestopoints(0.2) .rightpadding = inchestopoints(0.05) end works great, think i cannot margins work because i'm missing whatever removes "same whole table" property . after code runs, table properties looks this: perhaps i'm setting margins wrong, , automatically go away? missing? word provides macro rec

visual c++ - C++ - trying to point each sub-class to the main class in order to contain all information in a vector -

basically, im writing small database/inventory system game. item class , sub-classes (weapon, armor, consumable, etc) , working. vector inventory written within separate inventory class (allows more 1 inventory - i.e. enemies can have them too!) , @ point, inventory far written - there still no drop function, etc. but im taking 1 step @ time because learning experience. basically believe in case, pointers answer. code seems work (have not tried yet) weapon debugdagger{ 1, "debug dagger", "debug dagger given help", 25 }; armor datacloak{ 2, "data cloak", "data cloak given help", 10 }; item *pitem = &debugdagger; weapon *pweapon = &debugdagger; inventorymanager playerinv; playerinv.pickupitem(pweapon);` in case, pickupitem(item*) taking static item type - base class function, weapon being added inventory sub-class ( class weapon : public item{} ) the way written seems hack solution, easier if write pointer class functions eac

cuda - Cholesky factorization in cublas -

i new cuda programming. want perform cholesky factorization small matrics(8*8) .is there algorithm using cublas batch functions cuda version-6.5 thank your matrix sizes small see benefit gpu. however, new cuda 7 version provides cusolver module ( http://docs.nvidia.com/cuda/cusolver/index.html ) can ask. suggest looking up. also, consider sticking cpu , eigen library.

mysql - SQL Replace Other Column -

i've got joomla database need replace entries in "created_by" column new user id, replacement based on entries in "created_by_alias" column. ╔════════════╦══════════════╗ ║ created_by            ║ created_by_alias        ║ ╠════════════╬══════════════╣ ║ 62                            ║ bob dole                      ║ ║ 62                            ║ bill clinton                    ║ ║ 62                            ║ bob dole                      ║ ║ 62                            ║ hillary clinton              ║ ╚════════════╩══════════════╝ so, need created_by replaced 1500 when "created_by_alias" bob dole; 1550 when "created_by_alias" bill clinton; 1600 when "created_by_alias" hillary clinton. i have come following query isn't working: update candidates set created_by = 1500 created_by_alias (select * candidates created_by_alias 'bob dole') i err

python - scrapy: post some forms following scrapy finishing processing urls -

i using scrapy scrape data member's site. perform login , scrape data successfully. however, need submit forms on site when scraping of data finished. i.e: following reading of data, want write data site scraping (reading) data from. my question is: how informed of scrapy finished processing url scraping, can perform form submissions? i noticed solution - see here ( scrapy: call function when spider quits ) reason cannot continue yielding more requests in self.spider_closed method called on over examples can write operations. yes, cannot continue using spider after spider_closed signal has been fired - late, spider closed @ moment. a better signal use spider_idle : sent when spider has gone idle, means spider has no further: requests waiting downloaded requests scheduled items being processed in item pipeline

python 2.7 - My program jumps straight to else in a long string of if/elif/else and won't do its job -

this 1st segment of decoding script(in sense, same except 3 characters , there several hundred more) , not find proper character. #only 1 i'll comment, same except in converted character. if(str(fin.readline().rstrip('\n')) == "2a"):#if read string *without newlines* found on current line, convert it. converted = "a"#decoded character. fout.write(converted)#write memory loop = loop - 1#decrease characters left print str(loop) + " characters decode!"#useful information output. time.sleep(0.1024)#slow down program! fout.flush()#save output. here encoded file: 17 f4 f5 dd fc ed fe ef ff f1 f4 f3 fc f1 ed ec ff f4 first line here number of encoded characters. here's original... klzsdufvhkjshdcvk here's else , end of while loop: else: exit() fout.close() fin.close() print "exiting..." time.sleep(3.2374657902634905457908694752367895682347956923489756

oracle - How to add Devarts dotConnect provider to Entity Framework? -

i'm trying follow devarts tutorial of entity framework: http://www.devart.com/dotconnect/oracle/articles/tutorial_ef.html but when try create connection of entity data model, cant find dotconnect provider. i add text in .config file <provider invariantname="devart.data.oracle" type="devart.data.oracle.entity.oracleentityproviderservices, devart.data.oracle.entity, version=8.4.389.0, culture=neutral, publickeytoken=09af7300eec23701" /> visual studio version: 2013 devart.data.oracle.entity version: 8.4.389.0 entity framework: 6.0 this versions, using express version not supports entity framework. need professional or developer version if want use entity framework: http://www.devart.com/dotconnect/oracle/editions.html here can find more information provider registration: http://blog.devart.com/entity-framework-6-support-for-oracle-mysql-postgresql-sqlite-and-salesforce.html#providerregistration

c# - How to manage NHibernate sessions when using Repositories/Transactions -

i'm getting stuck nhibernate @ moment , i'm trying work out how best correctly design repositories whilst correctly managing lifetime of session. from examples i've seen, seems common practise inject isession each of repositories follows: public class somerepository : irepository { private readonly isession _session; public somerepository(isession session) { _session = session; } public ilist<t> loadsomedata() { return _session.query<t>().where(...).tolist(); } } so fine, can see couple of cases there problems: 1) there may not 1 session lifetime of app. 2) when accessing nhibernate should wrap our calls in transaction - if transaction faults must rollback transaction , close session. in both these cases repository defunct references closed session. my particular application long running process, call nhibernate, expect high turnover sessions instead of keeping 1 session open lifetime of app. i th

javascript - Bootstrap accordion collapse - one tab working, one not -

i have twitter bootstrap accordion layout 2 adjacent panes. events in dayone animate fine, in daytwo not. javascript console registers collapsing action in both panes, daytwo events don't slide. i suspect it's simple i'm @ loss. thank assistance! <section class="nav-tabs-default hidden-xs"> <!-- parent nav tabs --> <ul class="nav nav-tabs"> <li class="active"><a href="#dayone" data-toggle="tab"> <div class="title">day 1</div> <div class="subtitle">06/10/2015</div> </a></li> <li><a href="#daytwo" data-toggle="tab"> <div class="title">day 2</div> <div class="subtitle">06/11/2015</div> </a></li> </ul> <!-- parent tab panes --> <

javascript - How can I tell if an object is empty? -

this question has answer here: length of javascript object 30 answers i hope makes sense. if have object: var = {"minlength":true} var = {} how can tell if object empty (the second line of code) object.keys(a).length === 0 should trick.

python - Want to make a consumer, not sure if kombu is enough or I need to also implement Celery -

i'm in process of making consumer rabbtmq. i'm using python , after research decided use kombu. kombu connected queue in rabbit , read messages. code queue = queue('somequeue') def process(body, message): # message.ack() # connections connection(hostname="localhost", userid="****", password="****", port=****, virtualhost="/") conn: # consume conn.consumer(queue, callbacks=[process]) consumer: # process messages , handle events on channels while true: conn.drain_events() it seems work see celery , kombu used together. need consume messages queue, kombu enough or should integrate celery well. if so, has example, found examples aren't clear me. want make queue durable=false consumer seems have durable =true default. how can change this? thanks help!

java - Save a photo selected from gallery to cache directory -

i've written method creates directory in apps cache directory , prompts user take photo or select photo gallery. if user takes new photo, photo saved cache profile.jpg i'm trying intent returns photo gallery save returned photo in cache directory of app profile.jpg. i'm having trouble achieving this. public void selectimage(view v) { file newdir = new file(getexternalcachedir(), "recruitswift"); if(!newdir.isdirectory()) newdir.mkdirs(); else toast.maketext(this, "dir exist", toast.length_long).show(); if(newdir.canwrite()) imagefile = new file(newdir, "profile.jpg"); else toast.maketext(this, "dir not writable", toast.length_long).show(); final charsequence[] options = { "take photo", "choose gallery","cancel" }; alertdialog.builder builder = new alertdialog.builder(userprofileinterview

ascii - Matlab file loading error -

this file trying load looks like. combination of both hex , ascii. want load data , convert ascii hex format. however, when try load data matlab doesn't recognize lot of ascii characters, , leaves them blank result. have tried using importdata( ) fopen( ) , fgetl( ), both result in same error. appreciated. thanks! 736020.582471 Å% ÅÀ 736020.582471 Å2 Å9 736020.582471 Å# Å¡ 736020.582471 Å8 År 736020.582471 Å Åó 736020.582471 Å= Åñ 736020.582472 Å Åx 736020.582472 Å; Å≈ 736020.582472 Ŭ Å@ 736020.582472 Å7 ÅÀ

ORACLE SQL: Fill in missing dates -

i have following code gives me production dates , production volumes thirty day period. select (case when trunc(so.revised_due_date) <= trunc(sysdate) trunc(sysdate) else trunc(so.revised_due_date) end) due_date, (case when (case when sp.pr_typ in ('vv','vd') 'dvd' when sp.pr_typ in ('rd','cd') 'cd' end) = 'cd' , (case when so.tec_criteria in ('pi','mc') 'xx' else so.tec_criteria end) = 'of' sum(so.revised_qty_due) end) cd_of_volume shop_order left join scm_prodtyp sp on so.prodtyp = sp.prodtyp so.order_type = 'md' , so.plant = 'w' , so.status_code between '4' , '8' , trunc(so.revised_due_date) <= trunc(sysdate)+30 group trunc(so.revised_due_date), so.tec_criteria, sp.pr_typ order trunc(so.revised_due_date) the problem have there date no production planned, date wont appear on report. there way of filling in missing dat

sql - How to find bad references in a table in Oracle -

i have data problem need clean up. have 2 tables storing "package" information, 1 table documents , 1 table audit information. have entries in package tables reference documents no longer exist , have been replaced (same name different id) , want write query find bad ones , new document should replace them. thing linking these 2 string value in audit table stores document name (not id). i've setup sample schema here: http://sqlfiddle.com/#!4/997bda/1 package_s single values package in our application package_r repeating values package in our application (these joined same value in id column) audit_info audit information in package docs documents can attached package this query finds packages bad attachments (may more 1 per package) select distinct ps.pkgname, pr.doc_list package_s ps, package_r pr ps.id = pr.id , not exists ( select 1 docs pr.doc_list = id ) order 1,2 asc ; i need build query following rules: i need return @ least package id,

javascript - JS for different dynamically loaded content in a fully ajaxed website -

this updated post explain problem in better way improved concept code (based on answers given here far) i try realize completly ajaxed website. got problems multiple binded events. this basic html: <header id="navigation"> <ul> <li class="red" data-type="cars">get cars</li> <li class="red" data-type="vegetables">get vegetables</li> </ul> </header> <div id="anything"> <section id="dymanic-content"></section> </div> the navigation been created dynamically (as content of #navigation can replaced navigation), binding nav-elements this: $('#navigation').off('click', '.red').on('click', '.red', function() { var type = $(this).attr('data-type'); var data = { 'param': 'content', 'type': type }; ajaxsend(data); }); the content

javascript - Image maps with curves -

i need create many image maps custom edges, curved ones. options find polygons straight edges. while it's possible simulate curves zillions of points, user given option zoom images , perfect curves crucial. isn't there way of using, say, bezier curves on these image maps? if @ possible, don't want use svg objects since seems unnecessarily complex (although, obviously, might wrong). imagemaps ancient html feature , @ time, nobody considered bezier curves. there 1 (rarely used) feature of image maps solution though: server-side image maps . they work bit differently: instead of defining different urls specific areas, define 1 url entire map, , corrdinates, user clicks appended url. above link gives example how can try it. e.g. if have such image map, links http://foo.com/target , click somewhere (say @ pixel coords 25/27), user http://foo.com/target?25,27 with in place, decide on server side, user has clicked. (and there use more complex polygons bezié

python - getting the text from most popular news stories -

i trying scan cnn.coms popular news stories , extract news article top ten links or , save article text can count used words in it. not getting top links web page code. appreciated. how make @ first ten links found on cnn.com/mostpopular? import urllib2 bs4 import beautifulsoup html = urllib2.urlopen('http://www.cnn.com/mostpopular/').read() soup = beautifulsoup(html) item in soup.find_all(attrs={'class': 'cnnwcboxcontent'}): link in item.find_all('a'): item in link.get('href') #soups = beautifulsoup(item) #soups.find_all( print item to interested in need access "cnnmostpopulartabs1" , "cnnmpcontentheadline" : from bs4 import beautifulsoup import requests r = requests.get("http://edition.cnn.com/mostpopular/") data = beautifulsoup(r.content).find("div",{"id":"cnnmostpopulartabs1"}).find_all("div",{"cl

oracle - Ordering on property of child object -

running grails 2.3.9 , having trouble query. have 2 domain objects: class box { string name } and class skittle { string name box box } skittles in boxes, boxes don't have reference skittles. there lots of skittles, each box has skittles has hundreds of skittles. , there thousands of boxes. i want distinct list of boxes have skittles sorted box.name . i don't care if use hibernate or criteria, neither working me. when try criteria , projections, had like: def c = skittle.createcriteria() list results = c.list { projections { distinct "box" } box { order "name" } } interestingly, worked against mysql database, did not work on oracle. second attempt hql: list results = skittle.executequery("select distinct s.box skittle s order s.box.name") this worked in mysql, again failed in oracle (this time nasty error code ora-01791: not selected expression checking hibernate logging, found it's creating

c# - Return to proper hubsection when returning to mainpage -

i creating windows phone 8.1 app , mainpage has hub control consists of 1 (manually created) xaml hubsection , multiple dynamic hubsections generated json. have button takes user new page. when user returns mainpage shows user first hubsection. trying make user returns , sees hubsection focused on before. i attempted: ilist<hubsection> currentsections; currentsections = mainhub.sectionsinview; // code mainhub.sectionsinview = currentsections; but apparently sectionsinview readonly. can't find online... there way this? try using hub.scrolltosection method or hub.defaultsectionindex property

excel - Vertical Axis Values vs. Secondary Data Series Values -

Image
i have simple "stacked line markers" chart type 3 columns of data; month, preventable incidents , non-preventable incidents. chart looks @ 6 months of data , charts preventable , non-preventable incidents. have months along horizontal axis (column a: a2:a7) number of collisions on vertical axis. preventable incident values in column b: b2:b7 , non-preventable incident values in column c: c2:c7. the preventable values data points on chart correspond correctly vertical axis labels, non-preventable data points skewed higher , not correspond correctly vertical axis labels. appreciate in understanding why case , there way have both data series plot correctly values in vertical axis labels. probably need use "line markers" instead of "stacked line". stacked line plot sum of series can see additive effect of both. doesn't if want exact values both series.

PHP iconv Special Character Conversion -

i have problem converting utf-8 chars plain text. of them work while give : ? echo iconv('utf-8', 'ascii//translit', "Žluťoøučký kůň") outputs: zluto?ucky kun the ø ? . php file utf-8 , there no problem encoding. any ideas why? trying run in apache. works fine when using through terminal php compiling

android - How to avoid clicking Play audio option when the audio is buffering? -

i playing mp3 audio server using below code. working fine, no issues. when clicking on play button, taking few seconds start audio, takes buffering time, in gap time if click play button again , again, app crashes. how can have condition under play button code checking whether audio has been buffered , play starting or not? can't check here if(mediaplayer.isplaying()). private void playaudio(string url) throws exception { if( (mediaplayer == null || iscompleted) && !ispaused ) { iscompleted = false; ispaused = false; playpausebutton.setbackgroundresource(r.drawable.pauseimage); mediaplayer = new mediaplayer(); mediaplayer.setdatasource(url); mediaplayer.prepare(); mediaplayer.start(); } else if ( ispaused ) { playpausebutton.setbackgroundresource(r.drawable.pauseimage); mediaplayer.start(); ispaused = false; } else { playpausebutton.setbackgroundresource(r.dra

Static vs class functions/variables in Swift classes? -

the following code compiles in swift 1.2: class myclass { static func mymethod1() { } class func mymethod2() { } static var myvar1 = "" } func dosomething() { myclass.mymethod1() myclass.mymethod2() myclass.myvar1 = "abc" } what difference between static function , class function? 1 should use, , when? if try define variable class var myvar2 = "" , says: class stored properties not yet supported in classes; did mean 'static'? when feature supported, difference between static variable , class variable (i.e. when both defined in class)? 1 should use, , when? (xcode 6.3) static , class both associate method class, rather instance of class. difference subclasses can override class methods; cannot override static methods. class properties theoretically function in same way (subclasses can override them), they're not possible in swift yet.

javascript - Form inputs overshoot modal when using with Bootstrap 3 -

Image
i'm trying load modal angular , fill template. the problem inputs overshooting modal - here screenshot of problem: here code modal instantiation: $scope.loginopen = function () { console.log($modal); var modalinstance = $modal.open({ templateurl: '../views/login.html', controller: 'authcontroller', size: 'sm' }); modalinstance.result.then(function () { console.log($scope.modalinstance); }, function () { $log.info('modal dismissed at: ' + new date()); $scope.modalinstance = null; }); } and here /view/login.html <div class="container"> <div class="row"> <div class="col-md-6 col-lg-2"> <form ng-submit="login()" style="margin-top:30px;"> <h3>log in</h3> <div class="form-group"> <input type="text" class="form-control&q

meteor - iron:router beforeAction login AND data: function? -

i'm using standard iron:router pattern ensuring user authenticated before accessing route: authenticatedcontroller = routecontroller.extend({ onbeforeaction: function(){ if ( meteor.user() ){ var route = router.current().route.getname(); this.next(); } else this.render('login'); }) this works unparameterized routes example: router.route("profile",{ name: "profile", controller: 'authenticatedcontroller' }); when try extend pattern parameterized route, example: router.route('/foo/:id',{ name: 'foo', controller: 'authenticatedcontroller', data: function(){ return mycollection.findone({ _id: this.params.id }); } } }); it works if user logged in i 404 page if user not logged in it seems beforeaction runs after data function. since mycollection doesn't publish documents until user logged in iron:router decides route doesn't exist. the time want 404 if collection

java - Why i am getting 2/4 rows when i nsert 1/2 row(s) in mySql -

i trying save file coordinates(lat, long) online database . made method below. read file string external storage , split end latitude arraylist , longitude arraylist . afterwards make insert statment db. works fine, exampe if have 1 coordinate(x, y) in file double in db (1 row(x, y) , 2 row(x, y)), , if have 2 points 4 rows in db! - tried many hours find out did wrong. stuck in this! - appreciated, private void filetodatabase() { file path = environment.getexternalstoragepublicdirectory(environment.directory_documents); if (myfile().isempty()) { boolean delete = (new file(path, filename)).delete(); if(delete) { return; } } else { string[] latlngreplaced = myfile().replace("\n", ",").split(","); list<string> lats = new arraylist<>(); list<string> lngs = new arraylist<>(); (int = 0; < latlngreplace

ios - How to reload a data table from a Controller? (I'm using Core Data) -

i developing ios app. trying fetch data table after insert data on table. code: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { notification *notification = [self.fetchedresultscontroller objectatindexpath:indexpath]; if ([notification.isread isequaltonumber:@no]) { [self sendnotificationdata:notification]; notification.isread = @yes; } [self insertpost:notification.notificatableid]; post *post = [self fetchobjectfrom:@"post" withpredicate:[nspredicate predicatewithformat:@"objectid == %@", notification.notificatableid]]; } - (void)insertpost:(nsstring *)postid { nsdictionary *parameters = [[nsdictionary alloc] initwithobjectsandkeys:postid, @"notification[post_id]", nil]; [[akdemiaapiclient sharedclient] post:[nsstring stringwithformat:@"/notifications/%@/get_post",postid] parameters:parameters success:^(nsurlsession

c - dynamically allocated char array only prints first character from each index -

i'm trying read file has words in separated spaces, words read within loop. read correctly within loop , can printed loop ends able print first character of each element. here code: char **storewords(char **words){ char* filename = "words.txt"; file* fp = fopen(filename, "r"); int i; (i = 0; < 2; i++){ int j; (j = 0; j < 20; j++){ fscanf(fp, "%s", &words[i][j]); printf("%s", &words[i][j]); //prints correctly } } printf("%s", &words[0][0]); //prints first character of selected element fclose(fp); return **words; } int main(){ char **words = (char**)malloc(6 * sizeof(char*)); (int = 0; < 6; i++){ words[i] = (char*)malloc(20 * sizeof(char)); } storewords(words); system("pause"); return 0; } i don't understand why happens, appreciated if explained. thanks. the problem alloca

swing - How to add text to a single text field from many buttons ?? -- Java -

as can read title, need set text of jtextfield pressing buttons.. , buttons should disappear when clicked(which did method 'setvisible'), when delete letter button must appear again.. but focus on "how add text single text field many buttons".. each button when pressed must add letter, the code did far// note : i'm working on netbeans ide public class test extends javax.swing.jpanel { /** * creates new form test */ public test() { initcomponents(); } /** * method called within constructor initialize form. * warning: not modify code. content of method * regenerated form editor. */ @suppresswarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated code"> private void initcomponents() { jpanel1 = new javax.swing.jpanel(); k = new javax.swing.jbutton(); o = new javax.swing.jbutton(); a1 = new javax.swing.jbutton(); = new javax.swing.jbutton(