Posts

Showing posts from March, 2010

facebook - Given URL is not allowed by the Application configuration in wordpress social plugin -

Image
error - given url not allowed application configuration.: 1 or more of given urls not allowed app's settings. must match website url or canvas url, or domain must subdomain of 1 of app's domains. i have created app facebook error comes in wordpress socil login plugin . if body know me out just add wordpress web page url application settings. must add url in "website facebook login" part.

clojure - Architecture for plugins to be loaded in runtime -

considering developing end-user software program (as uberjar) wondering options make possible user download plugin , load during runtime. the plugin(s) should come compiled , without source code, sth. load not option. existing libraries (or ways of java...?) exist build on? edit: if not sure satisfied way costs reboot/-start of main-program. however, important source-code won't included in jar file (neither main application nor plugin-jars, see :omit-source of leiningen documentation). to add jar during runtime, use pomegranate lets add .jar file classpath. plugins of software should regular clojure libs follow conventions need establish: make them provide (e. g. in edn ) symbol object implementing constructor/destructor mechanism such lifecycle protocol in stuart sierras component library. in runtime, require , resolve symbol, start resulting object , hand on rest programs plugin coordination facilities. provide public api in program allows plugins int

knockout.js - using knockout to set css class with an if condition -

i want set bootstrap css class span if condition (up binded value). have isapproved field in list , want see field 'label-success' class when active , 'label-important' class when inactive i added line , time taking first class : data-bind="text: isapproved, css: isapproved = 'true' ? 'label label-important' : 'label label-important'" is possible in html or should add computed field on vm? if understood right, binding looking for. data-bind="text: isapproved, css: { 'label' : true, 'label-success' : isapproved(), 'label-important': !isapproved() }" i hope helps.

How do I pass a value to an object in javascript? -

i have think called object(?) in javascript: paymentwindow = new paymentwindow({ 'merchantnumber': "xxxxxx", 'amount': '10500', 'currency': "dkk" }); now want set amount value object. like: paymentwindow.amount = '20000'; however, not work. sure simple, can't find solution. now want able set amount outside object. this easy or impossible, depending on how object looks like. if constructor set this: function paymentwindow(options) { this.amount = options.amount; } then it's easy , works propose. attached this becomes public property. however, if constructor set this: function paymentwindow(options) { var amount = options.amount; } then it's impossible, because var amount private constructed object.

spring - Mock MVC - Add Request Parameter to test -

