Posts

Showing posts from February, 2015

datetime - date time in Android inconsistencies -

i stuck example running on android: simpledateformat sdf = new simpledateformat("dd-mm-yyyy kkmm"); sdf.settimezone(timezone.gettimezone(time.timezone_utc)); date scheduleddatetime = sdf.parse(sms.getscheduleddatetime()); log.i(tag, "scheduleddatetime : " + scheduleddatetime); // scheduleddatetime : fri jan 06 23:58:00 hnec 2012 log.i(tag, "scheduleddatetime milli : " + scheduleddatetime.gettime()); // scheduleddatetime milli : 1325890680000 calendar calendar = calendar.getinstance(); calendar defaulttzcalendar = calendar.getinstance(timezone.getdefault()); calendar utctzcalendar = calendar.getinstance(timezone.gettimezone(time.timezone_utc)); calendar.settime(scheduleddatetime); defaulttzcalendar.settime(scheduleddatetime); utctzcalendar.settime(scheduleddatetime); log.i(tag, "calendar : " + calendar.gettimeinmillis()); // calendar : 1325890680000 log.i(tag, "defaulttzcalendar : " + defaulttzcalendar.gettimeinmillis()); // defaulttzc...

Django Template being rendered differently for different urls -

i'm using static_url in 1 of templates , works if use 1 url , fails if use another. in both cases, exact same view being run exact same template. template code: <link href="{{ static_url }}css/form.css" type="text/css" rel="stylesheet" /> <!-- rest of page... --> view code: def myform(request): if request.method == 'post': form = myform(request.post, request.files) obj = save_form(form) if obj: send_confirmation_email(obj) return redirect('done-page') else: form = myform() return render(request, 'template.html', {'form': form,}) urls # site urls.py urlpatterns = patterns('', url(r'^$', 'site.app.views.myform'), url(r'^app/', include('site.app.urls'), #... ) # app urls.py urlpatterns('site.app.views', url(r'^$', 'myform'), #... ) the above snippet of django site. if page accessed via "mydomain.com/" (the index of site), static_ur...

c++ - class template, with template function, specialization -

i'm trying write template class aids programmer in writing correct code. calculate route san francisco new york via washington, given route san francisco washington , route washington new york. when given route san francisco los angeles , washington new york, compiler report error. here class (without normal workhorse function): extern const char miami[] = "miami"; template< const char* finish, const char* start> class route { public: route(); ~route() {}; template<const char* otherplace> route<start, otherplace> alterfinish() const; }; template<const char* start> // specialisation template<const char* otherplace> // allow miami finish changed else. route<start, otherplace> route<start, miami>::alterfinish() const{ return route<start, otherplace>(); } unfortunately not work. 'invalid use of incomplete type' error. same sort of function without specialisation compile. doing wrong? invalid use of incomplete typ...

sql - Postgres: Selecting Distinct on a column is not returning distinct results with Joins -

Image
i'm building system in there following tables: song broadcast station follow user a user follows stations, have songs on them through broadcasts. i'm building "feed" of songs user based on stations follow. here's query: select distinct on ("broadcasts"."created_at", "songs"."id") songs.* "songs" inner join "broadcasts" on "songs"."shared_id" = "broadcasts"."song_id" inner join "stations" on "broadcasts"."station_id" = "stations"."id" inner join "follows" on "stations"."id" = "follows"."station_id" "follows"."user_id" = 2 order broadcasts.created_at desc limit 18 as can see here, i'm getting duplicate songs happening because i'm following 2 stations both have broadcasted same song: note: shared_id same id. my question is: how...

php - line breaks not showing on output? -

for longest time, i've been outputting comments , using function below in order put in line breaks. it's been working great. echo str_replace(chr(13),"<br />",$com_text); however, of late, code has not been working new comments. still functions older comments in database. new being submitted database not being outputted correctly. no code has changed, i'm aware of. suggestions? try using echo nl2br($com_text); or regex looks new lines: echo preg_replace('/$\r?^/m', '<br />', $com_text);

ruby - Rails mailer links improperly rendering -

Image
has else had issues rails img src links being improperly rendered, i.e. http://host.s3.amazonaws.com/images/account_welcome_button.png is being rendered as http://host.s3.amazonaws.com/images/+account_welcome_button.png in e-mail clients? i'm testing particularly on gmail inbox client. if you've experienced this, has been fix remove these characters? ruby - rails mailer links improperly rendering - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company blog tour start here quick overview of site center detailed answers questions might have meta discuss workings , policies of site learn more stack overflow company business learn more hiring developers or posting ads log in sign ...

objective c - Bare bones Facebook integration demo app -

so started looking integrating fb app , whipped little test app. wanted have bare bones app without of bs that's in hackbook demo app. basically, it's overly complicated want. the problem i'm doing isn't working. app tries authenticate fb, doesn't return auth tokens. else noticed that... if have facebook app installed... switches it, shows white loading screen second, dismisses , pops app. if facebook app isn't installed... open in safari , show app approval window, let me login , pops app. both ways fail getting , storing auth tokens however. what heck doing wrong? mind seeing if code works them? full source here: deleted. thanks looking. it sounds don't have app registered in facebook developer portal. https://developers.facebook.com/apps

