Sunday, 15 July 2012

Link error while compiling llvm with a new optimization pass -



Link error while compiling llvm with a new optimization pass -

i have written new llvm optimization pass. have added pass making new directory @ next location: llvm/lib/transform/addsub

i next steps mentioned in llvm documentation: http://llvm.org/docs/writinganllvmpass.html

but while compiling getting linking errors. may build , makefile settings not correct.

relocation r_x86_64_pc32 against undefined symbol `_ztvn12_global__n_18addsube' can not used when making shared object; recompile -fpic

if have written independent llvm pass , added in new directory within llvm at: llvm/lib/transform/

what makefile or build changes need create while writing independent pass?

i ran same error when trying follow writing llvm pass guide. me, prepare adding line this:

char mypassname::id = 0;

(i had skipped on step in directions.)

llvm llvm-ir

python - Pythonic switching using functions inside a class -



python - Pythonic switching using functions inside a class -

i attempting utilize dict command function selection within class, however, next typeerror:

typeerror: a() missing 1 required positional argument: 'self'

example code:

class tt: def __init__(self): pass def a(self): print("a") def b(self): print("b") def c(self): print("c") a_diction={ '0' : a, '1' : b, '2' : c } def ad(self,data): self.a_diction[data]()

how should build switch in ad provide self both a_diction , called method a, b , c?

the error message indicates you're missing argument. suggest adding argument.

self.a_diction[data](self)

python class switch-statement

nest api target temperature for both thermostat modes -



nest api target temperature for both thermostat modes -

is possible fetch target temperature both thermostat mode (cool, heat) in 1 phone call ? have feeling can target temperature current thermostat mode , alter thermostat mode sec 1 , target temperature sec thermostat mode.

also same question changing target temps. possible alter both target temperature heat , cool mode in 1 request ?

assuming scheme can cool , heat, thermostat has 3 modes: heat, cool, heat-cool.

if in heat mode or cool mode can set target_temperature. if in heat-cool mode can set target_temperature_low_c & target_temperature_high_c.

you can retrieve target temperatures in 1 thermostat call:

https://developer-api.nest.com/devices/thermostats/$thermostat_id?auth=$auth

you can set heat-cool temperatures in 1 call, need in heat-cool mode:

{"target_temperature_low_c": 19, "target_temperature_high_c": 21}

you can set heat or cool temperature in 1 call, need in heat or cool mode:

{"target_temperature_c": 20}

you need create 2 calls set mode , set temperature(s) if not in appropriate mode.

target temperature nest-api

ruby - Display an icon before text in a QTreeView -



ruby - Display an icon before text in a QTreeView -

i'm using qtruby qt 4.8.6 , trying create tree view each item has custom icon between tree controls , name. end result should this:                      

i getting space allocated icon should go, i'm not seeing icons. have them show up?                      

here's code (simplified remove no-data border cases):

class="lang-ruby prettyprint-override">class mymodel < qt::abstractitemmodel # ... def data(index, role) case role when qt::displayrole case index.column when 0; qt::variant.new(index.internalpointer.displayname) when 1; qt::variant.new(index.internalpointer.displaytype) end when qt::decorationrole if index.column==0 # testing show static icon items qt::pixmap.new(':/resources/images/objects-scene-normal.png') end end end end @mytreeview.model = mymodel.new

if want inspect qt designer .ui file (in case tree view needs have property set have not) can seen here.

i think image cannot found path specified. verify qfileinfo::exists().

ruby qt treeview qtreeview qtruby

android - Using Umano SlidingUpPanel with limited drag area and drag button -



android - Using Umano SlidingUpPanel with limited drag area and drag button -

i'm using umano slidinguppanel 1 of test project have 1 problem wherein wanted create panel expand when press (not click) , drag image or when click button expand. later bit easy implement press i'm having hard time implement it.

for improve visual here xml panel:

<com.sothree.slidinguppanel.slidinguppanellayout xmlns:sothree="http://schemas.android.com/apk/res-auto" android:id="@+id/sliding_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="bottom" android:background="#00ffffff" sothree:panelheight="120dp" sothree:shadowheight="0dp" sothree:overlay="true" sothree:fadecolor="@android:color/transparent"> <relativelayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <imageview android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/imageview2" android:src="@drawable/test_img" android:adjustviewbounds="true" android:scaletype="centercrop" /> <imageview android:layout_width="40dp" android:layout_height="40dp" android:id="@+id/ic_menu" android:src="@drawable/menu" android:layout_marginleft="5dp" android:layout_margintop="5dp" android:onclick="showdrawer" /> </relativelayout> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="match_parent" android:background="#00ffffff"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="50dp" android:background="#00ffffff" android:id="@+id/transparent_panel"> <imageview android:layout_width="40dp" android:layout_height="40dp" android:id="@+id/ic_menu2" android:layout_marginleft="5dp" android:layout_margintop="5dp" android:onclick="showdrawer" android:visibility="gone" android:src="#00ffffff" /> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/img_expand" android:src="@drawable/img_expand" /> </linearlayout> </linearlayout> <linearlayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#66ffffff" android:id="@+id/pager_container"> <android.support.v4.view.viewpager android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v4.view.pagertitlestrip android:id="@+id/pager_title" android:background="@color/yellow" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top"/> </android.support.v4.view.viewpager> </linearlayout> </linearlayout> </com.sothree.slidinguppanel.slidinguppanellayout>

here have panel image wanted handle when expanding drawer , on code tried implement this:

imageview img_expand = (imageview) findviewbyid(r.id.img_expand); slidelayout = (slidinguppanellayout) findviewbyid(r.id.sliding_layout); slidelayout.setslidingenabled(false); img_expand.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { log.e("test", string.valueof(event)); log.e("test2", string.valueof(event.action_down)); log.e("test3", string.valueof(event.getaction())); log.e("test4", string.valueof(motionevent.action_down)); log.e("test5", string.valueof(motionevent.action_move)); if (event.getaction() == motionevent.action_move || event.getaction() == motionevent.action_down) { slidelayout.setslidingenabled(true); homecoming true; }else{ slidelayout.setslidingenabled(false); homecoming false; } } });

sadly didn't work expected. hope can guide me on this. :d

android

callback - Set default value for field using model method in rails 3 -



callback - Set default value for field using model method in rails 3 -

i have table called enrollments , have column on table called last_taken :datetime. using rails 3.2

i had constraint on database set field time.now of course of study set default time of migration. want set default value in model. looking on site solution seems callback, have tried in several forms. not working:

after_initialize :set_last_taken def set_last_taken self.last_taken ||= time.zone.now end

no matter callback utilize (i.e. before_create, before_save) value of nil when create field in console without setting field. console shows like:

1.9.3p194 :052 > enrollment.create(user_id: 22, course_id: 8) (0.3ms) begin enrollment exists (0.7ms) select 1 1 "enrollments" ("enrollments"."user_id" = 22 , "enrollments"."course_id" = 8) limit 1 sql (1.1ms) insert "enrollments" ("course_id", "created_at", "last_taken", "role", "updated_at", "user_id") values ($1, $2, $3, $4, $5, $6) returning "id" [["course_id", 8], ["created_at", sat, 11 oct 2014 14:56:53 eest +03:00], ["last_taken", nil], ["role", "user"], ["updated_at", sat, 11 oct 2014 14:56:53 eest +03:00], ["user_id", 22]] (0.8ms) commit => #<enrollment id: 108, user_id: 22, course_id: 8, created_at: "2014-10-11 11:56:53", updated_at: "2014-10-11 11:56:53", role: "user", last_taken: nil>

after_initialize should work. please write on after initialize method , check output.

after_initialize :set_last_taken def set_last_taken logger.debug("@@@@ - after initialize called") end

please check database column type , attr_accessible field.

model callback ruby-on-rails-3.2 rails-activerecord

javascript - pareser error while sending data as json to php script using jquery ajax -



javascript - pareser error while sending data as json to php script using jquery ajax -

i'm sending info sever @ localhost using jquery's $.ajax.

the info json object.

as follows:

javascript

var jso={ "data": { "game_name": "road rash", "cheat": "xyzzyspoon!", "effects": [ { "nitro": true }, { "chain": false } ] } }; function senddata(){ var querystring=json.stringify(jso); $.ajax({ type: "post", url: "/gamers_cheats.php", contenttype: "application/json; charset=utf-8", traditional: true, datatype: 'json', data: querystring, success: function(data){ console.log(data); }, error: function(data,textstatus,jqxhr){ alert("unknown error occured :- \n "+textstatus+"\n error"); console.log("unknown error occured :- \n "+textstatus+"\n error"); } }); } senddata();

and handling info in php file as:

gamers_cheats.php:

<?php var_dump($_post); echo"\n count:- ".count($_post); // demo file ?>

but problem $.ajax alerts error: part textstatus parsererror. same happening if didn't utilize json.stringify.

and if lines:

contenttype: "application/json; charset=utf-8", traditional: true, datatype: 'json',

were removed request sent sever isn't valid request adds slashes (\) every (") in json object.

like:

\"data\": { \"game_name\": \"road rash\", \"cheat\": \"xyzzyspoon!\", \"effects\": [ { \"nitro\": true }, { \"chain\": false } ] }

so gives error while processing on server side. there way send post json info using jquery ajax , handle on server?

and 1 more question, can add together $_post parameters not in json format querystring data: querystring +"&&navigator="+navigator.useragent+"" ? ain't working (this not of import though, curious it).

fyi i'm running iis 7 server php 5.2 , jquery version 1.7.2 json2.js .

hope experts here help me.

removing line 'var querystring=json.stringify(jso);' , passing object jso info may help. seek once.

javascript php jquery ajax json