Posts

Showing posts from March, 2013

r - Overlapping tables from grid.arrange in gridExtra -

i'm trying build automated report have 3 charts right underneath each other without margin space between each other. i've mocked problem following rmd script --- output: pdf_document --- ```{r setup, include=false} library(gridextra) ``` ```{r, echo=false} car_tbl <- tablegrob(mtcars[1:10,]) grid.arrange(car_tbl, car_tbl, car_tbl) ``` you can see how tables overlap each other. there seems there few issues comprising problem. how use options of tablegrob , grid.arrange keep tables overlapping. how make sure nothing cut off? in other words, how set graphic take whole page if need too? how can re-actively shrink text of plot fit on 1 page? how can set size of page whatever size want? there options set knitr document print pdf page of size want? perhaps poster size if need to? there different angles approach question. here's working example 3 tables fitting in 1 chunk placed on pdf of size a2. --- output: pdf_document geometry: paper=a2pape

python - CERTIFICATE_VERIFY_FAILED error during mutual authentication -

i'm using mutual authentication , python2. generate certificates server , client use form: openssl -newkey rsa:2048 -keyout server.key -out server.crt req -x509 -nodes -days 365 i wrap sockets this: ssl.wrap_socket(s, ssl_version=ssl.protocol_tlsv1, cert_reqs=ssl.cert_required, keyfile=keyfile, certfile=certfile) and following error occurs running connect on socket on client side: file "/usr/lib/python2.7/ssl.py", line 844, in connect self._real_connect(addr, false) file "/usr/lib/python2.7/ssl.py", line 835, in _real_connect self.do_handshake() file "/usr/lib/python2.7/ssl.py", line 808, in do_handshake self._sslobj.do_handshake() ssl.sslerror: [ssl: certificate_verify_failed] certificate verify failed (_ssl.c:590) i read somewhere may incompatibility between certificates , version of python, not sure. can provide exact version of python 2 (i think python 2.7) , openssl when i'm on main computer. any figuring out appreciated.

java - WebSphere Liberty Server (IBM Bluemix) - error when run the RESTful web-service on server -

i have maven restful web service application (with jax-rs support). api works when run on tomcat v7.0 server. however, error when deploy same project on websphere liberty server, used in bluemix. when deploy application, loads without problem. able open index.jsp page well. runs of api request calls (usually requests not take input, not produce output. however, of api requests shows error: launching defaultserver (websphere application server 8.5.5.9/wlp-1.0.12.cl50920160227-1523) on java hotspot(tm) 64-bit server vm, version 1.8.0_60-b27 (en_us) [audit ] cwwke0001i: server defaultserver has been launched. [audit ] cwwke0100i: product licensed development, , limited production use. full license terms can viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.9/lafiles/en.html [audit ] cwwkz0058i: monitoring dropins applications. [audit ] cwwki0001i: corba name server available @ corbaloc:iiop:localhost:2809/names

tfs2015 - Reporting TFS 2015 tag data in custom SSRS Reports -

i need add tag reporting capability collection of custom ssrs reports query tfs_warehouse (and in 1 case had query operational store gather test case steps). these reports use sql server datasource connected custom tfs_warehouse_extensions database. if sounds familiar, asked question yesterday , got wonderful response... discovered upgraded 2013 2015 last week , dbo.workitemsare gone. i using vs 2015 , more of database developer c# programmer (i know enough dangerous). there way can tags tfs 2015 workitems ssrs reports? edit: proposed duplicate answer not same problem. whether or not work items views went missing ancillary. requirement way query tfs tags in ssrs. far consider unanswered in either thread since no 1 has proposed solution meets requirement. @cyndi, i'm program manager reporting team. reporting tags not supported aside queries query editor. have new reporting solution we're working on , reporting on tags supported. don't have exact date re

css - What are some good ideas for automatically including external link tags from inside of an NPM component folder, into a larger project using Gulp? -

what ideas automatically including external <link> tags inside of /node_modules/mycomponent/ folder, larger project using gulp? the external <link> tags use absolute paths, appear similar this: <link rel="stylesheet" href="https://www.somecdn.com/somepath/somelibrary.css"/> example font-awesome cdn href, previous <link> tag: href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" problem: have component, uses font awesome icons & external <link> tag similar what's shown above. when include component module of larger project, icons disappear larger project. yet icons appear correctly in component. what i've tested: when test component itself, icons displayed on-screen. stylesheet's external url correct. component renders correctly in-browser stand-alone npm component. using npm test cli shows unit tests pass green checkmarks. possible solutions: know can

App Crash with WebView -

please me. want put webview in app. if make new project works fine. when want put in app crash. included mainactivity / java file / layout file / logcat mainactivity import android.app.fragmentmanager; import android.os.bundle; import android.support.design.widget.navigationview; import android.support.v4.view.gravitycompat; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient; public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { private webview mwebview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mwebvie

assembly - Array definition misunderstanding? -

i read kip irvine x86 assembly book , have 2 questions. 1) meaning of definition: array2 word 5 dup(3 dup(?)) 2) difference between myarray byte 10,20,30,40,50, 60,70,80,90,100 and myarray byte 10,20,30,40,50 byte 60,70,80,90,100 in array definition? array2 word 5 dup(3 dup(?)) this creates array of 5*3 words, 30 bytes in total. none of these bytes defined value because ? placeholder means assembler assigns space not initialize contents. myarray byte 10,20,30,40,50, 60,70,80,90,100 ... myarray byte 10,20,30,40,50 byte 60,70,80,90,100 both these initializer lists declare same array. in first case list not interrupted transition line added comma. becomes important when using lengthof , sizeof operators. in first case lengthof , sizeof yield 10, in second case they'll give 5.

