Posts

Showing posts from March, 2013

How to get reference id if 2 column values match in excel vba -

hi i'm new excel vba , started working on creating macro. have 2 sheets, sheet1 has 4 columns (id, refid, value, code) , sheet2 has 3 columns (refid, value, code). need fill sheet1 refid column sheet2 refid column comparing value & code columns of sheet1 , sheet2. possible using vlookup? options? when using vlookup , value looking for, has in first column of matrix searching in. recommend following. add column in sheet2 column a . fill values of value/code . new formula should this. =vlookup(c2/d2,sheet2!a$1:d$20,2,false) fill in column of refid in sheet1. column 2 in sheet 2 should refid . hth

csv - Python: renaming files returns the wrong name -

say have folder 1000 csv files names event_1.csv , event_2.csv ,..., event_1000.csv . i in fact have 25 folders , want rename files in such way first 4 characters 0001 first folder, 0002 second, way 0025 . last 4 characters represent event, such 1st event 0001 , second 0002 , way 1000 . so 1st file in 1st folder changed in fashion: event_1.csv = 00010001.csv . anyway code wrong, in first 100 files in 1st folder named 00020000.csv 00020099.csv , since 0002 should used in 2nd folder only. then, 101st file last, correct filenames: 00010101.csv 00011000.csv . this code: wrong that? import os, sys import glob import csv directory=r'c:\users\myname\desktop\tests' subdir=[x[0] x in os.walk(directory)] subdir.pop(0) n=['0001','0002','0003','0004','0005','0006','0007','0008','0009','0010','0011','0012','0013','0014','0015','0016','0017&

react native - how to support phones and tables using reactnative in android? -

i new react native. native android developer. in native android, different images/layouts can used different screen size/densities phones , tablets. layouts/images can changed when orientation of phone changes. possible achieve in reacting native? , if yes how? thanks in advance, krishna [this opinion (and experience) based answer, may bit out of scope of stack overflow] yes is. it's possible add different set of assets different resolutions , pixel ratios. (see: /[app-name]/android/app/src/main/res/ ) it's possible dimensions , pixelratio layout specific sets. if need (and need) relative positioning, flexible layouts etc, these + flexbox helps you. so suggest start doing simple , playing these. in addition, googling topic, there blog posts, 3rd party components , other resources available.

c# - Cannot serialise entites to viewmodel type via constructor -

i having problem only parameterless constructors , initializers supported in linq entities. , , not sure how resolve this, can potentially remove constructor , initialise these manually code there wondering if done. var entries = db.devices.select(device => new devicedetailsmodel(device)).tolist(); devices.addrange(entries); and here constructor class public devicedetailsmodel(device device) { deviceid = device.deviceid; ipaddress = device.ipaddress; alias = device.alias; devicename = device.devicename; } you using linq entities not linq objects. that`s difference. linq entities translates linq query sql query , has no idea how translate constructor. use initializer instead - linq entity can handle that: var entries = db.devices.select(x => new devicedetailsmodel { deviceid = x.deviceid; ipaddress = x.ipaddress; alias = x.alias; devicename = x.devicename; }).tolist();

elasticsearch scripting: how to access other buckets in histogram -

using elasticsearch 2.3.3 i have date_histogram , inside bucket_script . in script, want use aggregations on current bucket (no problem there) aggregation on previous bucket . did not see way access other buckets inside script. am missing or not possible? here query: curl -xpost "http://$eshost:$esport/$index_name/_search?pretty" -d ' { "size": 0, "aggs" : { "s_price" : { "date_histogram" : { "field" : "a_date", "interval" : "month", "format" : "yyyy-mm" }, "aggs" : { "median_price": { "percentiles": { "field": "s_price", "percents": [50] } }, "median_price_change": { "derivative": { "buckets_path": "median_price.50" }},

iterator - Iterating in Scala: checking previous values -

i having following iterator: val = iterator(("a",5),("a",3),("a",2),("a",1),("b",8),("b",2),("b",1),("c",1)) the values inside sorted firstly first element(string) , secondly second(int). how can first 2 values each 'letter'. result should in example: iterator(("a",5),("a",3),("b",8),("b",2),("c",1)) it can done groupby: it.tolist.groupby(_._1).mapvalues(_.take(2)).values.flatten.toiterator but see solution goes through each element , check previous 'string' element , if same , 'count' less 2 yield value. edit : following logic of @jwvh answer: how can generalized take first n values instead of first 2? it might nice if didn't have consume entire iterator @ once. updated case class limititr[a,b](var itr: iterator[(a,b)], reps:int) extends iterator[(a,b)] { private var memory: list[a] = list()

entity framework - How to create success notification in apache ofbiz -

Image
is there way create success notification whenever create information via form in ofbiz. example: want have success notification when product created thanks in advance. you can send notification this, first have ask user if wants allow notifications. notification.requestpermission(function() { if (notification.permission === 'granted') { // user approved. // use of new notification(...) syntax successful new notification('success', { body: 'success!' }); } else if (notification.permission === 'denied') { // user denied. } else { // notification.permission === 'default' // user didn’t make decision. // can’t send notifications until grant permission. } });

XML callback of BestBuy API -

i implementing bestbuy api. have seen it's json callback url. can tell me xml callback url? i have written query string url = "https://api.bestbuy.com/v1/products((search="+keywords+"))?apikey=myapikey&callback=xml_callback&format=xml"; but gives me nullpointer exception here's link search documentation: https://bestbuyapis.github.io/api-documentation/ here curl example of searching wildcard product name xml response: curl -v 'https://api.bestbuy.com/v1/products(name=contigo*)?format=xml&show=sku,name,saleprice&apikey=myapikey'

c# - Xamarin - Pressing "Add NuGet Packages..." does nothing -

trying add nuget package - "html agility pack" specific. but.. clicking add nuget package doesn't anything. nothing happens when right-click on project icon , go add > add nuget package. and under project > add nuget package... nothing happens also. running mac os x 10.11.5 question same mine no answer in it. feel mine more detailed. add nuget packages on xamarin studio mac not working edit: i reinstalled xamarin nothing happened. + no longer need html agility pack. need microsoft http client libraries pack , json.net pack link log: nuget log going alpha channels in updates page switching alpha channel, updating xamarin 6.1 fixes bug.

How to send php variable from view(html) to controller -

this html code. want pass " $category_edit->c_name " value update() controller. getting " $category_edit " variable controller. i using codeigniter framework. <form method="post" action="<?php echo base_url('admin/category/update');?>"> <label>parent category: </label></br> <select name="parent_id"> <?php echo '<option value="' .$category_edit->id .'">'; echo $category_edit->p_name; echo '</option>'; ?> </select> <label>category</label> <input type="text" name="<?php echo $category_edit->c_name; ?>" id="category_name" value="<?php echo $category_edit->c_name; ?>"> <button>update</button> </form> this update() controller. getting error: undefined variable: category_edit trying property of non-objec

sql - Auto Increment for non primary key column in Oracle -

i want insert records particular column increment 1 whenever new row gets inserted table based on following condition current year first row value :1 current year column value should increment 1 meaning 1 1st record of current year , next available number matching year year value 2016 1 2016 2 2016 3 2017 1 2017 2 ... my approach this: insert abc(analysis_year,analysis_number) values (extract(year sysdate), case when analysis_year=extract(year sysdate) autoicreamt starting value 1 else 1; ) any solution looks @ current table values not work in 'real' environment multiple users , multiple sessions , parallel transactions. i think need separate out 2 requirements: have ability sequence records based on when created have ability report on record sequencing within year. the first handled using sequence these designed , handle concurrency (multiple users, multiple transactions, ...). the second reporting requirement , has n

java - When I'm Publishing data using publisher(WSO2 Data Analytics Server)getting Exception -

when i'm publishing data using publisher(wso2 data analytics server)getting following error.code running fine.but publisher not push data server,my 192.168.##.##:7711,7611 ports active.can 1 me please. root@musni-hp:/opt/wso2publisher/logdirectorypublisher/binary# ./runlogpublisher.sh & [3] 10921 root@musni-hp:/opt/wso2publisher/logdirectorypublisher/binary# . info [main] (logfiledatapublisher.java:146) - total number of files process 2 info [main] (logfiledatapublisher.java:150) - current file being processed 1 file name 16063004000005_team_cdr.log info [main] (logfiledatapublisher.java:176) - total events: [116] info [main] (logfiledatapublisher.java:150) - current file being processed 2 file name 16063005000006_team_cdr.log info [main] (logfiledatapublisher.java:176) - total events: [529] error [databridge-connectionservice-tcp://192.168.##.##:7611-pool-4-thread-1] (dat

javascript - Rewrite HTML using jQuery -

i have table looks this: <table> <thead> <tr> <th>id</th> <th>link</th> </tr> </thead> <tfoot> <tr> <th>id</th> <th>link</th> </tr> </tfoot> <tbody> <tr> <td>1</td> <td><a href='#' onclick=('remove(0)')>remove</a></td> </tr> <tr> <td>2</td> <td><a href='#' onclick=('remove(1')>remove</a></td> </tr> <tr> <td>3</td> <td><a href='#' onclick=('remove(2)')>remove</a></td> </tr> <tr> <td>4</td> <td><a href='#'

reactjs - confusing about load data based on router params in react component -

Image
i want load data api based on router params in component, the channel page behave expected when first open page, if go other channel page clicking, channelpage component didn't call componentdidmount , reducer received fetch_messages action, sidebar component have problem. redux-devtools can received location_change action when other channel page clicked. it's weird! what's best practice loading data based on params in react component? sidebar class sidebar extends react.component { componentdidmount() { this.props.fetchchannels(1); } openchannelpage = (e, url) => { e.preventdefault(); console.log('open channel page'); this.props.changeroute(url); }; render() { let channelscontent = null; if (this.props.channels !== false) { channelscontent = this.props.channels.map((item, index) => ( <channelitem routeparams={this.props.params} item={item} key={`item-${index}`} href={item.url}

datatables - How to freeze columns in PrimeNg data table - Angular 2? -

in primeng data table , possible freeze first few columns , have horizontal scroll-x rest ? want similar : https://datatables.net/extensions/fixedcolumns/examples/initialisation/two_columns.html <p-datatable [value]="..yoursource" [frozenwidth]="set frozen width in px" [unfrozenwidth]="set un frozen width in px"> -- frozen column <p-column [header]="" [frozen]="true"> <template> </template> </p-column> --unfrozen column <p-column> <p-column> </p-datatable>

excel - Compare values previous date and second previous date in PowerPivot -

i'm new powerpivot , dax . i've followed on-line tutorials. have small problem can't solve. have following data: date instrument value 2016-07-27 100 2016-07-27 b 98 2016-07-26 102 2016-07-25 b 99 for each date calculate difference (profit/loss) in value between recent date , second recent date. data above following: date instrument value profit/loss 2016-07-27 102 2 ([val. inst. 2016-07-27]-[val. inst. 2016-07-26]) 2016-07-27 b 98 -1 ([val. inst. b 2016-07-27]-[val. inst. b 2016-07-25]) 2016-07-26 100 2016-07-25 b 99 i have tried dax find second largest date using =earlier([date]) but haven't managed work. second largest date maybe able find value corresponding date. suggestions how solved? in end came solution in 3 steps (the steps can combined 1 step). first rank dates, recent being 1 , second recent being 2 . after retrieve value

Polymer breaks with old version of Mootools -

Image
latest update (also updated post title) so tracked down issue old version of mootools (which cannot upgrade or remove due project restrictions). mootools following, code causes issue: /* class: abstract abstract class, used singleton. add .extend object arguments: object returns: object .extend property, equivalent <$extend>. */ var abstract = function(obj){ obj = obj || {}; obj.extend = $extend; return obj; }; //window, document var window = new abstract(window); var document = new abstract(document); the new definitions of window , document what's breaking polymer imports. suggestions on updating code above gracefully extend document/window objects without breaking existing functionality? old description below before discovered issue lies mootools i've included webcomponents.js script. then, when have polymer.html, errors below start appearing, , polymer components doesn't work. the components works in isolation using po

emulating `alloca()` in C -

if read through gnu libs docs, can see: some non-gnu systems fail support alloca, less portable. however, slower emulation of alloca written in c available use on systems deficiency. how c emulation of alloca() like, assuming vlas not available either? according alloca() is the alloca() function allocates size bytes of space in stack frame of caller. temporary space automatically freed when function called alloca() returns caller. implementation platform-specific, , compiler should aware of it, since generated code must respect non-fixed offsets of locals @ stack frame. if toolchain has no vla - have nothing it.

python - XlsxWriter: add color to cells -

i try write dataframe xlsx , give color that. use worksheet.conditional_format('a1:c1', {'type': '3_color_scale'}) but it's not give color cell. , want 1 color cells. saw cell_format.set_font_color('#ff0000') there don't specify number of cells sex = pd.concat([df2[["all"]],df3], axis=1) excel_file = 'example.xlsx' sheet_name = 'sheet1' writer = pd.excelwriter(excel_file, engine='xlsxwriter') sex.to_excel(writer, sheet_name=sheet_name, startrow=1) workbook = writer.book worksheet = writer.sheets[sheet_name] format = workbook.add_format() format.set_pattern(1) format.set_bg_color('gray') worksheet.write('a1:c1', 'ray', format) writer.save() i need give color a1:c1 , should give name cell. how can paint several cells of df? the problem worksheet.write('a1:c1', 'ray', format) used write single cell. possible solution write more cells in row, use wr

wix3.7 - How to Assign Property ID value to Variable in Wix file -

i have wix include file following code: <property id="deploytype" value="[la]" /> <?define dtype= [deploytype]?> now in product tag in wix script, i'd set deloytype value value of dtype, takes localizable integers. there way can variable assigned value of property?

zip - How can I uncompress a gzip file in javascript? -

i have gotten arraybuffer data (called s follows consist of many blocks) our serve side,the blob generated follows: var blob=new blob([s.slice(4,82838)]); but blob have made gzip data;how can uncompress in javascript? have tried zip.js didn't work?(and still puzzled why doesn't work). please tell me method un-compress blob,thank you. (my english poor,sorry) in browser have used pako you may like.. var reader = new filereader(); reader.onload = function(event) { var result = pako.inflate(event.target.result, { to: 'string' }); console.log(result); } reader.readasarraybuffer(file)); if environment nodejs have zlib capabilities

continuous integration - Insert jquery array to db in CI -

i started working ci , new jquery. still trying hold of it. i able select multiple dates in calendar dis-select them. submit button showing , hiding on date choose. i have array of these dates not sure how converted php (or form submit). don't know start from? $('td').click(function() { $(this).toggleclass('active-select-color'); if($('td').hasclass('active-select-color')) $('#mark-now').show(); else $('#mark-now').hide(); }); var selected = []; var tbl = document.getelementbyid("calender-table"); if (tbl != null) { for (var = 0; < tbl.rows.length; i++) { for (var j = 0; j < tbl.rows[i].cells.length; j++) tbl.rows[i].cells[j].onclick = function () { var item = getval(this); if($(this).hasclass('active-select-color')){ selected.push(item); } else { var index = selected.indexof(item); selected.splice(index, 1); } console.log(selected);

numpy - Quick evaluation of many functions at same point in Python -

problem : need fast way in python3 evaluate many (in thousands) functions @ same argument. in sense, kind of need opposite of numpy's broadcasting allows evaluate one function @ multiple points. my solution : @ moment store functions in list , iterate on list classic loop evaluate functions individually. slow. examples, ideas , links packages welcome. edit : people have asked functions like: 1. computational in nature. no i/o. 2. involve usual algebraic operations +, -, *, / , ** , indicator function. no trigonometric functions or other special functions. if functions io bound (meaning spend of time waiting io operation complete), using multiple threads may fair solution. if functions cpu bound (meaning spend of time doing actual computational work), multiple threads not you, unless using python implementation not have global interpreter lock . what can here, use multiple python processes. easiest solution being multiprocessing module. here example: #!

c# - Communication between VSTO and .XLL -

in visual studio, have solution. in solution have 2 projects. 1 vsto can make plugin excel. other project creating .xll file can have custom functions. the vsto helps create login system on excel can things. however, since want our users able use our custom functions have log in. think these 2 projects can't communicate directly .xll addin wouldn't know if user logged in or not. is there anyway these 2 projects communicate? perhaps via middle-man class static variables? edit: more information: both projects written in c# code. able .xll file using exceldna. so if there's way can create maybe c# class can coordinate or share data between 2 projects great. since login data isn't thing want share. i'm hoping in class there static boolean variable holding whether user logged in. vsto set boolean value , .xll it. you add hidden function [excelfunction(ishidden=true)] .xll, can call vsto add-in application.run.

mysql - Get last modified values for each records from two tables joins? -

i have 2 tables accounts , calls . account table contain account details , call table contain call details date_modified , others account id in parent_id column. there lots of records , need query fetch accounts last call details (most recent call). i have tried not able result. select accounts.id, accounts.name, calls.name subject accounts inner join calls on accounts.id = calls.parent_id accounts.id=( select c.parent_id calls c c.parent_id = calls.parent_id order c.date_modified desc limit 1 ) try query: should work. select * accounts inner join ( select c.parent_id ,c.name ,c.date_modified calls c inner join ( select parent_id ,max(date_modified) call_date calls group parent_id ) cc on cc.parent_id = c.parent_id , cc.call_date = c.date_modified ) ccc on ccc.parent_id = a.id

python - Tkinter Show webcam view in second window -

i using webcam view , performing analysis on images taken in. wish introduce functionality window can summoned , user can @ webcam view in new window, should desire. attempt causes buttons in main window swap on instance when open new window. what's going wrong? here (working) example: import tkinter tk import cv2 pil import image, imagetk class camview(): def __init__(self, parent): self.parent = parent self.window = tk.toplevel(parent) self.window.protocol("wm_delete_window", self.close) self.show_frame() def show_frame(self): imgtk = imagetk.photoimage(image=self.parent.img) lmain.imgtk = imgtk lmain.configure(image=imgtk) def close(self): self.parent.test_frame = none self.window.destroy() root = tk.tk() root.bind('<escape>', lambda e: root.quit()) lmain = tk.label(root) lmain.pack() class main(tk.frame): def __init__(self, parent): self.test_

android - Firebase querying data up and down from the middle key -

i have list of data having date. query data sorted date. in situation when need retrieve data , forth middle key. have data sorted date ( orderbychild("date") ) this: { "key1":{ "date": "2016-07-25" }, "key2":{ "date": "2016-07-26" }, "key3":{ "date": "2016-07-27" }, "key4":{ "date": "2016-07-28" }, "key5":{ "date": "2016-07-29" } } note: dates can in future also. there can multiple entries each date. there can gap between 2 dates. if know key3 , how can retrieve data 1 above key3 (i.e. key2 ) end of list (i.e. key5 )? so example, with key3 -> key2 key5 (till end). with key4 -> key3 key5 (till end). how can query key, , order child "date" . have key2 . , need fetch list. i have tried fetch results in parts, 1

android - Sending continues data stream in bluetooth Ble with less delay -

background i'm developing android application can communicates nordic bluetooth 4 device, can able send , receive data nordic. the problem whenever want send bulk data have break data in several 20 byte data , send delay of 50ms as show below code private boolean sendbytes(byte[] ibytes){ sendresetbytes(); byte[] arr=new byte[20]; for(int i=0;i<ibytes.length;i++){ if(i!=0&&i%20==0){ if(!mbluetoothgeneric.send(arr))return false; arr=new byte[20]; try { thread.sleep(50); } catch (interruptedexception e) { e.printstacktrace(); } } arr[i%20]=ibytes[i]; } if(arr.length!=0) if(!mbluetoothgeneric.send(arr))return false; return true; } for sending bytes used uartservice library given nordic send() implemented call writerxcharacteristics() fn public boolean writerxcharacteristic(byte[] value) { bluetoothgatts

How to make debugging work in Android Library projects? -

i have android project consisting of multiple subprojects , 1 of subprojects network, problem debugging breakpoints doesn't work in network library project , android.util.log doesn't work too, don't have way debug project right , that's makes things tough while fixing issues or adding new functionality in project. on breakpoint says no executable code @ line 42 also when load project (the 1 containing other projects in android studio) says can't load 3 modules fine, work when run them. wanted know if else facing problem , solution. i have tried putting .iml files in .idea/modules/network , helps me rid of error of can't load modules. i've tried cleaning project , rebuilding it. restarting android studio, upgrading android studio on latest version of android studio now. when open project in intellij idea ultimate gives me message unsupported projects, can't have java projects gradle projects in android. projects have andriod library projects

reactjs - Getting started with React in WebStorm -

Image
i new react , ides frontend development. i trying use react in webstorm. made new project "react starter kit" in webstorm. whole bunch of packages got created under project. should start writing react code? also have read need add library "node.js v1.8.1 core modules" , "node.js globals" i'm not able find them. attaching snippets better understanding. if starting react-native better not start "starter-kit". i recommend start form beginning, simple tutorial in react-native docs: https://facebook.github.io/react-native/docs/getting-started.html#content after familiarity it, able use stater-kit more properly. as project in webstorm, need files under src directory edit react code. good luck

wso2cep - Is there any custom mysql input event adapter for wso2 cep -

i wanted have event recevier/stream db instead of jms,email,http. in wso2 cep mysql/db available output adapter not intput adapter. there custom mysql input adapter available. please let me know if there alternative solution db adapter. i afraid wso2 cep not have input event adapter recieve events database (you can find list of available input event adapters in product documentation ). to understanding, because wso2 cep designed realtime stream processing. i guess, here database not original source generates events? if so, there should event publisher writes database. if have control on publisher, n't possible publisher send events wso2cep server directly, rather writing database , reading it? in opinion, better solution compared reading database.

keystore - How to retrieve client cert from android cert store -

i have created client cert using self signed root ca, installed clientcert.p12 file in android device. i need use cert in app, following code piece have tried. keystore store = keystore.getinstance("pkcs12"); if (store != null) { store.load(null, new string("the keystore password").tochararray()); log.i("birajendu", "cert check" + "type: "+ store.gettype()+ " size: " +store.size()); enumeration<string> aliases = store.aliases(); if (!aliases.hasmoreelements()) { log.i("birajendu", "no cert found"); } } i getting store.size() zero. but if use keystore store = keystore.getinstance("androidcastore"); , getting proper store size. here need find pkcs12 store. you'll need use android keychain ( https://developer.android.com/reference/a

r - get all the combinations of 10 factor variables -

Image
i have 10 factor variables, want possible unique combinations of factor variables level wise. my dataframe has following data variables: and want output formatted below: unique(dataframe_name) this command display unique values in dataframe. unique_data <- subset(unique(dataframe_name))

angularjs - $uibTooltipProvider doesn't allow specific css property in Angular js -

i have used $uibtooltipprovider tooltip in angular js app.. i have ten menus horizontally when hover menus tooltip display bottom of menu, want change first menu tooltip position, have written specific css this css: sample classname. .sample:first-child + .tooltip > .tooltip-arrow { border-bottom-color:#000; position: absolute; } .sample:first-child + .tooltip > .tooltip-inner { background-color: #000; position: absolute; left: -5px; width: 155px !important; } this code doesn't work when using state appendtobody:'true'. $uibtooltipprovider intialized in app.js: .config([ '$httpprovider', '$uibtooltipprovider', function($httpprovider, $uibtooltipprovider) { var tooltipoptions = {placement: 'bottom', appendtobody: true}; $uibtooltipprovider.options(tooltipoptions); } ]); how change first menu tooltip position when using appendtobody:'true' state??????

unity3d - building for UWP fails during Assembly conversion -

when try build project universal windows platform, following output in visual studio: 1>------ build started: project: projekt, configuration: debug x86 ------ 1> no way resolve conflict between "system, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e, retargetable=yes" , "system, version=2.0.0.0, culture=neutral, publickeytoken=null". choosing "system, version=2.0.5.0, culture=neutral, publickeytoken=7cec85d7bea7798e, retargetable=yes" arbitrarily. 1>w:\work\projekt_2\builduwp4\projekt\app.xaml.cs(99,4,99,62): warning cs0618: 'applicationview.suppresssystemoverlays.set' obsolete: 'use tryenterfullscreen method , isfullscreenmode property instead of suppresssystemoverlays. more info, see msdn.' 1>w:\work\projekt_2\builduwp4\projekt\mainpage.xaml.cs(36,57,36,81): warning cs0169: field 'mainpage.onrotationchangedhandler' never used 1> projekt -> w:\work\projekt_2\builduwp4\projekt\bin\x86\de

compilation - Explanation of packed attribute in C -

i wondering if offer more full explanation meaning of packed attribute used in bitmap example in pset4. "our use, incidentally, of attribute called packed ensures clang not try "word-align" members (whereby address of each member’s first byte multiple of 4), lest end "gaps" in our structs don’t exist on disk." i not understand comment around gaps in our structs. refer gaps in memory location between each struct (i.e. 1 byte between each 3 byte rgb if word-algin)? why matter in optimization? typedef uint8_t byte; typedef struct { byte rgbtblue; byte rgbtgreen; byte rgbtred; } __attribute__((__packed__)) rgbtriple; beware: prejudices on display! as noted in comments, when compiler adds padding structure, improve performance. uses alignments structure elements give best performance. not long ago, dec alpha chips handle 'unaligned memory request' ( umr ) doing page fault, jumping kernel, fiddling bytes require

c# - async & await - dealing with multiple calls to same method - locking/waiting on each other? -

i had complex task/lock based mess performing 'long' data operation, , i'm trying replace async/await. i'm new async await, i'm worried i'm making big mistakes. to simplify things, ui has few pages depend on same data. now, need data once. cache it, , further calls grab cache "cacheddataobjects" rather doing long call every time. like (semi-pseudocode): private dictionary<guid,list<data>> cacheddataobjects; public async task<list<data>> getdata(guid id) { list<data> data = null; //see if have cached cacheddataobjects.trygetvalue(id, out data); if (data == null) { if (connectedtoserver) { data = new list<data>(); await task.run(() => { try { //long data call data = service.getkpi(id);

vendor - Using SimpleSAMLphp in symfony with composer -

i implement simplesamlphp bundle in symfony project but, i'm having issues redirect after login. let me explain little: i have loaded "simplesamlphp/simplesamlphp" in composer. so, bundle sits in vendor directory. then wrote own bundle configured simplesaml, made controllers login actions,... everything works (in sense have button redirects idp (i configured) , thing). redirected to: http://baseurl/module.php/saml/sp/saml2-acs.php/identifier , not find, because files in vendor bundle. when reading documentation carefully, saw baseurl should point simplesaml package. but, because package in vendor, can't that. is there way still use simplesamlphp bundle or need symfony bundle use simplesaml? thank you. i highly recommend give try : https://www.lightsaml.com i've tried simple idp / sp service , works pretty , straightforward. along find website examples written can start base. if still want use simplesaml search "simplesamlphp-bun

XAMPP MySQL failing to start on Windows7 -

mysql failing run on xampp v3.2.2 software. running on windows 7. i have tried changing port xampp mysql in my.ini 3307 , changed port in xampp mysql config 3307 has not helped. i have tried disable service.msc command prompt when start xampp mysql service, user account control pop-up click on "yes" allow. it gives me "attempting start mysql service..." on xampp control panel never connects. go here?

android - How to register a geofence on phone reboot? -

i know have use boot_completed , broadcast receiver. need sample registering geofence broadcast receiver.i created geofence service calss , tried start broadcastreceiver did not work. public class bootcompletereceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { //or whatever action receiver accepts if(intent.getaction().equals(intent.action_boot_completed)){ toast.maketext(context , "app rebbot received" , toast.length_long).show(); intent serviceintent = new intent(context , geofenceobserversationservice.class); context.startservice(serviceintent); // geofenceobserversationservice.getinstant().addgeofences(); } }} here service class here manifest file. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.cctspl.geofenceex"> <uses-permission android:name="android.permission.access_fine_location" />

jquery - I need to add "Add new item" option in Select2 -

i want add button in first element of list "add new item". if user click on button need open pop-up , input users. how in select2 plugin. default options (or) need customize this? basically kld suggested, without additional buttons understand op wants use first option of select trigger new value modal. checks value when select2:close event triggered , if "new" selected, prompts new value, adds @ end of select box , selects it. note: i've disabled search in input , added placeholder $(function () { $(".select2") .select2({ placeholder: 'select type', width: '50%', minimumresultsforsearch: infinity }) .on('select2:close', function() { var el = $(this); if(el.val()==="new") { var newval = prompt("enter new value: "); if(newval !== null) { el.append('<option>'+newval+'</option>') .val(newval)

php - How to filter an array by a condition -

i have array this: array("a" => 2, "b" => 4, "c" => 2, "d" => 5, "e" => 6, "f" => 2) now want filter array condition , keep elements value equal 2 , delete elements value not 2. so expected result array be: array("a" => 2, "c" => 2, "f" => 2) note: want keep keys original array. how can php? built-in functions? $fullarray = array('a'=>2,'b'=>4,'c'=>2,'d'=>5,'e'=>6,'f'=>2); function filterarray($value){ return ($value == 2); } $filteredarray = array_filter($fullarray, 'filterarray'); foreach($filteredarray $k => $v){ echo "$k = $v"; }

Removing DNS entries with gcloud -

adding dns record gcloud good gcloud dns record-sets transaction start -z my-zone gcloud dns record-sets transaction add -z my-zone --name "some_domain.com" --ttl 0 --type txt "test" gcloud dns record-sets transaction execute -z my-zone but when try remove entry gcloud dns record-sets transaction start -z my-zone gcloud dns record-sets transaction remove -z my-zone --name "some_domain.com" --ttl 300 --type txt "test" gcloud dns record-sets transaction execute -z my-zone i error error: (gcloud.dns.record-sets.transaction.remove) invalid value 'parameters.name': 'some_domain.com' (code: 400) the dns zone file standard requires complete domain names end trailing '.' character. since common mistake, other gcloud dns ... commands automatically append trailing '.' domain names if user forgets add one. however, particular command not seem doing that. fixed soon. meanwhile, workaround it,

multithreading - Confused with MS SQL Server LOCK would help in INSERT Scenario.(Concurrency) -

business scenario: ticketing system, , got many user using application. when ticket(stored in 1st table in below) comes in application, user can hit ownership button , take ownershipf of it. 1 user can take ownership 1 ticket. if 2 user tries hit ownership button, first 1 wins , second gets incident or message no incident exists take ownership. here facing concurrency issue now. have lock implementation using table(2nd table in below). i have 2 tables; table(columns) ticket(ticketid-pk, owneruserid-fk) ticketownershiplock(ticketid-pk, owneruserid-fk, lockdate)note: here ticketid set primary key. current lock implementation: whenever user 1 tries own ticket puts entry 2nd table ticketid, userid , current date,then goes update owneruserid in 1st table. before insert above said lock entry, procedure checks other user created lock same incident. if there lock, lock wont opened user. else lock entry wont entered , user cannot update ticket onwership. more info: there many