i using spring 3.2 mock mvc test controller.my code is @autowired private client client; @requestmapping(value = "/user", method = requestmethod.get) public string initusersearchform(modelmap modelmap) { user user = new user(); modelmap.addattribute("user", user); return "user"; } @requestmapping(value = "/byname", method = requestmethod.get) @responsestatus(httpstatus.ok) public @responsebody string getuserbyname(@requestparam("firstname") string firstname, @requestparam("lastname") string lastname, @modelattribute("userclientobject") userclient userclient) { return client.getuserbyname(userclient, firstname, lastname); } and wrote following test: @test public void testgetuserbyname() throws exception { string firstname = "jack";

android - Close Application if no internet connection -

oncreate of "home" activity, want check if there's internet connection, if false close activity showing toast.. but, home activity not first on stack, if set finish(); close activity , show top 1 in activity stack.. so i've written down code, make sense? if(!utils.isonline(mcontext)) if(!movetasktoback(true)) finish(); where utils.isonline() method check internet connection edit : i've created method check internet connection , it's utils.isonline().. i'm not asking how check internet connectio... edit2 : movetasktoback() not best choice achieve target, because yes puts activity onbackground if reopen it, app doesn't check anymore condition (don't know why.. skips oncreate(?)) , shows blank activity.. if want close app can add lines: intent intent = new intent(intent.action_main); intent.addcategory(intent.category_home); intent.setflags(intent.flag_activity_new_task); startactivity

C++ vector<vector<int>>`select only entries that appear just once -

i have vector<vector<int>> has following entries: 2 3 3 4 2 3 4 5 5 6 i need create vector<vector<int>> entries apeears once. so: 3 4 4 5 5 6 this gives result looking for. using std::map , std::pair #include <iostream> #include <vector> #include <map> int main() { std::map<std::pair<int, int>, int> count_map; std::vector<std::pair<int, int> > v; std::vector<std::pair<int, int> > v2; int a[10] = {2,3,3,4,2,3,4,5,5,6}; for(int = 0; < 10; i++) { int first = a[i]; int second = a[++i]; std::pair<int, int> p = std::make_pair(first, second); v.push_back(p); count_map[p]++; } for(auto = count_map.begin(); != count_map.end(); ++it) { if(it->second != 1) continue; v2.push_back(it->first); std::cout << it->first.first << ", " << it->first.second &

windows - Is there any way to semi-automatically commit? -

please bear me here, because i'm beginner when comes version control systems. i've decided start simple github app. want (because work in dreamweaver) when save file window pop-up , ask me if want commit, achievable , if so... how? perhaps there's solution uses directory watcher watch changes , prompt? in opinion, isn't solution though - don't want use git "backup" solution, want each commit mini-milestone represents logical group of changes. can't think of single instance first time saved change file commit-worthy. if commit every save, how ever test changes?

jquery: does $(window).load() get fired after css is rendered? -

i reading stackoverflow post: is $(document).ready() css ready? the answer clear: no, $(document).ready() not guarantee complete css rendering. that left me wondering: can ensure full css rendering before jquery function (that relies on rendered css ) executed? there event gets fired once css rendered? $(window).load() solution? $(window).load() seems work fine me , seems developer recommends: http://taitems.tumblr.com/post/780814952/document-ready-before-css-ready (is our assumption) correct? i'd suggest load css in head before call scripts should ideally @ bottom of html document. have been using , never has there been case unstyled content visible.

ios - Expression is not assignable error -

- (void)textfielddidbeginediting:(uitextfield *)textfield { #define koffset_for_keyboard 110.0 textfield.frame.origin.y -= koffset_for_keyboard; textfield.frame.size.height += koffset_for_keyboard; textfield.frame = cgrectmake(textfield.frame.origin.x, (textfield.frame.origin.y - 230.0), textfield.frame.size.width, textfield.frame.size.height); } got code textfield app in ios... plan have in way that, when keyboard appears, textfield goes on top of keyboard , when return key in keyboard pressed, textfield goes original position @ bottom of screen. error, "expression not assignable." how solve this? error mean? you can't assign value origin or height. you'll have assign cgrect frame , update values in new cgrect.

android - Call AsyncTask in a Fragment -

i have class extends fragment. call asynctask class in fragment. doesn't obtain error in mylogcat doesn't display null in listview. below paste code use, code more simple, read json file , insert in custom listview. code works if change class in activity, want transform activity in fragment. thanks in advance. public class myfragment extends fragment { jsonparser jsonparser = new jsonparser(); arraylist<hashmap<string, string>> unilist; jsonarray articles = null; listview list; listuniadapter adapter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); new loadnews().execute(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { linearlayout ll = (linearlayout)inflater.inflate(r.layout.uni_list, container, false); list = (listview) ll.findviewbyid(android.r.id.list); return ll; } class loadnews extends asynctask<string, st

java - Error Conversion String to Date WebService -

guys, i´m writing app webservice i´ve been facing strange issue. when call w.s receive error: exception description: object [2013-08-04t12:00:00:00], of class [class java.lang.string], mapping [org.eclipse.persistence.oxm.mappings.xmldirectmapping[dateevent-->dateevent/text()]] descriptor [xmldescriptor(br.com.gvt.armanagementapp.service.to.receivableinvoicein --> [databasetable(ns0:receivableinvoicein)])], not converted [class java.util.calendar]. but objet receivableinvoicein there isn´t attribute java.util.calendar there atributte java.util.date has faced issue? my environment weblogic12c maven i found problem. think bug on weblogic12c1.1 when perform simple test webblogic ´s webservice client , puts blank spaces tag this: 1999-12-24t22:00:00 the solution split blank spaces: 1999-12-24t22:00:00

ios - Use string as part of [JSON valueForKeyPath] selector? -

i'm parsing json looks like: {"data":{"items":{"daily":{"2013-07-31":16}}}} i've built date string. e.g: nsdateformatter *format = [[nsdateformatter alloc] init]; [format setdateformat:@"y-mm-d"]; nsdate *now = [[nsdate alloc] init]; nsstring *datestring = [format stringfromdate:now]; how use datestring part of valueforkeypath selector? [json valueforkeypath:@"data.items.daily"]? you can create keypath string using +stringwithformat: method , use it. have (assuming json object parsed json string): nsstring *keypath = [nsstring stringwithformat:@"data.items.daily.%@", datestring]; id valueyoulookfor = [json valueforkeypath: keypath]

ios - Nesting UICollectionViews - how should I handle the data from core data? -

i need add scrolling in both directions uicollectionview - netflix app does. know can add uicollectionview in single-column uicollectionviewcell object, question best way pass data each section in nested uicollectionview ? depending on data structure, easiest way might use 2 separate nsfetchedresultscontroller s.

javascript - IE attach event to checkbox? -

i have html list of checkboxes don't know how 'document.attachevent' find checkboxes on onclick? i wasn't sure if set event model specific ie in document.attachevent create loop goes through every checkbox , handles each one? also, checkboxes of different names can't checkboxname.attachevent unless did each one. my elements dynamics enough tried adding en event broadest ancestor, document use event target , type no avail. much thanks. some fixes code: document.attachevent('onclick', function (e) { var target = e.srcelement; if (target.type === 'checkbox') { if(target.checked){ button.disabled = false; } else { button.disabled = true; } } }); the third argument not used in ie's event handling model. e.srcelement refers clicked element. i'd suggest wrap checkbox(es) in div or other element, , attach event listener wrapper. when page gets larger, che

sql - If a value contains a certain character then do this or else do this -

i trying write function processes column value , returns value before '@' symbol. i have managed far using following code: create function fnstaffcodeconvert (@staffcode varchar(10)) returns varchar(4) begin declare @staffinitals varchar(4) set @staffinitals = (select substring(@staffcode,0, charindex('@',@staffcode))) return @staffinitials end example result function - parameter in = abc@123 , returns = abc . this works exclusively returns every result column contained @ value , remaining results without @ omitted. i.e. abc@123 returns abc xyz not return anything. how can amend code give me both sets of values? imagine have put 'if' statement in there unsure how write results want. many in advance :) mike you there: alter function fnstaffcodeconvert (@staffcode varchar(10)) returns varchar(4) begin declare @staffinitals varchar(4) if charindex('@',@staffcode) <> 0 set @staffinitals =

php - ajax returns success but mysql db not updated -

i have javascript loop sends array ajax page update mysql database. i echo result original page , echos success when check db nothing has changed my javascript loop sends array for(var m=0; m<array.length; m++){ $.post("update_page_positions.php",{page_ref:array[m][0], ref:array[m][12], menu_pos:array[m][1], sub_menu_pos:array[m][2], top_menu:array[m][3], pagelink:array[m][4], indexpage:array[m][5], hidden:array[m][6], page_title:array[m][7], page_desc:array[m][8], page_keywords:array[m][9], page_name:array[m][10], deletedpage:array[m][11]}, function(data,status){ alert("data="+data+" status="+status); }); here php ajax page updates db <? include("connect.php"); $ref = $_post['ref']; $page_ref = $_post['page_ref']; $menu_pos = $_post['menu_pos']; $sub_menu_pos = $_post['sub_menu_pos']; $top_menu = $_post['t

html - How can I prevent the browser from scrolling on top of the page when clicking the checkbox? -

whenever click on checkbox, browser window (firefox) scroll on top of screen. how can prevent behavior when click on checkbox browser window not scroll on top? here code found here http://jsfiddle.net/zafnd/6/ thank you. <html> <head> <title>test</title> <style> div label input { margin-right: 100px; } body { font-family:sans-serif; } #ck-button { margin: 4px; background-color: #efefef; border-radius: 4px; border: 1px solid #d0d0d0; overflow: auto; float: left; } #ck-button { margin: 4px; background-color: #efefef; border-radius: 4px; border: 1px solid #d0d0d0; overflow: auto; float: left; } #ck-bu

node.js express custom format debug logging -

a seemingly simple question, unsure of node.js equivalent i'm used (say python, or lamp), , think there may not one. problem statement: want use basic, simple logging in express app. maybe want output debug messages, or info messages, or stats log consumption other back-end systems later. 1) want logs message, however, contain fields: remote-ip , request url, example. 2) on other hand, code logs everywhere in app, including deep inside call tree. 3) don't want pass (req,res) down every node in call tree (this creates lot of parameter passing not needed, , complicates code, need pass these async callbacks , timeouts etc.) in other systems, there thread per request, store (req,res) pair (where data need is) in thread-local-storage, , logger read , format message. in node, there 1 thread. alternative here? what's "the request context in specific piece of code running under"? the way can think of achieving looking @ trace, , using reflection @ local

Misunderstanding Android weights -

i've tried couple different approaches weights, there glaring mis-understanding of how aiming here. attempting do, have imageview take 1/3rd of screen across width, while having layout of textviews take remainder of 2/3rds of screen across width. what ends having try , manipulate however, imageview small , not taking space should be. i've been messing around trying layouts right morning. the answer below has led me following occurring in instance: 0dip layout dimensions <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:weightsum="3"> <imageview

javascript - WordPress Language Page -

i've installed wordpress , played while. , got question how can make top page let visitors choose languages. let's there ware 2 languages website, english , japanese. when visitor opens domain root( http://example.com ), selection page appears. if english clicked, redirects page " http://example.com/en ", has been created wordpress's page feature(permalink). if japanese, goes example(dot)com/jp." this kind of page annoying , of time useless. can automatically detect user browser language and/or ip location, or display language switcher anywhere in website. if need anyway, can try wpml plugin (or other free alternative, if find one...). can test if have detected language , if there not, display language chooser.

javascript - HTML - Dynamically created input labels, for attribute -

this question has answer here: possible associate label checkbox without using “for=id”? 3 answers is there way link label input without using input's id ? i'm creating/deleting input / label couples dynamically , not have generate unique ids for attribute. can done using classes or else ? thanks ! yes place input inside label <label><input type="text" name="myname" /> first name</label> have here - possible associate label checkbox without using "for=id"? when <input> inside <label> , connection between them implicit. html4 specification

php - HTML editor embedded in admin page -

i'm working on simple webpage company , company wants able edit content time time. have no programing knowledge , therefore want use embedded html editor, have chosen jquery te . the problem know how use form, e.g.: <form id = "wyform" method="post" action="test.php"> <textarea class="editor"name = "testtext">hi</textarea> <input type="submit" class="wymupdate" /> </form> then convert textarea editor jquery: <script> $('.editor').jqte() </script> this makes possible send result .php page updates database. many times don't want use textfield or form, simple object convert editor in same way. how save change in case? catch form submit event , copy content hidden field. <form id = "wyform" method="post" action="test.php"> <div class="editor" name="testtext">hi</

.net - C# Reading a binary text file without knowing the format of the file -

ok have binary text file written using binarywriter. format of file has been lost due poor documentation. im using binaryreader read file way can through trial , error stepping through file , guessing whether should using readint64(), readstring() etc of binaryreader class. is there anyway step through file , automatically determine next value format is? no. binarywriter not pack type information written file, there no way reverse-engineering - other trial & error, have found out.

hdfs - Only one datanode can run in a multinode Hadoop setup -

i trying setup multinode hadoop cluster. right now, trying 2 nodes. 1 namenode/datanode (host a), , other second datanode (host b). strange thing that, can have 1 datanode running, either host or host b. if remove host b conf/slaves file , keep host in set up, system use host datanode. if put both host , b in conf/slaves file, host b show datanode in system. the following log host when not work: ************************************************************/ 2013-07-31 10:18:16,074 info org.apache.hadoop.hdfs.server.datanode.datanode: startup_msg: /************************************************************ startup_msg: starting datanode startup_msg: host = a.mydomain.com/192.168.1.129 startup_msg: args = [] startup_msg: version = 1.0.4 startup_msg: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1393290; compiled 'hortonfo' on wed oct 3 05:13:58 utc 2012 ************************************************************/ 2013-07-31 10:1

bash - Shell redirection i/o order -

i'm playing i/o shell redirection. commands i've tried (in bash): ls -al *.xyz 2>&1 1> files.lst and ls -al *.xyz 1> files.lst 2>&1 there no *.xyz file in current folder. these commands gives me different results. first command shows error message ls: *.xyz: no such file or directory on screen. second 1 prints error message file. why did first command failed write err output file? this error: ls: *.xyz: no such file or directory is being written on stderr ls binary. however in command: ls -al *.xyz 2>&1 1> files.lst you're first redirecting stderr stdout default goes tty (terminal) and you're redirecting stdout file files.lst , remember stderr doesn't redirected file since have stderr stdout redirection before stdout file redirection. stderr still gets written tty in case. however in 2nd case change order of redirections (first stdout file , stderr stdout ) , rightly redirects stde

actionscript 3 - AS3 OggVorbis - is there a precompiled SWC available? -

i use oggvorbis sound files in flash project, , while realize can compile swc crossbridge, little on head, wondering if knows of ready use swc library available download. have googled death without luck. alternatively, if knows of walkthrough compiling library great too. have crossbridge set , working, when gets part of making swc interface got bit lost, , i'm on time-table working. thanks! this 1 works pretty good, , has compiled swc files. http://labs.byhook.com/2011/02/22/ogg-vorbis-encoder-decoder-for-flash/

javascript window.onresize on page load -

i have script shows different content depending on screen size, looks this: window.onresize = function(event) { if ((window.innerwidth > 750 && window.innerwidth < 1250)) { //do }} the above works absolutely fine when re-sizing browser. question how can above work if user opens page window width of 750? i have tested , event isn't triggered until browser re-sized, causing above not work var onresizing = function(event) { if ((window.innerwidth > 750 && window.innerwidth < 1250)) { //do }}; window.onresize = onresizing; window.onload = onresizing;

svg - Recursive/recurring animation events in D3 -

i'm trying make recurring transitions in d3 keep repeating indefinitely. specifically, i'm working map , want background stars flicker. problem transitions appears they're run ahead of time, try infinite recursion ahead of time , page never load. found related example ( recursive d3 animation issue ) isn't infinite. other idea somehow use d3 timer, i'm not entirely sure how go either. tips appreciated. right, can’t schedule infinite number of transitions ahead of time. :) however, can repeatedly schedule new transition when old transition ends (or starts), using transition.each listen end (or start ) events. take @ chained transitions example infinitely-repeating animation. whenever circle transition starts, schedules identical following transition, allowing transition repeat indefinitely. alternatively, use setinterval or settimeout create transitions repeatedly, in concurrent transitions example . unlike chained transitions example linked, a

Magento 1.7 Admin Login Fatal error: Call to a member function getBlockName() on a non-object in line 43 -

can me? on index.php/admin following exception thrown: fatal error: call member function getblockname() on non-object in /home/ahorraen/public_html/app/code/core/mage/captcha/block/captcha.php on line 43 delete var/cache , var/session this works me!

How do I include a matplotlib Figure object as subplot? -

this question has answer here: embed matplotlib figure in larger figure 1 answer how can use matplotlib figure object subplot? specifically, have function creates matplotlib figure object, , include subplot in figure. in short, here's stripped-down pseudocode i've tried: fig1 = plt.figure(1, facecolor='white') figa = myseparateplottingfunc(...) figb = myseparateplottingfunc(...) figc = myseparateplottingfunc(...) figd = myseparateplottingfunc(...) fig1.add_subplot(411, figure=figa) fig1.add_subplot(412, figure=figb) fig1.add_subplot(413, figure=figc) fig1.add_subplot(414, figure=figd) fig1.show() sadly, however, fails. know fact individual plots returned function invocations viable--i did figa.show(),...,figd.show() confirm ok. final line in above code block--fig1.show()--is collection of 4 empty plots

html - Order list making the line numbers hrefs -

i'm using ordered list , able link specific line using line numbers links them. <ol> <li id="line10" href="#line10">coffee</li> <li>tea</li> <li>milk</li> </ol> i wondering if guys know of way this? thanks help! the href attribute not valid attribute of li if want li clickable link, linking itself, nest a element inside: <li id="line10"><a href="#line10">coffee</a></li>

excel - Reference cell in another workbook as email address in .To field -

i'm trying reference cell a1 in workbook, in sheet, set "to" field in email. here code: dim outapp object dim outmail object set outapp = createobject("outlook.application") set outmail = outapp.createitem(0) addresses = workbooks("test.xlsx").sheets("sheet2").range("a1").value on error resume next outmail .to = addresses .cc = "" .bcc = "" .subject = "confirm " & format(date, "mm.dd.yy") .body = "please see attached confirm. thanks," .attachments.add activeworkbook.fullname .display end on error goto 0 set outmail = nothing set outapp = nothing when execute macro, "to" field in email has nothing in it. cell referencing has value in it. have suggestions? try moving display beginning. so... with outmail .display

regex - Find rows that contain three digit number -

i need subset rows contain <three digit number> wrote foo <- grepl("<^[0-9]{3}$>", log1[,2]) others <- log1[!foo,] but i'm not sure how use regex...just been using cheat sheets , google. think < , > characters throwing off. the ^ , $ signs refer beginning , end of string, respectively. shouldn't matching before or after them. if want rows contain pattern, shouldn't use anchors @ all. should use this: <[0-9]{3}> (or shorten <\\d{3}> )

php - Json returns empty string between tags -

i new json , have problem why json_decode returns empty string between tags of < , > ... here json string { "clipboard": { "title": " mozilla firefox ", "event": "<mouse+copy/paste>" } } the output json_decode through var_dump shows object(stdclass)#44 (1) { ["clipboard"]=> object(stdclass)#45 (2) { ["title"]=> string(17) " mozilla firefox " ["event"]=> string(18) "" } } why keeps removing data between "<" , ">" , checked on online json editor validate json string , shows value is. when use deocde_json "event" array element comes empty. the string(18) in ["event"]=> string(18) "" gives clue. look @ source of page. not displayed on website in source because interpreted html tag.

c# - iOS http POST request -

i have api on server trying json response from. have used several request tools simulate call, , correct data each time. here request setup: nsstring *post = [nsstring stringwithformat:@"user_id=%@&last_sync=%@",user_id, last_sync]; nsurl *directoryurl = [nsurl urlwithstring:directoryuri]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:directoryurl]; [request sethttpmethod:@"post"]; [request setvalue:@"application/x-www-form-urlencoded" forhttpheaderfield:@"content-type"]; [request sethttpbody:[nsdata datawithbytes:[post utf8string] length:[post length]]]; the content type same on simulated requests. there no errors returned, no content. i use afnetworking library, takes lot of pain out of http comms. my post calls along lines below: nsurl *nsurl = [nsurl urlwithstring:@"http://someurl.com"]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:nsurl]; [request sethttpmethod:@

jquery - Spring MVC: 415 (Unsupported Media Type) Error -

it recurring issue , have found few solutions.but none of work me. trying post form jquery ajax. note: posted yesterday, thinking client side issue. tried possible on client side no luck. spring controller @requestmapping(value="/save",method=requestmethod.post,consumes="application/json") @responsebody public string handlesave(@requestbody string formdata) { system.out.println(formdata); } jquery request (tried people suggested in comments) it works fine if send data:$(this).serialize() , contenttype:application/json $('form').submit(function () { $.ajax({ url: $(this).attr('action'), type: 'post', data: collectformdata(), headers: { "content-type":"text/xml" }, datatype: 'xml;charset=utf-

javascript - Is it possible to reference a variable -

i have object 30 'values' or whatever called, example: var list = new object(); list.one = 0; list.two = 0; list.three = 0; ... list.thirty = 0; is there simple/efficient way me able increment values of list object? for example let's there 100 buttons, each button if pressed increase value amount. i'm trying short function like: function test( value, amount, math ) { if( math === "add" ) { value += amount; } else if( math === "sub" ) { value -= amount; } } but whole value thing doesnt work =(. other way can think doing creating 30 functions, each function same thing above each 1 specifies list value add or subtract to. or make single function if value === "one" list.one etc. other ideas? i've thought using array i'd prefer having code easy read since list values have specific names make easy me in other functions. thanks in advance help is possible reference variable? no. possible refere

ruby - Massaging a mongoid habtm with a string for a class -

i started off https://gist.github.com/scttnlsn/1295485 basis make restful sinatra app. i'm having difficulty, though, managing habtm relationships paths such as delete '/:objecttype/:objid/:habtm_type/:habtm_id' i have objecttype map (as per gist), , pulling right object db id straightfoward. however, getting other side of habtm , calling appropriate method on objecttype delete relationship involves turning handful of strings appropriate objects , methods. i came solution, uses eval. i'm aware using eval evil , doing rot soul. there better way handle this, or should put in safeguards protect code , call day? here's working, self contained, sinatra-free example show how i'm doing eval: require 'mongoid' require 'pp' def go seed frank = person.find_by(name:"frank") apt = appointment.find_by(name:"arbor day") pp frank really_a_sinatra_route(frank.id, "appointments", apt.id) frank.reload

python - glib main loop hangs after Popen -

i'm trying build script logs window title when different window becomes active. have far: import glib import dbus dbus.mainloop.glib import dbusgmainloop def notifications(bus, message): if message.get_member() == "event": args = message.get_args_list() if args[0] == "activate": print "hello world" activewindow = popen("xdotool getactivewindow getwindowname", stdout=pipe, stderr=pipe); print activewindow.communicate() dbusgmainloop(set_as_default=true) bus = dbus.sessionbus() bus.add_match_string_non_blocking("interface='org.kde.knotify',eavesdrop='true'") bus.add_message_filter(notifications) mainloop = glib.mainloop() mainloop.run() however, apparently wrong popen call, , glib seems swallow error. @ least, on irc channel told me. when remove popen , activewindow.communicate() calls, keeps working , message "hello world!" printed in s

getting null json grid data from jqgrid in struts2 action class .please guide in proper direction -

$.ajax({ type: "post", url: "senddata.action", datatype:"json", data : datatosend, contenttype: "application/json; charset=utf-8", success: function(response, textstatus, xhr) { alert("success"); }, error: function(xhr, textstatus, errorthrown) { alert("error"); } }); datatosend getter , setter.. should have parse java array list or have print datatosend in ajax send data below data :{"datatosend":data} //where "data" data u want send and datatype of "datatosend" depends on type of data u send.

Ruby on Rails 4 API - update devise user -

i'm trying build api rails 4. everything(show/delete/create) works fine, update gives me error: activemodel::forbiddenattributeserror in api::v1::userscontroller#update my update method this: def update @user = user.find_by_id(params[:id]) if @user.nil? logger.info("user not found.") render :status => 404, :json => {:status => "error", :errorcode => "11009", :message => "invalid userid."} else @user.update(params) render :status => 200, :json => {:status => "success", :user => @user, :message => "the user has been updated"} end end i send post request http://localhost:3000/api/v1/users/3 , i'm sending username:testuser via patch - should right rails 4. i guess i'm forgetting allow paramets updated? i forgot syntax in rails 4. needed replace @user.update(params) @user.update_attributes(params.permit(:email, :username, :password))

php - Inserting Specific Image for MYSQL Database -

i creating application grabs list of instagram images , inserts ones (based on choice) specific database. currently, when select submit button grabbing last available image in list , inserting database. each image assigned submit button. how make sure proper image, relative submit button, 1 being inserted database. the following code list of images , submit button each image: foreach ($media->data $data) { echo $pictureimage = "<img src=\"{$data->images->thumbnail->url}\">"; echo "<form action='tag.php' method='post'>"; echo "<input type='submit' name='submit' value='click me'>"; echo "</form>"; } this how inserting image database. remember, grabs last available image in list , inserts that. if(isset($_post['submit'])) { // there variables database information $hostname = "random"; $username = "random"; $dbname = &q

c++ - Conditional expression in Makefile -

i know can use if statements following in makefiles: foo: $(objects) ifeq ($(cc),gcc) $(cc) -o foo $(objects) $(libs_for_gcc) else $(cc) -o foo $(objects) $(normal_libs) endif is there way conditional replacement possibly ternary type operator. (condition?$(cc):$(cc2)) -o foo $(objects) $(libs_for_gcc) and if there isn't idiomatic way achieve example i added c++ tag because question had 7 views , figured used c++ might know answer,i know isn't strictly c++ question(though planning compile c++ it) edit: looks there if function using syntax $(if condition,then-part[,else-part]) i'm still little confused on how works though the $(if ...) function can serve ternary operator, you've discovered. real question is, how conditionals (true vs. false) work in gnu make? in gnu make anyplace condition (boolean expression) needed, empty string considered false , other value considered true. so, test whether $(cc) string gcc , yo

c# - Using methods on Generics -

i have ton of methods this: public uipcompanybutton addcompanybutton (string name, company company, uieventlistener.voiddelegate methodtocall, gameobject contents) { return uipcompanybutton.create (name, company, methodtocall, contents); } that i'd replace single method this: public t addbutton<t,k>(string name, k item, uieventlistener.voiddelegate methodtocall, gameobject contents) t:uipmenubutton { return t.create(name, item, methodtocall, contents); } which doesn't work @ t.create part. there syntax need this? i'm open different method same result: single method takes in derived menubutton , creates right 1 right class of "item". no, can't call static methods on generic types - not without reflection. aside else, there's no way of constraining generic type have specific static members. closest parameterless constructor constraint.

sql server - Within While Loop how to execute "Use [database name] Go" -

i need shrink log file every database weekly. writing while loop query loop each database. don't think allowed following: declare @database_id int declare @database varchar(255) declare @log varchar(255) declare @cmd varchar(500) while (select count(*) #logfiles processed = 0) > 0 begin set @database_id = (select min(database_id) #logfiles processed = 0) set @database = (select name #logfiles database_id = @database_id , [type] = 0) set @log = (select name #logfiles database_id = @database_id , [type] = 1) select @database, @log set @cmd = 'use ' + @database exec(@cmd) set @cmd = 'dbcc shrinkfile (' + @log + ');' exec(@cmd) update #logfiles set processed = 1 database_id = @database_id end or there way so? thanks as mentioned in multiple comments, really, really, isn't idea. shrinking these files can grow again next week wasted effort and, since log file autogrow events c

javascript - JQuery Dialog Modal Box Frame -

i trying use dialog element on page, having issues. appear box not showing up. have iframe inside dialog working (aside sizing issues), title bar of box , (sometimes) buttons not shown. have seen online cause of typically jquery ui css file not included, don't think problem here, have link, copied page creating dialog boxes properly. can't decide if relevant or not, creating pages in sharepoint designer, , using 2 different standards evaluate pages, 1 of (the non-working one) claims <link> tag error, saying 'in xhtml 1.0 strict tag cannot contain .' however, there no <div> around <link> tag, , designer says many of sharepoint-created tabs named <sharepoint:...> not allowed in version of xhtml. code creates dialog included reference: <div id='am_scheddetailmodal' title='details'> <div class='ui-widget'></div> </div> $(document).ready(function() { $("#am_scheddetailmodal&

linux - Hashtag instead of the dollar sign ssh shell -

hello got server centos 5 (64 bits) installed , when i'm connecting putty after entering user root , password hashtag instead of dollar sign i'm confuse. [root@mokmeuh ~]# also it's seems alot of command don't work like [root@mokmeuh ~]# $chmod u+x file.sh that's 1 can't run shell script or i'm confuse , need help. yep, hashtag says you're root. normal users have dollar sign. but shouldn't write dollar sign in front of commands. leave it.

asp.net mvc - Import aspect is not working using MEF -

using mefcontrib.mvc3 on mvc web application. used following class initialize mef before application start event. class auto generated(downloaded) nuget. tiny changes applied catalog(for plugins folder) , controller factory segments. [assembly: webactivator.preapplicationstartmethod(typeof(omr.cms.app_start.mefcontribmvc3), "start")] namespace omr.cms.app_start { using system.componentmodel.composition.hosting; using system.linq; using system.web.mvc; using mefcontrib.hosting.conventions; using mefcontrib.web.mvc; public static class mefcontribmvc3 { public static void start() { // register compositioncontainerlifetimehttpmodule httpmodule. // makes sure cleaned correctly after each request. compositioncontainerlifetimehttpmodule.register(); // create mef catalog based on contents of ~/bin. // // note class in referenced assemblies implementing in "

javascript - Retriew object in relational field on parse.com -

i've created table in parse called user , there relational field friends pointing same table user.now i've fetched backbone collection of user , single user.how can list of object contained field friends?i've tried method backbone returns object this:object {__type: "relation", classname: "_user"}. var cur_user = parse.user.current().id; var self = this; models.utenti = new usercollection(); models.utenti.fetch({ success: function (object) { var cur_user = parse.user.current().id; // gives u user model var user = models.utenti.get(cur_user); // lets friends list not collection yet // assuming it's object var friends = user.get("friends")); // create friends collection var collections.friends = new friendcollection(friends); var view = new friendsview({ collection: collections.friends });

python - Using psycopg2 on Windows I get unwanted debug messages -

everybuddy. i've installed psycopg2 package psycopg2-2.5.1.win32-py2.6-pg9.2.4-release.exe found in site http://www.stickpeople.com/projects/python/win-psycopg/ . can import , connect database, when run scripts on command-line (both, standard , cygwin) unwanted messages printed stderr. for example: conn = psycopg2.connect(host="42.42.42.42", port=5432, database="mydb", user="myuser", password="********") if conn none: sys.exit("connection failed") print "connection successful" prints following: debug: committransaction debug: name: unnamed; blockstate: started; state: inprogr, xid/subid/cid: 0/1/0, nestlvl: 1, children: connection successful i've been unable turn messages off. searched in google couldn't find relevant, , tried changing config of standard logging module, in case of being used, still no avail. does know how prevent messages? thanks in advance! it looks build m

Forward email using Amazon SES: 554 Message rejected: Email address is not verified. -

i have ec2 instance postfix installed. there no inboxes. email forwarded using settings users define in postfixadmin. when enable amazon ses, website can send emails fine. problem arrises when forward mail. in email header, "from" field remains same. amazon ses rejects since not verified sender or domain. how can remedy this? want continue using amazon ses make sure don't blacklisted. not lot of options here. amazon ses mail notification service more pure smtp server. because of this, of emails/domains must verified , of mail sessions must authenticated. the alternative can figure out configure postfix proxy instead of relay, replaces header known address, verified ses, , authenticates in ses.