Facebook PHP publish watches action -

i want add facebook open graph feature website. created action (watch) (video) . have set meta tags so: <meta property="og:title" content="title"/> <meta property="og:type" content="namespace:video"/> <meta property="og:url" content="http://www.zzz.com/images.php?i=something"/> <meta property="og:image" content="http://www.zzz.com/thumbnails/images.png"/> <meta property="og:site_name" content="site name"/> <meta property="fb:app_id" content="xxxxxxxxxxx"/> <meta property="fb:admins" content="xxxxxxxxxxxx"/> <meta property="og:description" content="desc"/> i using php sdk authenticate users , on videos page want publish users actions so: require_once('scripts/facebook.php'); $config = array('appid' => 'xxxxxx','secret' => 'xxxxxxx');...

javascript - Chart rendering issue with resizing container -

Image
i have two question chart rendering when container resized. first thing is, how render chart correctly when container resized.. i.e. maximize / restore problem, @ first rendering works fine, when restore size of window, charts begin overlay previous size. can see following pics: i know if set resize handler (and wait small amount of time) refresh chart whenever window resized, problem can solved. thinking whether there other approaches let chart flow right size without refreshing chart every time. the second thing is: if charting area in <div> container, , size of container change resize bar. use following code work window resizing. won't work moving resize bar. $(window).resize(function () { settimeout(function () { createchart(chartdata); }, 300); }); note : grid component works fine in case , chart having troubles. using highcharts, kendoui grid , both of them rendered in jqueryui portlets. any comments appreciated!this problem has taken me long time.. update...

php - Codeigniter replace uploaded image -

i'm using codeigniter's file uploading class uploading user avatars. there way replace user's image file whenever he/she uploads new one? want replace existing avatar newest 1 uploaded. my image uploading controller function upload_avatar() { $config['upload_path'] = './uploads/avatars/'; $config['allowed_types'] = 'jpg|png'; $config['overwrite'] = false; //overwrite user avatar $config['encrypt_name'] = true; $config['max_size'] = '200'; //in kb $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { $error = $this->upload->display_errors(); $this->session->set_flashdata('error', $error); redirect('/settings/avatar'); } else { $config['image_library'] = 'gd2'; $config['source_image'] = $this->upload->upload_path.$this->upload->file_name; $config['create_thumb'] = false; $config['maintain_ra...

python - How to produce a TabularInline that spans models -

i have model (booking) onetoonefield (thread) subsequently has foreignkey relationship (message). show list of messages on booking admin, thread model in between appears hard/not possible? class booking(model): ... thread = models.onetoonefield('user_messages.thread', verbose_name='thread') class thread(model): ... class message(model): thread = models.foreignkey(thread, related_name="messages") is there way can set bookingadmin inline can display messages (spanning across thread relationship)? like: class messageinline(tabularinline): model = message fk_name = '???' class bookingadmin(modeladmin): inlines = [messageinline, ] i'm happy override way inlines work if that's best way, i'm not sure tackle that. looks overriding *get_formset* might trick? this isn't tested yet, appears work. solution have inline , formset hooks replace booking attached thread... class bookingmessageformset(baseinlineformset): '''given bo...

php - How to pass controller function parameters in codeigniter from forms? -

i have search city in website, search bar option can select city want view. when search city in website, directs url: foobar.com/s/ now want url become this: foobar.com/s/california my select options have format: <select name='city'> <option value='california'>california</option> </select> how can make value of option seen in url? you need first redirect foobar.com/s/california once user has selected option dropdown , routing send url respective controller something $route['s/(:any)'] = "s/your_method_name/$1";

ios - Get Alpha Value Objective-C -

how alpha value of nsbox , use in if statement? i want check alpha of nsbox if value equal 0 something. if ([preferences alphavalue ==0]) { [[[[preferences subviews] objectatindex:0] animator] setalphavalue:0.0]; } else { [[[[preferences subviews] objectatindex:0] animator] setalphavalue:1]; } } do want if ([preferences alphavalue] == 1.0) or something? you need explain want more clearly.

parameter function in jquery -

i want make function parameter. working below code not working. can tell me doing wrong. <head> <script type="text/javascript" src="jquery-1.7.2.js"></script> <script type="text/javascript"> $(function hide(fn){ $(fn).click(function(){ $('div').hide() }) }) </script> <style> div { width:500px; height:500px; background:#ff0000; } </style> </head> <body> <button onclick="hide(this)">click hide</button> <a href="#">click</a> <button>click</button> <div></div> </body> one important thing: should write unobtrusive javascript , considered best practice. it, can maintain separation of content code. thus, first step remove onclick handler on <button> element. i'm assuming want click button says "click hide" hide <div> . okay, let's skeleton code out <script> : $(document).ready(functio...