php - How to get date from dateTime object -

i'm trying compare 2 dates - check difference between them in minutes. code is: $first_date = new datetime($token->created_at); $first_date->format('y-m-d h:i:s'); $second_date = new datetime(); $second_date->format('y-m-d h:i:s'); $difference = $first_date->diff($second_date); $time_diff = $difference->format("%i"); var_dump($first_date); //i object object(datetime)#552 (3) { ["date"]=> string(26) "2016-04-21 10:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "utc" } how date datetime object, should compare 2 dates , check difference betwen them. thanks. $difference_in_hours = (($second_date->gettimestamp() - $first_date->gettimestamp())/3600); if difference between 2 dates greater 60 minutes: if($difference_in_hours>1) { //if so, insert desired code here }

ember.js - Ember sendAction from mixin to component without observer. also the mixin import within the component -

imagine that, a div-component had button tag , child-component named input-component ( input tag ), input-component contains action validation. mixin import inside child component. when trigger action mixin, calls child-component ( input-comp ) action getting input value. never try call action on child component. not possible! if try doing wrong! you should update data outside , give down data. data down actions up.

android - How to receive GCM message when app is closed or in background? -

when app in foreground, gcmlistenerservice called , can performance here. if app in background? when app in background, can still receive notification notification part without data part. how can customize on receive event receive gcm message when app in background or closed?? the onmessagereceived() method not called if app in background. there other method works when app in background? https://github.com/google/gcm/issues/63 i have same problem him. , in link there solution. when app in background, need server side make action. data part automatically saved in intent , send activity contains action in content filter.

php - Using get method on form, part of action url doesnt show up when submitted -

i have strange issue have following form/php form handler: <form id="search" method="get" action="page.php?pg=xxxxxx"> on submit, in url domain.com/page.pgp?action=xxxx....(more parameters here). how can pass pg=xxxx action url correctly? tried throwing & sign (page.php?pg=xxxxxx&) didn't seem work either. you passing pg value of "xxxxxx" incorrectly. these values should passed in input tags inside form, instance: <form id="search" method="get" action="page.php> <input type="hidden" name="pg" value="xxxxxx"> <input name="submit" value="submit"> </form> the previous code creates form button called "submit", , when press it, takes page action.php query string wanted in url: http://www.foo.com/action.php?pg=xxxxxx hope helps! :)

php - jQuery AJAX call failing until after refresh -

