Posts

Showing posts from February, 2014

How should I implement Default Associated Values with Swift Enums? -

swift question there way of having enum type 1 case can have associated value. i have api gives me available filters, it's unlikely possible api add additional filter types. if api sends unknown filter type want keep information associated enum. below different ideas had doing this. my first 2 tries didn't compile. third try feels bit clunky. does have better way of doing this? think shouldn't use enum problem? typealias apifilteridentifier = string /* not compile */ enum enumtestassociatedvaleu: apifilteridentifier { case unknown(apifilteridentifier) case = "everyone" case team = "myteam" } /* not compile */ enum enumtestdefaultassociatedvalues: apifilteridentifier { case unknown(apifilteridentifier) case everyone(apifilteridentifier = "everyone") case team(apifilteridentifier = "myteam") } /* compiles there better way? */ enum enumtestwithcustominit { case unknown(apifilteridentifier)

Spring SAML2 Sample Compilation Errors -

i have downloaded spring saml2 core , sample projects. when trying compile sample project in eclipse, shows errors. for example, in class org.springframework.security.saml.web.metadatacontroller there references metadatagenerator.setentityalias(..) not resolve. i checked source code of metadatagenerator in saml2 core project , there no such method. what missing? it worked me 1.0.0.rc2 , not later versions. pointing following repository: <repository> <id>spring-milestones</id> <name>spring milestones</name> <url>http://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository>

Azure media player preview image -

is there way specify poster or preview image of video azure media player mentioned on page http://amsplayer.azurewebsites.net/azuremediaplayer.html thanks help. use "poster" attribute on video tag. for example: <video id="azuremediaplayer" poster="~/content/img/preview.png" class="azuremediaplayer amp-default-skin amp-big-play-centered" controls width="640" height="480" data-setup='{"logo": { "enabled": false}, "nativecontrolsfortouch": false}' tabindex="0"> <source src="{video_src}" type="application/vnd.ms-sstr+xml" /> <p class="amp-no-js">to view video please enable javascript, , consider upgrading web browser supports html5 video</p> </video> if don't specify value poster attribute player use first frame of source video poster.

common table expression - SQL Server 2008R2 - WITH CTE AS disappears -

i have table owner names , multiple addresses. want select 1 address , doesn't matter 1 gets pulled long 1. i've created view syntax below , have nested in view. with cte ( select distinct ownerlesseeid, addressid, row_number() on (partition ownerlesseeid order ownerlesseeid) ol ownerlesseeaddress) select distinct ownerlesseeid, addressid, ol cte ol = 1 it runs , executes desired. however, every time save , close view cte ( disappears. whenever re-open have insert in part again execute query. according to: https://msdn.microsoft.com/en-us/library/ms175972(v=sql.105).aspx temporary expression. i don't think can use max() because ownerlesseeid uniqueid field. ideas on how mitigate problem?

razor - MVC Partial View Postback calling wrong method -

i have following partial view html.formbegin helper method; @if (session["userspecific"]!=null) //(request.isauthenticated) { using (html.beginform("logoff", "account", formmethod.post, new { id = "logoutform", @class = "navbar-right" })) { @html.antiforgerytoken() @* @html.actionlink("hello " + user.identity.getusername() + "!", "index", "manage", routevalues: null, htmlattributes: new { title = "manage" })*@ <input type="button" class="menu-button nav navbar-nav navbar-right" data-target=".customer-list" data-toggle="collapse" /> <div class="customer-list-container"> <div class="customer-list collapse"> <ul> @{ string[] array = { "steel company", "

oracle - Which hotel has the most stayings? -

i pretty new @ oracle, , doing examples found on 1 of websites learn new. 1 of tasks tables, hotel has stayings. find 1 problem realy complex , can not solve myself, happy if me soultion , explanation why is way. i understood question in way, have connect visitor , visited , hotel , owning , owner tables. to explain. owning table connecting owners hotels , visited table connecting visitors hotel in stayed. this tables example: pastebin link example . what have tried far is: select visitor.id, visitor.name, visitor.surname, hotel.name visitor left join visiting on visitor.id = visiting.tk_visitor left join hotel on hotel.id = visiting.tk_hotel order hotel.id asc; this connecting 3 tables, visitors , hotels connected in 1 table, can't go further. i hope able me, can learn new on example. thanks in addition! which hotel has stayings[?] each visit corresponds 1 row in table visited , therefore want count rows of visited on per-hotel basis. t

angularjs - How to bind an absolute path using data-ng-src in Angular JS -

hi um using angular first time bind data img tag um using <img data-ng-src="{{img.filepath}}" alt="{{img.vehicleid}}" style="width:10%" /> to show image , value of img.filepath follows wont show up d:\country\province\city\images\a0001\2676199\aaaaaaaa-5a59-4bfb-b1ba-0faff297b7b1.jpg there no compile errors or other errors in code. image available in correct path. why not working ? thank in advance from index.html(main html load js) track file location. if index.html in "d:\country\" then in ng-src ="province/city/imagesa0001/2676199/aaaaaaaa-5a59-4bfb-b1ba-0faff297b7b1.jpg"

shell - converting a list of files to a hyphen separated list -

say have folder contains following files stuff1001.f stuff1002.f stuff1003.f ... stuff1099.f i have command requires me enter these files in hyphen separated list such that command.py -i stuff1001.f-stuff1002.f-stuff1003.f-... how can i: have terminal print out full hyphen separated list can copy/paste it? enter code command this? the following may help: ls -1 | tr '\n' '-' the ls -1 (that's dash one ) command writes name of each file in current directory separate line. tr '\n' '-' command translates each newline hyphen. end result hyphen-separated list of files in current directory.

javascript - Fixed divs under the bootstrap fixed nav -

i'd attach fixed alerts underneath navbar-fixed navigation bar in bootstrap. best attempt point make div positioned @ 50px position: fixed; , width: 100% , , insert alerts in div. problem cuts off top of other content same way navbar-fixed cuts off content when 1 fails apply padding body element. #alerts { position: fixed; width: 100%; top: 50px; } .alert { top: 0px; //position: fixed; padding-left: 15px; padding-right: 15px; padding-top: 4px; padding-bottom: 4px; margin-bottom: 0px; border-radius: 0px; } body { padding-top: 50px; // avoid 'underlapping' navbar } here's link not-working example: http://www.bootply.com/pnehtlhubi my best idea @ moment use js adjust padding-top value on body alerts created/destroyed, bad maintenance/readability , i'd prefer more declarative css. any suggestions? looks there won't way without js. since if alert dynamic, meaning appears when triggers via alert method $('#al

Is it ok to use JSON strings for relations in Oracle database -

some time ago joined project oracle (11.2) database. json strings heavily used in relational data: instead of using separate tables many many relationships, json string used. example: let's suppose have student , lecture tables. in our architecture student table have "lectures" column. contain json array lecture names (not lecture ids even, names). 1 many relations though, other's table id used instead of json. often whole objects stored inside json columns, instead of separate tables. student can have i.e. grades column have jsons { grade: 'a', date: '2015-01-01', lecture: 'mathematical analysis'} objects retrieved microorm , jsons parsed in c# code json strings become lists of simple objects. each json column have code this: private string _lecturesjson; public string lecturesjson { { return lectures.tojson(); } set { _lecturesjson = value; lectures = value.fromjson<list<string>>(); } }

python 3.4 - tor name not recognized in stem -

i trying follow "to russia love" tutorial ( https://stem.torproject.org/tutorials/to_russia_with_love.html ) getting error: [1mstarting tor: [0m traceback (most recent call last): file "c:\users\gatsu\my documents\liclipse workspace\torcommunicator\tutorialstart.py", line 52, in <module> init_msg_handler = print_bootstrap_lines, file "c:\python34\lib\site-packages\stem\process.py", line 244, in launch_tor_with_config return launch_tor(tor_cmd, args, torrc_path, completion_percent, init_msg_handler, timeout, take_ownership) file "c:\python34\lib\site-packages\stem\process.py", line 83, in launch_tor raise oserror("'%s' isn't available on system. maybe it's not in path?" % tor_cmd) oserror: 'tor' isn't available on system. maybe it's not in path? what missing? need import project or add tor path? using windows 8.1. that means stem doesn't know tor executable loca

My requirement is In android I have 4 dynamic columns of images in which there shoud be a empty column after second column -

please suggest best approach follow. tried grid view not able empty column if not want use gridview (should work fine case), use gridlayout . not advise if going have lot of imageview s, because need recycling abilities of gridview . in case of gridlayout , can create base gridlayout , set 5 columns , use gridlayout.addview(view, layoutparams) append new imageview s. when on second column add space view. some simple pseudocode: for(int = 0; < imagelist.size(); i++) { imageview imageview = getimageviewusinglist(i); if((i % 5) % 2 == 1) { gridlayout.addview(new space(), layoutparams); } else { gridlayout.addview(imageview, layoutparams); } }

php - Stored non-English characters, got '?????' - MySQL Character Set issue -

my site working on in farsi , text being displayed ????? (question marks). changed collation of db tables utf8_general_ci still shows ??? i ran following script change tables did not work well. i want know doing wrong <?php // connection mysql_connect("mysql.ord1-1.websitesettings.com","user_name","pass"); mysql_select_db("895923_masihiat"); // convert code $res = mysql_query("show tables"); while ($row = mysql_fetch_array($res)) { foreach ($row $key => $table) { mysql_query("alter table " . $table . " convert character set utf8 collate utf8_unicode_ci"); echo $key . " =&gt; " . $table . " converted<br />"; } } ?> bad news. first, double check: select col, hex(col)... to see in table. if hex shows 3f , data gone. correctly stored, dal character should hex d8af ; hah hex d8ad . what happened: you had utf8-encoded data

c++ - Why does my dialog box appear like this? -

Image
i have created simple dialog box in resource file. when try spawn using dialogbox(), dialog appears looks not have window. don't know why happens. advice? it looks when running, can see there no window. check boxes, text , stuff don't have background, , there no title bar. nothing. and should show this: the code use spawn is: bool mostrarventanaconfiguracion() { dialogbox(getmodulehandle(0), makeintresource(id_diag_config), null, (dlgproc)ventanaconfiguracion); return true; } this .rc file code: language lang_neutral, sublang_neutral id_diag_config dialog 260, 200, 339, 203 style ds_3dlook | ds_center | ds_modalframe | ds_shellfont | ws_caption | ws_popup | ws_sysmenu | ws_border | ws_visible caption "configuración" font 8, "ms shell dlg" { ltext "pulsar la combinación de teclas.", 0, 218, 18, 102, 9, ss_left, ws_ex_left control "", id_conf_macro, hotkey_class, ws_tabstop, 136, 16, 77

jquery - scrollTop inside position Fixed -

i facing issue need use scrolltop inside div thats position fixed , overflow-y. did see post using scrolltop inside of fixed element overflow-y:scroll the issue have is, error element have scroll positioned inside content relative positioned. code not work my fiddle http://jsfiddle.net/5446a6ds/2/ if remove parent relative positioning, works, cannot that. error may positioned anywhere within content relatively positioned., scrolling content not option. html <div id="relativedad"> <div id="containerparent"> <div id="containerchild"> <section id="content"> form<br> form<br> form<br> form<br> form<br> form<br> form<br> form<br> form<br> form<br> form<br>

ios - setting frame in swift doesn't work as expected -

Image
i'm porting app objective-c pure swift , i'm facing strange problem. i've got alertview class replacement standard uialertview (now uialertcontroller ) displaying animatable popups. alertview created in uiviewcontroller extension - it's inited view controller's view frame , added subview. alertview has property popupview 's instance - custom uiview subclass xib (on autolayout). popup should has dynamic height depends on contents (multiline message label). now when i'm trying animate popup in alertview class: when set in popupview settranslatesautoresizingmaskintoconstraints(false) - view's height correct setting frame in animation doesn't work expected - view sticked top left corner when set settranslatesautoresizingmaskintoconstraints(true) - animation works expected view has size xib (won't expand according contents) what can wrong here? edit showing popup method: private func showpopup(popupview: popupview) {

html - ng-maxlength $error message not showing -

using ng-maxlength="80" in <input> field. expected this: <span class="select2-container text-error resize" ng-show="myform.samplename.$error.maxlength">this can't longer 80 characters.</span> to show if <input> field has more 80 characters. however, error message not show. input field gets red border. nothing else. here part of form: <form name="myform" class="form-horizontal" ng-show = "isformactive()" novalidate> <div class="control-group"> <label class="control-label buffer-right"><h5>name:</h5></label> <div class="input-prepend buffer-left"> <span class="add-on"><i class="icon-pencil"></i></span> <input type="text" name="samplename" ng-model="person.name" ng-minle

c# - How can I tell that my program is under unit test environment -

i have console application. in release environment, works @ time. when in ide debug environment, don't want console window close, added function, , calling in end of program. [conditional("debug")] public static void debugwaitakey(string message = "press key") { console.writeline(message); console.readkey(); } it works me, when debug program. unit testing, still wait key before exiting! the work-around unit-testing release edition of program, or test other functions. want can identify current session under unit testing, , use flag in function. i believe this should answer question. took class there , adapted situation. /// <summary> /// detects if running inside unit test. /// </summary> public static class unittestdetector { static unittestdetector() { string testassemblyname = "microsoft.visualstudio.qualitytools.unittestframework"; unittestdetector.isinunittest = appdomain.currentdomain.g

ios - Using JSQMessages framework with Core-data -

this core-data object message: #import <foundation/foundation.h> #import <coredata/coredata.h> @class account; @interface message : nsmanagedobject @property (nonatomic, retain) nsnumber * read; @property (nonatomic, retain) nsdate * sentdate; @property (nonatomic, retain) nsstring * text; @property (nonatomic, retain) nsstring * receiver; @property (nonatomic, retain) nsstring * sender; @property (nonatomic, retain) account *account; @end then messages viewcontroller, load messages code: - (void)loadmessages messages = [[nsmutablearray alloc]initwitharray:_fetchedresultscontroller.fetchedobjects]; //------------------------------------------------------------------------------------------------------------------------------------------------- demo message demo incoming message. static nsstring *senderid = @"2"; static nsstring *senderdisplayname = @"a"; jsqmessage *message = [[jsqmessage alloc] initwithsenderid:senderid

twitter bloodhound engine not working according to twitter-typeahead examples -

i have been using twitter typeahead quite time easy , convenient remote data. decided upgrade latest version (typeahead.js 0.10.5) use robust bloodhound engine. having quite problem bloodhound, below code used directly https://twitter.github.io/typeahead.js/examples/ prefetch example , code not seem work no matter what. i assume url calling correct link works fine me , see countries. thing have changed prefetch remote , not work prefetch either. have tried other examples on stackexchange here works suggest calling scripts in header correctly, when change url 1 provided twitter not work. know if using code copied twitter-typeahead examples correctly. <div id="prefetch"> <input class="typeahead" type="text" placeholder="countries"> </div> <script type='text/javascript'> $(function() { var countries = new bloodhound({ datumtokenizer: bloodhound.tokenizers.obj.whitespace('name

java - Tomcat server is not starting if i make changes in server.xml in conf folder -

whenever changed server.xml mysql properties tomcat server blinking , stopping how solve issue <realm classname="org.apache.catalina.realm.jdbcrealm" drivername="com.mysql.jdbc.driver" connectionurl="jdbc:mysql://localhost:3306/test?user=root;password=root" usertable="users" usernamecol="user_name" usercredcol="user_pass" userroletable="user_roles" rolenamecol="role_name"/> without more information, issue can see connectionurl wrong, url parameters separated & , html encoding &amp; : <realm classname="org.apache.catalina.realm.jdbcrealm" drivername="com.mysql.jdbc.driver" connectionurl="jdbc:mysql://localhost:3306/test?user=root&amp;password=root" usertable="users" usernamecol="user_name" usercredcol="user_pass" userroletabl

Change facebook page tab name dynamically -

is there way change name user sees on facebook page tab depending on locale? example: english user visiting page see "games" page tab name, , spanish user see "juegos" on same tab. the closest thing i've found "localize" option on app, can add support different languages. way when page installs app different tab name, description... depending on page language. but seems it's not possible wanted.

android - How can i get the url from an Image using two activities? -

i have 2 activities, 1 called listview, , second activity called informations, shows specific information specific user. and pass 1 image listview, informations activity. to image url user, i'm trying use intent. listview activity lv.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { string checkid = ((textview) view.findviewbyid(r.id.id)) .gettext().tostring(); string checkimage = ((imageview) view.findviewbyid(r.id.list_image)).getcontext().tostring(); intent in = new intent(getapplicationcontext(), userprofile.class); in.putextra("teste", checkid); in.putextra("teste2", checkimage); startactivity(in); } }); informations activity intent intent = getintent(); string id = intent.getstringextra("teste"); string image = intent.ge

python - 403 Error with tweepy -

i trying use tweepy operate twitter account using python appear have slipped @ the first hurdle. no matter try, keep getting 403 error no specific details. import tweepy # consumer keys , access tokens, used oauth consumer_key = 'xxxxxxxxxxx' consumer_secret = 'xxxxxxxxxxx' access_token = 'xxxxxxxxxxxx' access_token_secret = 'xxxxxxxxxxx' # oauth process, using keys , tokens auth = tweepy.oauthhandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) # creation of actual interface, using authentication api = tweepy.api(auth) # sample method, used update status api.update_status('hello') (keys blanked out, assure twitter provides) this basic code provided tutorial, returns traceback (most recent call last): file "c:\users\sam\documents\python\tweepy\tweepy.py", line 22, in <module> api.update_status('hello') file "c:\pyt

php - How to order rows by a field that exists on both table while using JOIN statement -

main table: 'posts'. structure: id || text || time || user_id secondary table: 'likes'. structure: id || post_id || time || user_id here, post_id 2nd table can (& must) id 1st table. running query fetch ids posts table of specific user_id , post_ids likes table of specific user_id. query: select p.id posts p left join likes l on p.id=l.post_id p.user_id=$userid or l.user_id=$userid the time field on both table numeric, type int (12). unix timestamp stored in here, 1234567890 . order data i'm fetching time field on both table. for example, there 2 posts in posts table, post id 1 has time value of 1234567891, post id 2 has time value of 1234567896. , there's 1 post id 3 in likes table time value of 1234567893. i order rows time, this: post id 1, post id 3, post id 2. as post id 3 occured before post id 2. how go since time , it's value can in either tables. thanks! after join have 2 time columns, 1 each table. ne

datatables - R shiny build links between tabs with DT package -

solution creating links between tabs have found here r shiny build links between tabs nice, it's not working dt package (for me..). can tell me, doing wrong in example code using dt library in compare solution without dt package? library(shiny) library(dt) server <- function(input, output) { output$iris_type <- dt::renderdatatable({ datatable(data.frame(species=paste0("<a href='#filtered_data'>", unique(iris$species), "</a>")), escape = false, options = list(initcomplete = js( 'function(table) { table.on("click.dt", "tr", function() { shiny.oninputchange("rows", table.row( ).index()); tabs = $(".tabbable .nav.nav-tabs li a"); $(tabs[1]).click(); }); }'))) }) output$filtered_data <- dt::renderdatatable({ if(is.null(input$rows)){ iris }else{ iris[iris$species %in% unique(iris

Typescript: Object of T but value is Predicate -

for following function (see http://ramdajs.com/docs/#where ) var spec2 = {x: function(val, obj) { return val + obj.y > 10; }}; r.where(spec2, {x: 2, y: 7}); //=> false r.where(spec2, {x: 3, y: 8}); //=> true i create typing case object t has value of predicate. i thinking this: where<t>(spec: {item: (val: any, testobj: t) => boolean}, testobj: t): boolean; but i'm not sure key. there isn't way represent in typescript type system.

javascript - Can't store a boolean returned by a function in a variable -

this question has answer here: boolean variable returns string javascript function 2 answers i don't know if bug, feels kind of strange. can store boolean returned function in variable using javascript? whenever try store boolean value in variable returned function, gets changed string. i have following function converts string boolean function str2bool(strvalue){ console.log("value - " + strvalue); console.log("type - " + typeof strvalue); return (strvalue && typeof strvalue == 'string') ? (strvalue.tolowercase() == 'true') : (strvalue == true); } i've found function somewhere here on stackoverflow, not remember it's author, if reading this, sorry me not giving proper credits:) i have javascript line, looks follows: target.prop('disabled',str2bool(booleaninstringformat)); console.log

node.js - how is my webrtc audio is being heard when all elements are muted? -

in webrtc application there 2 video elements , both muted. both candidates engaged in webrtc chat has 2 peer connections. when 1 one happening working fine, other peer connection kicks in, though elements muted, still able hear sound of sender himself how possible..? this not possible. it's surely bug in code.

javascript - Google maps not drawing the map on localhost -

am trying first current co-ordinates using navigator.geolocation , use latitude , longitude draw map. but it's not showing map, blank white screen. <html> <style type="text/css"> html{height: 100%} body{height: 100%; margin: 0; padding: 0} #map-canvas{height: 100%} </style> <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script> <script> function getlocation() { if (navigator.geolocation){ navigator.geolocation.getcurrentposition(showposition); } else alert("geolocation not supported browser"); } function showposition(position) { coord = {}; coord.lat = position.coords.latitude; coord.longi = position.coords.longitude; initialize(coord); } function initialize(coord) { var map_canvas = document.getelementbyid('map_canvas'); var map_options = { center: new google.maps.latlng(coord.lat, coord.longi), zoo

Python multiprocessing doesn't seem to use more than one core -

i want use python multiprocessing run grid search predictive model. when @ core usage, seem using 1 core. idea i'm doing wrong? import multiprocessing sklearn import svm import itertools #first read data #x feature numpy 2d array #y 1d numpy array of labels #define grid c = [0.1, 1] gamma = [0.0] params = [c, gamma] grid = list(itertools.product(*params)) grid_hx = [] def worker(par, grid_list): #define sklearn model clf = svm.svc(c=g[0], gamma=g[1],probability=true,random_state=seed) #run cross validation fuction: returns error ll = my_cross_validation_function(x, y, model=clf, n=1, test_size=0.2) print(par, ll) grid_list.append((par, ll)) if __name__ == '__main__': manager = multiprocessing.manager() grid_hx = manager.list() jobs = [] g in grid: p = multiprocessing.process(target=worker, args=(g,grid_hx)) jobs.append(p) p.start() p.join() print("\n-------------------") print(&q

mysql - SQLAlchemy: how exchange unique values in one transaction? -

my versions: $ python python 3.4.0 (default, apr 11 2014, 13:05:11) [gcc 4.8.2] on linux type "help", "copyright", "credits" or "license" more information. >>> import sqlalchemy >>> sqlalchemy.__version__ '1.0.0' let's example sqlite (in production use mysql, not matter here): from sqlalchemy.ext.declarative import declarative_base sqlalchemy.orm import sessionmaker sqlalchemy import column sqlalchemy import create_engine sqlalchemy import integer, string base=declarative_base() engine = create_engine('sqlite:///:memory:', echo=true) class user(base): __tablename__ = 'user' id = column(integer, primary_key=true) name = column(string(16)) tech_id = column(integer, unique=true, nullable=true) base.metadata.create_all(engine) session = sessionmaker(bind=engine) s = session() now add 2 records: u1=user(name="user1", tech_id=none) u2=user(name="user2&

design patterns - Javascript - if with asynchronous case -

my question bit regards concept. a lot of times there such situation: if(something){ someasyncaction(); }else{ somesyncaction(); } // continue rest of code.. var = 5; the problem such case clear, don't want var = 5 call unless someasyncaction() or somesyncaction() done, now, cause soasyncaction() asynchronous way (i can think of) solve situation that: var after = function(){ // continue rest of code.. var = 5; } if(something){ someasyncaction(after); }else{ somesyncaction(); after (); } but, code ugly, hard read , looks anti-pattern , problematic. i trying think maybe can find solution promises (using bluebird @ backend) can't find something. is faced before , can me figure out? thanks! with promises, have similar pattern callback, store result first , not have call/pass callback twice: function after(result) { // continue rest of code.. var = 5; } var promise; if (something){ promise = someasyncaction

printing - Print without print dialog Android -

simple android app developed. have printing functionality working in android version 4.4 via api google. anyway final purpose print automatically default printer without ui interface. print content simple html. need custom code resolve issue. kind regards danilo i think, can't able hide print dialog, coz, printmanager class final. so, not allowed override that. when call print(string, printdocumentadapter, printattributes) activity, starts print jobs bringing system print ui. if want example printing document can refer android-wifi-print - github . prototype printing document using wifi printer.

java - Remapper variables during bytecode method inlining by ASM -

i doing online bytecode method inlining optimization using asm. changes based on example 3.2.6 inline method ( http://asm.ow2.org/current/asm-transformations.pdf ). test example (inline callee's calculate(int,int) @ caller::test) is: public class caller { final callee _callee; public caller(callee callee){ _callee = callee; } public static void main(string[] args) { new caller(new callee("xu", "shijie")).test(5, 100); } public void test(int a, int b){ int t = a; int p = b; int r = t+p-_callee.calculate(a, b); int m = t-p; system.out.println(t); } } public class callee { final string _a; final string _b; public callee(string a, string b){ _a = a; _b = b; } public int calculate(int t, int p){ int tmp = _a.length()+_b.length(); tmp+=t+p; return tmp; } } based on asm 5.0 version, code is: //maininliner.jav

php - mysql merge two queries, get count of each value from two seperate columns? -

$accepteventcount = mysql_query("select count(*) count, tbldevices.name, tblevents.sentdeviceid tbldevices,tblevents tbldevices.deviceid = tblevents.sentdeviceid group tblevents.sentdeviceid order count desc"); $declineeventcount = mysql_query("select count(*) cnt, tbldevices.name, tbldeclinedevents.deviceid tbldevices,tbldeclinedevents tbldevices.deviceid = tbldeclinedevents.deviceid group tbldeclinedevents.deviceid order cnt desc"); i'm new merging 2 queries in php mysql. tried unions i'm not able desired result. basically want count of accepted events , declined events of devices table tbldevices. 3 tables involved here. can me this? this tried! select count() count, tbldevices.deviceid,null,tblevents.sentdeviceid tblevents,tbldevices tblevents.sentdeviceid = tbldevices.deviceid group tblevents.sentdeviceid union select count() cnt,tbldevices.deviceid,tbldeclinedevents.deviceid,null tbldevices,tbldeclinedevents tbldeclinedevents.devi

Call Javascript function in PHP -

i need call javascript function , use results(json) variable php. have following function: <script type="text/javascript" src="scripts/jquery-1.9.1.min.js"></script> <script> $(function () { var baseurl = 'https://xxxxxxxxx/'; var uid = 'xxxx'; var pwd = 'xxxx'; getprod('dt.x0ceb.009', '1'); function getprod(cod_prod, qtd) { jquery.support.cors = true; $.ajax({ url: baseurl + 'api/prod?ref=' + encodeuricomponent(cod_prod) + '&qtd=' + qtd, type: 'get', jsonp: "callback", datatype: 'jsonp', username: uid, password: pwd, success: functi

unity3d - Set material color with unity C# -

i working on game in unity. game far have 3 cubes wish target. have them set in array , when hit tab targets switch between them based on distance. fine have run pickle , wish have cubes target turn red visual representation. seen on youtube people used following line of code : selectedtarget.renderer.material.color = color.red; however not work me. seen comment saying : function render deprecated. below should work... selectedtarget.getcomponent<renderer>().material.color = color.red; this code not work me either. no errors mind you, runs fine cubes not turn red. has idea on whether or not doing right? post entire script below , code on in selectedtarget(). appreciated , thank you! private void selecttarget(){ selectedtarget.renderer.material.color = color.red; } i had very same problem. had no errors. need able set color property on material, , shaders have color property. had use example self-illuminated/bumped instead of mobile/vertexlit. changing c

To create a session explicitly for first the first time page loads in Grails -

as page loads, renders lot of data , shows on view sort of slows down performance. want restrict , load data when filter applied . need way in session variable can store value on 1st login , no data should loaded in 1st session i.e. when user loads first time using login. below in controller class: if(session.dtstartdate && session.dtstartdate != '') { simpledateformat nsdf = new simpledateformat('yyyy-mm-dd') date startdatevalue = nsdf.parse(session.dtstartdate.substring(0, session.dtstartdate.lastindexof("t"))) eq("startdate", startdatevalue)//if filter applied } else{ if 1st session startdate should null --> need piece of code replaced here } i unsure maybe still have not got have tried ask properly, thought should try answer question how understood problem be. if take basic filter , add stuff may able wish using better method ? unsure startdate representing if base on if user has hit controller first time or

java - JButton in separate class file -

i wrote class contain simple jframe , want add button other class jframe when i'm trying write panel.add(new cancelbutton()) i got error: loginwindow.java:29: error: no suitable method found add(cancelbutton) can me it? import javax.swing.*; import java.awt.*; public class loginwindow { public loginwindow(){ //login window jframe frame = new jframe("movie date base"); frame.setsize(500,500); frame.setvisible(true); frame.setdefaultcloseoperation(jframe.exit_on_close); //label jlabel label = new jlabel("welcom movie date base! "); label.setfont(new font("verdana", font.plain, 18)); //panel jpanel panel = new jpanel(new gridbaglayout()); jpanel panel1 = new jpanel(new gridbaglayout()); //add panel frame frame.add(panel); frame.getcontentpane().add(panel, borderlayout.north); frame.getcontentpane().add(panel1, borderlayout.south); //grid layout gridbagconstraints c = new gridbagconstraints(); c.insets = new insets(100,10,10,10); panel.a