so i've asked similar question here before , got answer worked, however, after progressing in beginner project , introduction ajax, i've come across problem. seems ajax call isn't successful..until after page reloaded. noticed issue prior adding more text fields form, can't imagine how related. later query reliant on whether form submitted, don't want make user refresh page data pushed through database. suggestions? <form action="call.php" method="post"> <input class="oomtext" type="text" name="accountname" placeholder="account name"><br> <h2 class="oomhead2">email notifcations phone calls</h2> <input class="oomtext" type="text" name="accountemailone" placeholder="email recipient 1*"><br> <input class="oomtext" type="text" name="accountemailtwo" placeholder=&

asp.net mvc - MVC Model not updating -

the model class address { public string street { get; set; } public string city { get; set; } public string state { get; set; } public string zip { get; set; } } the controller action [httppost] public actionresult getaddress(address model) { if (!string.isnullorempty(model.zip)) { model.city = getcitybyzip(model.zip); } return view(model); } the view <div class="formrow"> @html.labelfor(model => model.city) @html.textboxfor(model => model.city) @html.validationmessagefor(model => model.city) </div> <div class="formrow"> @html.labelfor(model => model.state) @html.dropdownlistfor(model => model.state, (ienumerable<selectlistitem>)viewbag.states, new { style = "width:217px;" }) @html.validationmessagefor(model => model.state) </div> <div class="formrow"> @html.labelfor(model => model.zip) @html.textboxf

javascript - Making sticky div up to a point -

i'm trying make div start being fixed when gets div, , stop being sticky when hits div, stay in position left. position of div sticky div should stop can anywhere depending on article lenght. can work on 1 resolution, not on others. surprisingly, getting fixed works of time, "stop being fixed" part doesn't work (my div messes in height). here code: $(document).scroll(function() { var topoflastdiv = ($("#scroll_to").position().top)-630; var topoffirstdiv = ($("#tour_user_info").position().top)+20; var topoflastdivsocial = topoflastdiv+100; var y = $(document).scrolltop(), header = $("#tour_price_map"); social_media = $('#social_media_sticky'); if (y < topoffirstdiv) { header.css({position: "relative", "top" : "0px", "transform": "translatex(0)"}); header.fadein(100); social_media.fadeout(100); } if(y >= topoffi

How do you redicrect your Java application to another java file -

here's code: public class cyptography implements actionlistener { jframe frame = new jframe("cyptography"); jtextfield input = new jtextfield(); jbutton decrypt = new jbutton("decrypt"); jtextfield output = new jtextfield(); jbutton encrypt = new jbutton("encrypt"); container north = new container(); jradiobutton scytale = new jradiobutton("scytale"); jradiobutton caesarcipher = new jradiobutton("caesar cipher"); jradiobutton vigenerecipher = new jradiobutton("vigenere cipher"); container south = new container(); public cyptography() { frame = new jframe("cyptography"); frame.setlayout(new borderlayout()); frame.setsize(700,300); north.setlayout(new gridlayout(1,4)); north.add(decrypt); north.add(input); input.addactionlistener(this); north.add(encrypt); north.add(output); output.addactionlistener(this); frame.add(north, borderlayout.nort

apache 2.4 on fresh fedora: AH01630: client denied by server configuration -

i've seen hudreds of questions , of them end in changing syntax latest apache version or messing .htaccess. not in case since used fresh f23 install , never played erarlier apache versions. i'm trying set simple virtual host binds 1 of ip's. here put in /etc/httpd/conf.d/internal.conf listen 10.10.1.177:80 <virtualhost 10.10.1.177:80> documentroot "/home/www" directoryindex index.html servername internal:80 <directory “/home/www“> options indexes followsymlinks options +indexes require granted </directory> loglevel debug errorlogformat "%{cu}t %m" errorlog /var/log/httpd/internal-error.log customlog /var/log/httpd/internal-access.log combined </virtualhost> when try: curl http://10.10.1.17 from other host in network, first 403 page appears , redirected default fedora-apache page. entries entries gets

javascript - How to createText and append text to an existing element e.g. empty span? -

everywhere i've searched i've found ways append textnode after creating new element. example, they'll create new paragraph ( p ) element, , afterwards append textnode new paragraph. want add textnode existing element (in case, empty span). link code example , clarification http://pastebin.com/k1ebmr4z <span class="span"></span> <!-- append textnode here --> function newfunction(){ var textnode = document.createtextnode("ok"); // append `textnode` empty span here } thanks in advance as mentioned in comment, can add text node child of span using appendchild() method. for text can set innerhtml property of span. both examples in bin: function newfunction(){ var span = document.getelementbyid('my-span'); var otherspan = document.getelementbyid('my-other-span'); span.innerhtml = 'yo text'; var textnode = document.createtextnode("ok"); otherspan.appendchild(t

scala - Understanding Tagged Types and asInstanceOf -

i use tagged types miles sabin gist: type tagged[u] = { type tag = u } type @@[t, u] = t tagged[u] trait mytrait def tag(s: string): string @@ mytrait = s.asinstanceof[string @@ mytrait] which can use (and works): scala> tag("lala") res7: @@[string,mytrait] = lala my question is: how? how doesn't throw classcastexception : s.asinstanceof[string @@ mytrait] . point of view, "lala" of type string not of type string { type tag = mytrait} since instantiated usual string object. magic asinstanceof method? first, note whole point of tagged types avoid runtime overhead, means can't expect runtime type checks work distinguishing them! asinstanceof runtime cast, , jvm doesn't know scala type system (or java's); has classes, interfaces, , primitives. asinstanceof can cast erased type, i.e. closest jvm equivalent of scala type. erased type of string { type tag = mytrait} string , succeeds. the relevant parts of specificatio

python - Insert values in lists following a pattern -

i have following example list: list_a = [(1, 6), (6, 66), (66, 72), (72, 78), (78, 138), (138, 146), (154, 208), (208, 217), (217, 225), (225, 279), (279, 288) ..... ] and need is: after every 6 elements on list, insert in place new tuple formed last number of previous one, , first number in previous 6 tuples. after tuple inserted, insert formed first number of previous 1 plus 1, , last number of previous 1 , first number of next tuple. so result may like: list_a = [(1, 6), (6, 66), (66, 72), (72, 78), (78, 138), (138, 146), (146, 1), # <- first part (147, 154), # <- second part (154, 208), (208, 217), (217, 225), (225, 279), (279, 288) (288, 147) # <- first part .....

c++ - Overload resolution with std::function -

consider example of code: #include <iostream> #include <functional> typedef std::function<void()> func1_t; typedef std::function<void(int)> func2_t; struct x { x (func1_t f) { } x (func2_t f) { } }; int main ( ) { x x([](){ std::cout << "hello, world!\n"; }); } i sure shouldn't compile, because compiler shouldn't able choose 1 of 2 constructors. g++-4.7.3 shows expected behavior: says call of overloaded constructor ambiguous. however, g++-4.8.2 compiles it. is code correct in c++11 or bug/feature of version of g++? in c++11... let's take @ specification of constructor template of std::function (which takes callable): [func.wrap.func.con]/7-10 template<class f> function(f f); template <class f, class a> function(allocator_arg_t, const a& a, f f); 7 requires: f shall copyconstructible . f shall callable (20.10.11.2) argument types argtypes , return type r . copy co

python 2.7 - Spyder crashes after running pygame for the second time -

i have installed spyder on ubuntu 15.10 homepage instructions. running code first time works (with ipython console), after closing window repeteadly message in console , can't run code anymore until close console , restart new 1 again: it seems kernel died unexpectedly. use "restart kernel" continute use kernel if have normal python consol running warning when trying run code second time: no python consol selected run mygame.py. please select or open new python consol , try again . the version are: spyder 2.3.8 python 2.7.10 64bits, qt 4.8.6, pyqt4 (api v2) 4.11.4 on linux can 1 help?

How to pass a String variable from PHP to Javascript -

this question has answer here: how pass variables , data php javascript? 17 answers i'm trying pass string variable php javascript , giving me troubles. i pas number variable per code below , works, once introduce (or uncomment) line var cityname = <?=$city;?>; in javascript code doesn't work. believe has type of data because if introduce number scity = 3 in php works. thank you i have following php: <?php $get_total_rows = 0; $city = "london"; $db = pg_connect("$db_host $db_name $db_username $db_password"); $query = "select * table"; $results = pg_query($query); $get_total_rows = pg_numrows($results); ?> and have following javascript: <script type="text/javascript"> $(document).ready(function() { var track_load = 0; //total loaded record group(s) //var cityname

How do you trigger sharding tables in BigQuery? -

how shard multiple tables of same format in bigquery? i think native way split tables date, in form: table_name_yyyymmdd then can query entire collection of tables via table_date_range. if manually shard on other basis, can perform union query listing tables separated commas: select * table1, table2

javascript - How to make a gif animate on hover, go back to normal after unhovered -

so have bunch of elements like: <div class="hover-icon one"> <img class="original" src="sswe-images/circle_customer notifications.png"/> <img class="hovered one" src="sswe-images/customer-notifications.gif" /> </div> <div class="hover-icon two"> <img class="original" src="sswe-images/circle_field service tools.png" /> <img class="hovered" src="sswe-images/field-service-tools.gif" /> </div> <div class="hover-icon three"> <img class="original" src="sswe-images/circle_remote connectivity.png" /> <img class="hovered" src="sswe-images/remote-connectivity.gif" /> </div> where .original placeholders , .hovered gifs want animate on hover, go normal state after mouse leaves. attempt is: $('div.hover-icon').hover(function(){ var

c# - How do I make a struct immutable? -

all on stack overflow , internet see design principle keep structs immutable. unfortunately, never see implementation causes these structs immutable. assuming struct not have reference types inside it, how make struct immutable? is, how prevent mutation of of primitive field (perhaps compile-time/runtime exception)? i wrote simple test attempting make struct immutable, not using system.componentmodel.immutableobjectattribute worked: class program { static void main(string[] args) { immutablestruct immstruct1 = new immutablestruct(); console.writeline(immstruct1); //before mutation. immstruct1.field1 = 1; immstruct1.field2 = "hello"; immstruct1.field3 = new object(); console.writeline(immstruct1); //after 1st mutation. immstruct1.field1 = 2; immstruct1.field2 = "world"; immstruct1.field3 = new object(); console.writeline(immstruct1); //after 2nd mutation. c

android - Overlaying bitmap over another bitmap -

if have 2 bitmaps (b1 , b2). how can generate 3rd bitmap (b3) result of b2 drawn on b1? if can modify b1 drawing b2 on think better (for memory). thank you you create bitmap backed canvas canvas canvas = new canvas(bitmap1); canvas.drawbitmap(bitmap2); that overwrite bitmap 1. if want avoid that, create new bitmap first , pass constructor of canvas, draw bitmap 1 , 2 it.

html - W3CSS: fluid layout to center the page? -

i use w3css build responsive site. center page thought, i'd use 12-column system provide. did this: <div class="w3-container"> <div class="w3-row"> <div class="w3-col m2 l3 w3-container w3-blue"></div> <div class="w3-col m8 l6 w3-container w3-white"> <p> hello world! <br> <br> let's this. <br> <br> lot of fun... </p> </div> <!-- content column --> <div class="w3-col m2 l3 w3-container w3-red"></div> </div> <!-- content container row --> </div> <!-- page container --> i had assign class w3-container w3-col . otherwise layout wouldn't work. downside of adding w3-container is, w3-color-classes won't apply anymore. my problem : want 2

Android recyclerview, databinding and sub view animation -

could me find proper way without leak animate recylcerview's item's sub item? i want create 2 level drawer menu, menu items in recyclerview created adapter. of menu items contain sub items, , items can open arrow @ end add sub items list below parent item. want animate arrows rotate 180 degree when adapter detects parent item have open/close , show/remove sub items. the whole thing working i'm not happy solution of animation. :( what tricky part i'm using databinding fill item's data. here's class contains data: public class menuitem extends baseobservable { public observablefield<string> name = new observablefield<>(); public observableboolean selected = new observableboolean(false); public observableboolean issubitem = new observableboolean(false); public menuitem parent; public list<menuitem> subitems = new arraylist<>(0); private draweradapter.ondraweritemclicklistener listener; /* it's p

c++ - Programming Linux serial timings -

im trying write small program gets values through serial port, , presents on screen. ive read several guides this, link . now got in trouble believe timing, wrote 2 small pieces of code see if narrow problem down. the code posted here 1 sender , 1 reciever, sender outputs 11:22 , receiever should recieve , present on screen. sort of this, lots of blank lines, , skipped letters. guess im missing fundamental, due lack of knowledge :) please see code below: note, crude & indention got screwed men trying copy , paste gvim.. :) receiver: #include <iostream> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> #include <stdio.h> using namespace std; int main() { int fd; //desc serial port. char in[20]; //char array data serial port struct termios options; tcgetattr(fd,&options); cfsetispeed(&options,b19200); cfsetospeed(&options,b19200); options.c_cfla

Unable to create file on removeable sdcard in Android 5.0.1 -

i working on application needs ability create files on removeable sdcard in samsung s4 i9295 device. running stock samsung rom 5.0.1 has been rooted. test purposes, have been trying create these files hardcoding paths specific device, have been unable create files on removeable card. code below creates files expected on internal sdcard not on removeable card. //creates directory on internal sdcard public void createinternalsdcardfile(){ log.v(logtag, "create internal sdcard file initiated"); string szfilepath = "/storage/sdcard0"; file appdir = new file(szfilepath, "targetfile"); appdir.mkdir(); maketimestamp(); file exportdir = new file(szfilepath, "targetfile/" + szdatetime); exportdir.mkdir(); } //creates directory @ root of removeable sdcard public void createremoveablesdcardfile(){ log.v(logtag, "create removeable sdcard file initiated"); string szfilepath = "/storage/extsdc

GVM Error Setting Default Groovy Version -

i installed groovy gvm: gvm install groovy but when yes set 2.4.6 default version, error: rm: `/c/users/<user_name>/.sdkman/candidates/groovy/current' directory ln: `/c/users/<user_name>/.sdkman/candidates/groovy/current': cannot overwrite direc tory not sure why it's trying rm current folder create symbolic link it. ideas i'm doing wrong? current should symbolic link directory of current version, not directory itself looks reason, it's directory try moving current out of way, , trying again ps: gvm called sdkman , command sdk not gvm though gvm still works historic compatibility

Can't use button in android -

hi have been trying use onclicklistener on button give me error. code using: public class login extends appcompatactivity { private loginbutton loginbutton; private callbackmanager callbackmanager; private button testbutton; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); testbutton = (button) findviewbyid(r.id.login_activity_button); testbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { } }); and error getting: java.lang.runtimeexception: unable start activity componentinfo{com.buddifyapp.buddify.buddify/com.buddifyapp.buddify.buddify.ui.login}: java.lang.nullpointerexception: attempt invoke virtual method 'void android.widget.button.setonclicklistener(android.view.view$onclicklistener)' on null object reference what doing wrong here ? you have call setcontentview firs

appcelerator - Titanium if attribute and Alloy.Globals not working -

according documentation possible to: in xml markup, add if attribute element , assign property passed createcontroller() method. prefix property name $.args namespace. based on property passed method, application displays different label. so means if put: <label if="alloy.globals.property" color="blue">foobar</label wont work?? right i´m not using createcontroller method, because added on xml require tag. there way this? as can see in docs there examples. one of which: <alloy> <window> <label if="$.args.foobar" color="blue">foobar</label> <label if="$.args.foobaz" color="red">foobaz</label> </window> </alloy> so yes, work. long property provide set when rendering. once variable changes while view open won't update it. you'll need data binding

binary - Bit Selection in C -

i trying select bits [0:2] , bits [6:8] of bit-string 1010000000001. bits [0:2] 001 , bits [6:8] 000. tried select these bits with: int instr = 0x1401; int src2 = (instr & 0x0006); //get bits [2:0] int src1 = (instr & 0x01c0) >> 6; //get bits [6:8] printf("%04x, %04x",src2, src1); however getting src1 , src2 both 0000. can please me understand doing incorrectly can select bits [0:2] , [6:8]? look @ code: #include <stdio.h> int main (void) { unsigned instr = 0x1401; unsigned src2 = instr & 0x0007; // 7 in hex == 0000 0000 0111 in binary unsigned src1 = (instr & 0x01c) >> 6; // 1c in hex == 0001 1100 0000 in binary printf("%04x, %04x", src2, src1); } it masks out desired bits in instr , shifts them correct offset. also, when doing bit manipulation, unsigned types preferred.