Posts

Showing posts from September, 2015

php - Hide output during test execution -

i have var_dumps in php code (i understand there must none in end, still), , while tests running outputs non necessary information console, there method ignore code execution? i've tried /** * @codecoverageignore */ and // @codecoverageignorestart print '*'; // @codecoverageignoreend but ignores coverage, , still executes code. you can set setoutputcallback nothing function. effect suppress output printed in test or in tested class. as example: namespace acme\demobundle\tests; class nooutputtest extends \phpunit_framework_testcase { public function testsuppressedoutput() { // suppress output console $this->setoutputcallback(function() {}); print '*'; $this->assertfalse(false, "don't see *"); } } you can find reference in doc hope help

javascript - Migrate custom AngularJS filter from 1.2.28 to 1.4.x -

i have complex json response iterated on using ng-repeat. relatively small subset of attributes within result set displayed on screen, filtering of results should restricted values user can see, otherwise filtering behavior confusing end-user. since 1 of attributes wish filter on nested array, custom filter needed since built-in angularjs filterfilter not iterate on array elements best of knowledge. i able working time in angularjs v1.2.28, unfortunately appears break during migration v1.4.3. have not spent time isolate in release cadence functionality broke however. i have not found helpful information in migration guides indicate has changed. know actual/expected parameters filter receive different values in latest major version of angularjs, leads failure. ng-repeat filter expression: <li ng-repeat="user in users | list_filter:{establishment: {id: filtertext, names: [{name: filtertext}], locations: [{streetaddress1: filtertext, streetaddress2: filtertext, city:...

objective c - Call precedence for method overridden in category and again in subclass -

i'm working on project in objective-c , i'm facing situation. let's have class named foo . implement category class named foo+bar , override foo 's method foomethod: . then create subclass foo , named baz , override same foomethod: in class. when use method foomethod: on baz object, implementation called? 1 inside foo+bar or 1 inside baz ? how objective-c handle situation , why? i'm open explanation and/or documentation. behaviour if override method in category explicitly undefined . please don't: if name of method declared in category same method in original class, or method in category on same class (or superclass), behavior undefined method implementation used @ runtime. if overriding method defined once in category of superclass of course subclass implementation called. but here override method defined twice in superclass. behaviour undefined, because override undefined implementation. if worked, bad code anyway. re...

php - values in database not inserted in codeIgniter? -

i new php framework have created simple form , want inserts value in database failed don't know wrong!!! every time getting mysql returned empty result set (i.e. 0 rows). using codeigniter 3 , mysqli drivers controller <?php //display_errors(on); error_reporting(e_all); class register extends ci_controller { public function index () { //validations $rules=array ( "username"=> array( "field"=>"username", "label"=>"username", "rules"=>"required|max_length[20]|min_length[5]|callback_username_is_taken" ), "password"=> array( "field"=>"password", "label"=>"password", "rules"=>"required|max_length[20]|min_lengt...

osx - NSAttributedString in NSTextView not showing up unless you scroll -

i'm trying set attributed string in nstextview, , if text taller text view, text doesn't show @ unless scroll text box. there aren't many posts attributed strings in nstextview, maybe i'm doing wrong. here's how i'm setting text: [[self.textview textstorage] appendattributedstring:attributedstring]; you have programmatically tell nstextview has make new string visible: nsuinteger length = [[self.textview string] length]; [self.textview scrollrangetovisible:nsmakerange(length,0)]; this should work independent of if appended string "simple" string or attributed string.

Using a self signed SSL certificate just for a web service -

i have web service clients have , want data that's sent server encrypted. test used self signed ssl certificate. know when use self signed cert , when navigate whatever address using web browser warn it's unsafe etc. i wondering if i'm going run problems if used certificate instead of verified 1 when web service goes live? also don't have domain name server, going use ip address given isp, ok certificate, because everywhere read them people talking using them domain names? an ssl certificate issued domain , signed issuing authority. when browser connects server server presents certificate client. client verifies certificate checking if domain accessing same 1 mentioned in certificate. also, verifies trust chain. means issuer's certificate should valid. if issuer not root signing authority issuer's issuer's certificate verified. and, root signing authority should trusted means root signing authority should in truststore. major signing author...

Update Magento products with multiple images -

Image
i'm developing magento store , imported products, in these products there more 1 image , when imported products 1 came with, need update products images left, knows how in quick mode? thanks! step 1: export products before begin, make sure changes product data have been saved. on admin menu, select system > import/export > dataflow - profiles. in list of profiles, select export products. in panel on left, click run profile. to begin process, click run profile in popup button. wait few moments profile begin execution. length of time takes complete process depends on size of database. not close window. when process complete,you can find exported csv file in following location on server: [magento-install-dir]/var/export/export_all_products.csv the csv data appears in spreadsheet rows of product records organized columns of attributes, attribute code in header of each column. step 2: copy product images server the csv file contains path each prod...

visual studio - Code Definition Window not working in VS2015 -

just upgraded visual studio 2015 , code definition window not working.it says "no definition selected" no matter select. project windows forms written in c#. go definition , peek definition working fine went vs2013 try out , it's still working there tried make brand new project in vs2015 see if project related, not checked couple of colleagues , wasn't working them either i have feeling either bug in vs2015 or sort of configuration change. anyone found way configure it, or sort of work around , running again? i got reply microsoft on bug report. turns out it's not implemented , possibly never be: hi, based on fact peek definition introduced in vs2013, combined telemetry data shows tiny percentage of users ever display code definition window, decided not implement support part of roslyn. i've filed issue on our github project consider resurrecting it. thanks report! -- kevin pilch-bisson visual studio managed l...

hibernate - How to refresh just entity children without refreshing entire entity? -

i have pretty clean cut parent-child case scenario in db, reflected in corresponding entity objects: parent: @entity @table(name="tbl_parent") @namedqueries(...) public class parent implements serializable { ... @onetomany(cascade = cascadetype.all, mappedby = "parent", fetch = fetchtype.eager) private list<child> childlist; ... public list<child> getchildren() { if(this.childlist != null) { collections.sort(this.childlist); } return this.childlist; } child: @entity @table(name="tbl_child") @namedqueries(...) public class child implements serializable, comparable<child> { ... @joincolumn(name = "parent_id", referencedcolumnname = "parent_id", insertable = true, updatable = false) @manytoone(optional = true) private parent parent; as loading of child data performed jpa framework specified above annotations, not need speci...

ruby - How to use gems installed in vendor/bundle directory -

i have installed gems inside project directory in vendor/bundle using bundle install --path vendor/bundle all gems getting installed. .bundle/config file bundle_path: vendor/bundle bundle_disable_shared_gems: '1' bundle env environment bundler 1.10.6 rubygems 2.4.8 ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux] gem_home /home/xyz/.rvm/gems/ruby-2.0.0-p643 gem_path /home/xyz/.rvm/gems/ruby-2.0.0-p643:/home/xyz/.rvm/gems/ruby-2.0.0-p643@global rvm 1.26.11 (1.26.11) git 1.9.1 rubygems-bundler (1.4.4) bundler settings path set local app (/home/xyz/code/project/.bundle/config): "vendor/bundle" set current user (/home/xyz/.bundle/config): "vendor/bundle" disable_shared_gems set local app (/home/xyz/code/project/.bundle/config): "1" set current user (/home/xyz/.bundle/config): "1" gemfile source 'https://rubygems.org' gem 'creek' gem 'faraday' gem 'fa...

embedded - Is it possible to run a flash memory dump from a production device inside of an emulator/simulator for offline debugging? -

i not sure if right forum, or if better suited in different se sub, though figure appropriate place it. i wondering if there emulators capable of running flash dump directly targets same architecture on device dumped from? instance, if dump taken device(via jtag) running broadcom mips cpu, , contained entire system(bootloader, firmware, filesystem, nvram, etc.) there mount(or should say, load memory) raw image directly, memory , all, , run it, similar how flash onto different device same chip? i have been looking different software such ovpsim(which "full system simulator" , qemu, though unsure if can run full dump directly. can shed light on this, can confusing looking @ everything. i've run embedded-linux systems under qemu in past, don't far. give emulation of cpu core, enough boot kernel, no emulation of "special sauce" around said cpu (e.g. socs may have timers, gpios, i/o interfaces , whole host of other things). if dead-set on doi...

R An if else statement inside a for loop -

i have data table made of 3 columns assigned variable g. g # v1 v2 v3 # [1,] 1 yes 3 # [2,] 4 no 6 # [3,] 7 no 9 # ... i'm trying create list, m, checking see if values in g[,2] "yes" or "no", , pasting string m. m <- for(i in 1:nrow(g)){ if(g[i,2]=='no'){ paste0("abc", g[i,1], "def", g[i,2], "ghi", g[i,3],"\n") } else if(g[i,2]=='yes'){ paste0("ghi", g[i,1], "def", g[i,2], "abc", g[i,3],"\n") } else {null} } m # null however when try return m, returns null. want m this: m # abc1defyesghi3 # ghi2defnoabc9 can point out doing wrong here? thank much! a for loop doesn't return in r. typically want update variable continue using after for loop. example: m <- "intialize" # initialize, better `list()` for(i in 1:nrow(g)){ if(g[i,2]=='no'){ # paste position of vector m m[i] ...

javascript - How to dynamically enable/disable Responsive extension -

i have project users need able select whether or not accompanying script activates responsive extension of jquery datatables. i want add dropdown menu in html lets users choose whether option responsive set true or false in datatable() initialization options. i tried add separate function select value , used global variable datatable() function couldn't work. javascript: $(document).ready(function(){ $("#example").datatable({ "responsive": false, "processing": false, "serverside": true, "ajax": "scripts/university.php", "columns": [ // id null, ........ *html** <select id="selected2" onchange="myfunction()"> <option value="true">true</option> <option value="false">false</option> </select> i tried adding document.getelementbyid clause first line in datatable function could...

python - Better way to dump the contents of ScrolledText widget -

i know how use built in method dump , i'm trying filter dump contents text content. came ugly , inefficient 1 liner this: list(filter(none, map(lambda line: line[1] if line[0] == "text" else none, self.text.dump(1.0, "end")))) what's better way filter dump list text? reason i'm doing write contents log file, if that's @ relevant. 1 liner above works pretty gets text, new line characters, able write contents log file looks ugly. to text use get method, giving starting , ending range of characters want. whole text do: self.text.get("1.0", "end-1c") note: "end-1c" means "the last character, minus 1 character", prevents getting newline tkinter adds.

Python hangs on fetchall using MySQL connector -

i new python , mysql. writing code queries 60 different tables each containing records each second in 5 minute period. code executes every 5 minutes. few of queries can reach 1/2 mb of data in 50 kb range. running on workstation running windows 7,64-bit using mysql connector/python. testing code using powershell windows code run scheduled task. workstation has plenty of ram (8 gb). other processes running according task manager half of memory being used. performs expected processing hangs. have inserted print statements in code (i've used debugger tracing) determine hang occurs. occurring on call fetchall. below germane parts of code. caps (pseudo)constants. mncdb = mysql.connector.connect( option_files=env_mcg_mysql_option_file, option_groups=env_mcg_mysql_option_group, host=ut_get_workstation_hostname(), database=env_mnc_database_name ) generic_table_id in dbr_table_index: site_table_id = dbr_site_table_names[site_id][generic_table_id] ...

unix - Using SCP to move a file from windows desktop to a hadoop sandbox on vmware -

i think simple appreciate help. have zip file on windows desktop "receipts_lab.zip" , running hadoop sandbox on vmware. sandbox part of training course signed mapr beginner , not sure how move zip file windows directory in sandbox is"/user/user01/3" the manual uses following code scp receipts_lab.zip user01@node-ip:/user/user01/3 node-ip ip address got when starting sandbox, lets assume 192.168.88.128 when write following command: scp receipts_lab.zip user01@192.168.88.128:/user/user01/3 and error is: "receipts_lab.zip: no such file or directory" please me understand should since have tried lot of times modify syntax still same error your error means in wrong directory. have tried using winscp? give interface lets see both computer directory , remote computer (in case mapr vm) directory. ( https://winscp.net/eng/download.php ) it may make life easier. download "portable executables" files website , unzip it. sinc...

authentication - How do I validate certificates using OpenAM-12.0 -

i have following use case: a client sends certificate portal. my portal needs authenticate client based on certificate. the certificate sent client signed known certificate authority or signed certificate authority specific client's organization. my portal would, in way or other, able public key of certificate authority if client's certificate signed client's organization. could please suggest me ways implement use case using openam?

Using C#, Unable to load properly .mht document content in html string. .MHT Content is not in proper format -

using c#, unable load .mht document content in html string processing download pdf file. after downloading .mht content not in proper format. bb contains byte array .mht file attachment. byte[] bb = new byte[0]; attachmentstring = attachmentstring + "<br clear=\"all\" style=\"page-break-after:always\" />"; attachmentstring = attachmentstring + "<center><table border=\"0\"><tr><td>" + attachments[a].description.trim() + "</td></tr></table></center><br/>"; bb = helpers.decryptafile(path); //string messagestring = string.empty; //foreach (byte b in bb) //{ // messagestring += (char)b; //} string mht = ""; memorystream stream = new memorystream(bb); streamreader streader = new streamreader(stream, system.text.encoding.ascii); mht = streader.readtoend(); attachmentstring += "<div>" + mht + "</div>";

Fast android decoding/encoding media extractor -

i'm following code mediamuxer video compression (change resolution) , https://android.googlesource.com/platform/cts/+/kitkat-release/tests/tests/media/src/android/media/cts/extractdecodeeditencodemuxtest.java . for 1 minute video on htc 1 m8, takes 40 seconds compress smaller file size. on sony z3 however, takes full 2 minutes compress 1 minute video. there more performant way compression? whatsapp example seems compress same video (one minute) in 1 minute , twenty seconds.

javascript - scrollify footer bottom positioning -

it's been while i've been trying solve out myself. using scrollify jquery . have total of 5 sections , scrollify working totally fine. want footer shown in last section named "five" it's out of section. here goes code: <section class="panel five" data-section-name="five"> <div class="contactus bottom-10"> <!-- contact form, removed code looks easy , small --> </div> <!-- end contact --> <div id="footer-wrapper"> <footer> <!-- footer codes --> </footer> </div> <!--end footer wrapper --> </section> css #footer-wrapper { width:100%; position:absolute; bottom:0; height: 50px; } part of jquery $(function () { $(".panel").css({ "height": $(window).height() }); $.scrollify({ section: ".panel" //this part detect section ? }); $(...

amazon ec2 - How to access elasticsearch in EC2? -

i new aws, , spun ec2 instance, , installed elasticsearch on it. can access elasticesearch via http://localhost:9200 after ssh box, little stuck on how access external. what's best practice if write app access ec2 instance? , how can configure can access externally? any appreciated. thanks.

winapi - SetWindowText for combobox -

i want set text of combobox not present in combobox list. example if combobox has 3 items: apple orange banana i doing selection change event of combobox. on_cbn_selchange(idc_combo, oncomboclick) void cmmacceptctrl::oncomboclick() { cstring str; m_combo.getlbtext(m_combo.getcursel(), str); str += " test"; m_combo.setwindowtext(str); } now if select "orange" expect text of combobox become "orange test" text not changed, "orange" in spite of fact i'm doing setwindowtext . is there way can have different text 1 has been selected combobox list? this bit late, came here same question , found trick... in on_cbn_selchange handler, can post message say postmessage( wm_command, id_addtesttomycombotext) and use setwindowtext in handler that.

Repeat word in python unlimited times -

for example want word repeat unlimited times keep repeating then how should be? import time time.sleep(0.6) print(" hello world") use infinite loop while(1): print "hello world" this run forever

service - websocket connection keeps disconnecting [Android] -

my app makes websocket connection url using this library . working fine. app communication app (sends , receives messages). when app goes background (pressing home key) websocket connection still works , user receives push notifications new messages. the problem that, when app in background, after amount of time, websocket connection disconnects automatically. time interval different each time (sometimes 5 seconds, 5 minutes). now problem not url (no idle time/timeout issues - believe me, works fine on other platforms). looking possible reasons behaviour can fix problem. how websocket connection disconnected when app goes in background. also, should run continuous background service remedy? ps: there no service in app right now. library supposed let websocket connection running when app goes background. the issue library using not stop connection when app backgrounded... however, android may kill process. a service exists prevent problem. if implement in servic...

asp.net mvc - MVC 5 EF 6 Insert Multiple Rows SaveChanges -

i trying insert multiple rows using following code. savechanges() works first record if fails when tries next one. guess each time trying insert records. not sure if correct or not, , if correct how can change code make correct. following code: contrroller: foreach(var m in pms) { _pmservice.addpms(m); } and in _pmservice.addpms: _pmrepository.add(pm); _pmrepository.savechanges(); _pmrepository.add (actually baserepository , pmrepository extends base) _ctx.set<t>().add(entity); finally, here savechanges() (again baserepostiroy) _ctx.changetracker.detectchanges(); return _ctx.savechanges(); so in controller, looping through each entry, , calling add. add in service calls add in baserepository , savechanges(). first record works without issues 2nd record onwards fails. , following error: "saving or accepting changes failed because more 1 entity of type xxxxxxxxxxxxx have same primary key value. ensure ex...

python - How to disable a Tkinter canvas object -

Image
in project using tkinter buttons background gif image. have requirement add "icon", given base64 string. tkinter button doesn't provide option add icon, or second image. that's why have created custom button using canvas . code below: from tkconstants import disabled tkinter import tk, canvas import tkinter import base64 import imagetk _fontcolor = "#ffffff" _bgcolor = "#787878" _icondata = '''ivborw0kggoaaaansuheugaaabgaaaaycayaaadgdz34aaaagxrfwhrtb2z0d2fyzqbbz g9izsbjbwfnzvjlywr5ccllpaaaaujjrefuenrsvc1qhdaqhq20fnrp7kf68ib9d+99dp/j5+jdr9bz8vwu pchbqbdo00yyllusrw4x9nkbjy+rl5nmz34mxhjodbm0h/yexoy3dcynrtxx3bmbv8qtxxdvvat7jgywiv2 opbe1gywh9rwdh83xqeicuphjg6mmnixa+t5jkrelmum4fimk4nvjf4bhm6cjlkqwu1vp69p8q9u2mi7j/p oo5hv+yn9weveuqri8yazomuc5ne0dwzbbmaznupn95o276kqryxi8z4mgcmd3fajrwqn79tnoug5c1xvtz lrq04om8h3bbi7jqn/3oo2m/u0too9vvqlrklh/uwj2y/hhsg0b97vyrcjyv+mss5n6ewmaqhic5zzdswas suzqhfzw8l5sd5clnqgkbxer9ttu/3vw/yb/eyjvaqya4v5...

java - Intersection type with type definition -

i have java interface uses intersection type this: public interface javaintersection{ public <e extends jcomponent & runnable> void foo(e arg); } and i'm trying create scala class implements interface. wrote following: class scalaintersection extends javaintersection{ override def foo[e <: jcomponent runnable](arg:e):unit = ??? } this works but, in full program i'm writing, type gets used in multiple places. having include full type each time pretty tedious. modified class this: class scalaintersection extends javaintersection{ type runnablecomponent <: jcomponent runnable override def foo(arg:runnablecomponent):unit = ??? } with change program no longer compiles, following errors: error: class scalaintersection needs abstract, since method foo in trait javaintersection of type [e <: javax.swing.jcomponent runnable](arg: e)unit not defined error: method foo overrides nothing. [info] note: super classes of class scal...

java - Why does the DocumentFilter not give the intended result? -

Image
i figure must simple mistake in code or misunderstanding on part, cannot documentfilter detect insertstring events. below simple filter upper case letters, not important fact insertstring(..) method never seems called! why insertstring(..) method of documentfilter not called? the filter applied jtextfield @ top. every time insertstring(..) called, should append information jtextarea in center . @ moment, there no action in text field causes text appended text area. import java.awt.*; import javax.swing.*; import javax.swing.border.emptyborder; import javax.swing.text.*; public class filteruppercaseletters { private jcomponent ui = null; private final jtextfield textfield = new jtextfield(25); private final jtextarea textarea = new jtextarea(5, 20); filteruppercaseletters() { initui(); } public void initui() { // document filter seems nothing. documentfilter capsfilter = new documentfilter() { @overri...

javascript - MailChimp JS Validation Isn't Working -

i using 1 of mailchimp's embedded forms, copied wordpress popup builder. issue js in mailchimp's form causing error, validation of form doesn't work. here error: uncaught typeerror: cannot read property 'replace' of undefined // error occurs in file: mc-validate.js:198 and here full form code: <!-- begin mailchimp signup form --> <link href="//cdn-images.mailchimp.com/embedcode/classic-081711.css" rel="stylesheet" type="text/css"> <style type="text/css"> #mc_embed_signup{background:#fff; clear:left; font:14px helvetica,arial,sans-serif; width:500px;} /* add own mailchimp form style overrides in site stylesheet or in style block. recommend moving block , preceding css link head of html file. */ </style> <div id="mc_embed_signup"> <form action="" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-for...

php - Update is not working for mysqli -

i trying information update in table. have spent hours , keep going in circles. think problem in query section toward end of code. appreciated. thanks. <?php require "connect.php"; ?> <?php session_start(); if(isset($_session["id"])){ }else{ header('location:login.php'); } ?> <?php $user = $_session["id"]; $result = $con->query("select * bd id='$user'"); $row = $result->fetch_array(mysqli_both); $_session["firstname"] = $row['firstname']; $_session["lastname"] = $row['lastname']; $_session["email"] = $row['email']; $_session["username"] = $row['username']; $_session["password"] = $row['password']; ?> <?php if(isset($_post['update'])){ $updatefname = $_post['firstname...

arrays - How to find the kth smallest element of a list without sorting the list? -

i need find median of array without sorting or copying array. the array stored in shared memory of cuda program. copying global memory slow program down , there not enough space in shared memory make additional copy of there. i use 2 'for' loops , iterate on every possible value , count how many values smaller o(n^2). not ideal does of o(n) or o(nlogn) algorithm solves problem? thanks. if input integers absolute value smaller c, there's simple o(n log c) algorithm needs constant additional memory: binary search answer, i.e. find smallest number x such x larger or equal @ least k elements in array. it's parallelizable via parallel prefix scan counting.

javascript - how to change the pattern of the datetime-local provided in the html input -

html input of datetime type is datefield: <input type="datetime-local" data-date="" data-date-format="dd mmmm yyyy, h:mm:ss"> script contains below code. $("input").val(moment().format('yyyy-mm-dd, h:mm:ss')); $("input").on("change", function() { this.setattribute( "data-date", moment(this.value) .format( this.getattribute("data-date-format") ) ) }).trigger("change") i have referred http://jsfiddle.net/g7mvaosl/ wherein date pattern can changed. in similar way, tried use type="datetime-local" doesn't work. how resolve this. the date picker returns year, month, , day. console.log(this.value); //returns 2015-08-09 you're asking , additionally hours, minutes, seconds: date picker cannot do. i'm guessing want use current time h:mm:ss? in code set moment's now. $("input").val(moment().format('yyyy-mm-...

ios - iPhone 6/6+ layout - views won't touch each other/hidden margin -

Image
i have 4 "buttons" (black) has following constraints: same width superview height, multiplier 0.4 (using superview height create perfect square) same height superview height, multiplier 0.4 trailing/trailing/top/bottom "coldiv" and"rowdiv" (red), 0 constant, 1 multiplier my problem is, buttons don't "touch" dividers on iphone 6/6+. have "hidden" margin them. works want on smaller screens (iphone 4s). anyone know why happens? and no, don't have "constrain margins" checked on constraints. it looks this: update: when set width , height's multiplier 0.3 (making buttons smaller), margins small. "hidden" margin's size relative button's size. workaround, mean smaller buttons, not thing project. 0.4 + 0.4 = 0.8. margin 0.2 difference haven't accounted for. change widths , heights 0.5 , should good.

android - Why does nothing appear when adding TableRow to TableLayout from code -

i creating tablelayout in xml: <tablelayout android:id="@+id/button_area" android:layout_width="fill_parent" android:layout_height="0px" android:layout_weight="3"> and try add buttons rows (to replicate effect of "wrap panel" - little surprised android doesn't have this, nevermind): protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.activity_main); tablelayout layout = (tablelayout) findviewbyid(r.id.button_area); tablerow row = new tablerow(this); row.setlayoutparams(new tablerow.layoutparams(tablerow.layoutparams.wrap_content, tablerow.layoutparams.wrap_content)); (int = 0; != 12; i++) { button b = new button(this); b.settext("something"); b.setlayoutpara...

c++ - Understanding GLSL Uniform Buffer Block Alignment -

i'm having trouble understanding std140 layout glsl uniform buffer objects. i'm under impression in following uniform block, int begin @ offset 0 , matrix begin @ offset 16. following uniform giving me bad matrix, apparent because nothing draws on-screen. layout (std140) uniform camera { int rendermode; mat4 projection; } camera; the point of rendermode tells me uniform update code doesn't work. i have following code (homegrown) me along. code makes open gl calls in c++ application. code inside class called uniformbufferobject . #define updateexdata(o, s, d) glbindbuffer(gl_uniform_buffer, _uboid); \ glbuffersubdata(gl_uniform_buffer, o, s, d); \ glbindbuffer(gl_uniform_buffer, 0); int alignment(int offset, int alignment) { int leftover = offset % alignment; if (leftover > 0) { return offset + (alignment - leftover); } else { return offset; } } template<typename t, typename... args> void upd...

javascript - Is there a cleaner way to chain these Bluebird promises? -

i have 3 functions (a, b, c) each return promise. chain of promises don't require information previous promises except complete. b has wait finish, , c has wait b finish. currently have: return a(thing) .then(function () { return b(anotherthing); }) .then(function () { return c(somethingelse); }); this feels i'm wasting lot of space (7 lines 3 lines of actual code). this works return a(thing) .then(b.bind(null,anotherthing)) .then(c.bind(null,somethingelse)); note: bind not available on ie8 or earlier - there's polyfill - https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/function/bind for info - in es2015 - iojs let enable arrow functions, apparently broken in way return a(thing) .then(() => b(anotherthing)) .then(() => c(somethingelse));

How do you merge indexes of two lists in Groovy? -

i have 2 lists need merge new list, new list needs contain merged indexes of original lists. example: list1 = [1, 2, 3] list2 = [a, b, c] i need output be: finallist = [1a, 2b, 3c] i need able in groovy. appreciate can provide. assuming both lists same size, in groovy 2.4+, list1 = [1, 2, 3] list2 = ['a', 'b', 'c'] assert ['1a', '2b', '3c'] == list1.withindex().collect { it, index -> + list2[index] } alternatively , bit more in groovy 1.5+, assert ['1a', '2b', '3c'] == [list1, list2].transpose()*.sum()

sql - How to insert values into one table from another table -

i have 2 tables i.e., table1 , table2 same structure , want insert values of table1 table2. these table contains 2 image type column. have tried query couldn't succeed. declare @imagepan varbinary(max) declare @imagecheque varbinary(max) set @imagepan=(select panid table1 emp_code='e001') set @imagecheque=(select cancel_checqe table1 emp_code='e001') insert table2 (transno, emp_code, panno, panid, panext, entdt_pan, banknm, cancel_checqe, chqext, entdt_bnk, acc_no, ifsc, cheque_nm, status_pan1, status_pan, status_bnk1, status_bnk, userid, entdt, panmodify_by, panmodify_on, bnkmodify_by, bnkmodify_on) values(select transno, emp_code, panno, @imagepan, panext, entdt_pan, banknm, @imagecheque, chqext, entdt_bnk, acc_no, ifsc, cheque_nm, status_pan1, status_pan, status_bnk1, status_bnk, userid, entdt, panmodify_by, panmodify_on, bnkmodify_by, bnkmodify_on table1 emp_code='e001') how can achieve this? remove 'values' keyword ...

responsive design - Set slick slider value of JQuery according to width of browser -

i using slick kenwheeler.github.io/slick <div class="slick" data-slick='{"slidestoshow": 4, "slidestoscroll": 1}'> <div>1</div> <div>2</div> <div>1</div> <div>1</div> <div>1</div> </div> i want set value of slidestoshow according width of browser. idea appreciated 2that's classic responsive slider. slider initializer script should this: $('.your-slider-class').slick({ slidestoshow: 3, responsive: [ { breakpoint: 768, settings: { slidestoshow: 2 } }, { breakpoint: 480, settings: { slidestoshow: 1 } } ] }); and add other settings script. next time read "how use" on link gave, there's example this

c - What is the purpose of array[index] = 0;? -

char dev[20] = "dev_name"; char dest[32]; strncpy(dest,dev,sizeof(dev)); dest[sizeof(dev)-1] = 0; what dest[sizeof(dev)-1] = 0; means? in code, assuming size analogous sizeof , dev_name[size(dec_name)-1] = 0; dev_name[size(dec_name)-1] points last element of array, remember c arrays use 0 based indexing. then, definition, string in c exxentially char array with null-termination, if want use char array string , must have null-termination. 0 ascii value of nul or null . so, essentially, you're putting null-terminator char array.

MongoDB - Get id of the maximum value in a group by query -

i have collection documents below. "_id" or entire document of maximum revision in each group grouped "name". { "_id" : objectid("55aa088a58f2a8f2bd2a3793"), "name" : "abc", "revision" : 1 } { "_id" : objectid("55aa088a58f2a8f2bd2a3794"), "name" : "abc", "revision" : 2 } { "_id" : objectid("55aa088a58f2a8f2bd2a3795"), "name" : "def", "revision" : 1 } { "_id" : objectid("55aa088a58f2a8f2bd2a3796"), "name" : "def", "revision" : 2 } in case, i'd select 2nd , 4th documents. tried various approach including aggregation framework couldn't purely in mongodb query. is there solution this? thank you. try following aggregation pipeline first sorts documents revision field descending , $group name fie...

C++ Input/output -

#include <iostream> #include <fstream> using namespace std; int main() { int , b , c , , n; int d = 0; ifstream myfile; myfile.open("duomenys1.txt"); myfile >> n; (int = 0; < n; i++ ) { myfile >> >> b >> c; d += (a + b + c)/3 ; } ofstream myotherfile; myotherfile.open ("rezultatai1.txt"); myotherfile << d; myotherfile.close(); myotherfile.close(); return 0; } the programs should read 3 (3 n) rows of numbers (5 7 4 ; 9 9 8; 8 7 8), rows summed separately , given 3 different averages (7 ; 9 ; 8) in rezultatai1.txt file. -2143899376 result. the problem isn't huge number, need program give every row's average number separately in output file, in output file written (7 ; 9 ; 8) you must make 1 output per line , must use floating point arithmetic followed rounding if want rounded averages. #include <iostream> #include <iostream> #include <cmath> int main...

how to move files from one folder to another folder in the same git repository preserving history -

this question has answer here: is possible move/rename files in git , maintain history? 8 answers i'm using git-bash-1.8.4 git structure: master -folder1/file1,file2,file3.. -folder2/ -folder3/ so want copy file1 folder2 preserving history. i tried git mv file1 folder2 doesn't work. please suggest. git mv file1 folder2 does not work because file1 , folder2 under different directories. try following command root of repository. git mv folder1/file1 folder2

ios - Get User class user details by using pointer in other class -

in condition need current user , other user.i getting current user data fine, dont know how other user data.my code is pfuser *user1 = [pfuser currentuser]; pfobject *user2 = [pfobject objectwithoutdatawithclassname:@"_user" objectid:objid]; my output user1 is <pfuser: 0x7fd3427923f0, objectid: a1p2zzf46e, localid: (null)> { email = "xxxx@gmail.com"; fullname = xxxx; picture = "<pffile: 0x7fd342791950>"; thumbnail = "<pffile: 0x7fd342791ee0>"; username = "xxxx@gmail.com"; } but user2 is <pfuser: 0x7fd3448b8bd0, objectid: xlunx9rzdv, localid: (null)> { } because using objectwithoutdatawithclassname return pfobject objectid only. so, if want full object objectid , can use + (pf_nullable pfobject *)getobjectofclass:(nsstring *)objectclass objectid:(nsstring *)objectid object so: [pfquery getobjectofclass:@"_user" objectid:objid];

Magento Setting Prices to Zero - Randomly -

looking our magento 1.9.2 set up. for last month or we've experienced prices changing 0 no reason. we've tried work out causing disabling/removing extensions, upgrading 1.7 1.9.2, it's still happening. its random - can go 2-3 days no 0 prices , of sudden we'll batch of 20+ products. the affected products orders on previous day , once have zero'd themselves, , we've reset them true price don't 0 again. the link think we've found placing manual orders, , process use that. we @ our wits end tho, magento working apart 1 issue. any suggestions?

javascript - Not getting expected values from JSON -

i trying json values using jquery, code not working expect to. can please give me suggestion on how fix it? // json response: [{ "private": "8044553.0" }, { "governmentdocs": "98952.0" }, { "officialdocs": "5577356.0" }] $.each($.parsejson(data), function(idx, obj) { privatedocs = obj.private; alert(obj.private); alert(obj.officialdocs); alert(obj.governmentdocs); }); i getting value 8044553.0 , undefined , 5577356.0 . why showing this? you have problem in json : [{"private":"8044553.0"}, {"governmentdocs":"98952.0"}, {"officialdocs":"5577356.0"}] json should : '[{"private":"8044553.0", "governmentdocs":"98952.0", "officialdocs":"5577356.0"}]' here working example : var data ='[{"private":"8044553.0", "governmentdo...

php - Laravel 5.1: Retrieve method(s) for route name? -

is there way method(s) route responds name? urlgenerator (as expect name in fairness), provides url given route name. there service provider can return both url , methods route can respond to? prefer not have hook directly app's route collection if possible. i think best way go extend urlgenerator. add new method return array of http methods allowed route. public function getmethodsforroute($name) { if (! is_null($route = $this->routes->getbyname($name))) { return $route->methods(); } throw new invalidargumentexception("route [{$name}] not defined."); } as alternative may able current route router , return them way. less elegant, however. (note untested) $name = 'route.name'; $router = app('illuminate\routing\router'); if (! is_null($route = $router->getroutes()->getbyname($name))) { $methods = $route->methods(); }

c - What does s[i] - '0' mean? -

the following code k&r textbook, page number 71: val =10.0*val+s[i] -'0' what s[i] -'0' mean here? it converts int in char form actual int . for example, if s[i] '9' s[i] - '0' produce 9 .

angularjs - angular directives inside ng-bind-html is not evluated -

this subsequent question this post . i have ng-attr-title used in html injected using ng-bind-html not working ie) title not formed in dom element hence on hovering tooltip not formed.here code myapp.controller("myctrl",function($scope) { $scope.tl="this title"; $scope.level = "<span ng-attr-title='{{tl}}'><b>data</b></span>"; }); problem illustrated in jsfiddle you have use $compile service achieve this. js: var myapp = angular.module('myapp', ['ngsanitize']); myapp.controller("myctrl", function($scope){ $scope.tl="this title"; $scope.level = "<span ng-attr-title='{{tl}}'><b>data</b></span>"; }); myapp.directive('compilehtml', compilehtml); function compilehtml($compile) { return { restrict: 'a', link: function (scope, element, attrs) { scope.$watch(function (...

generics - TypeScript type parameter to implement multiple interfaces -

in c# , can this: class dictionary<tkey, tval> tkey : icomparable, ienumerable { } is there way in typescript 1.5 beta type parameter in generic class or function implement multiple interfaces, without creating entirely new interface purpose? the obvious way not working due ambiguity of commas. class dictionary<tkey extends icomparable, ienumerable, tvalue> { } by way, funnily enough, extends can handle interface unions fine in generics: class dictionary<tkey extends icomparable|ienumerable, tvalue> { } intersection types here since ts 1.6 , can use in above example: class dictionary<tkey extends icomparable & ienumerable, tvalue> { }

linux - Segmentation fault (core dumped) Error Message during c++ code compilation -

i new c++ , trying compile simple c++ programm. using vector #include <iostream> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #define bufsize 100 using namespace std; typedef struct aa{ int a; std::string a_str; }a; typedef struct bb{ int b; std::string b_str; vector<aa> aobj; }b; int main() { b bobj; bobj.aobj[0].a=4; bobj.aobj[0].a_str="dicom"; bobj.b_str="ldap"; bobj.b_str="dicom"; size_t ipos; ipos=bobj.aobj[0].a_str.find("com"); if(ipos!=string::npos) cout<<"string found successfully...."; else cout<<"string not found ...."; return 0; } when compile program shows error message segmentation fault (core dumped) using ubuntu os what need first create object of type aa , push vector of b as aa aa; aa.a = 4; aa.a_str = "hello world"; bobj.aobj.push_back(aa); ...

process - synchronization processes with read & write to file c# -

i trying stop other processes reading , writing file need synchronize between process,how can it? it helpful if give me pattern it, , show me should enter read , write section in code. alright. easy thing thought if that's aim. can use filestream open file. like.. using (var stream = new filestream( @"c:\files\yourfile.txt", filemode.open, fileaccess.readwrite, // that's important parameter set // locks file other processes // long stream persists fileshare.none)) { // give logic ... } messed up. didn't note questions intention, bad. if try close process reading/writing file. try find out which , kill it.

constraints - variable contraints in OPL/CPLEX -

i want implement variable constraint in opl. forall(k in products, t in periods, z in t..periods) z suppose model current , future periods after t. model says not possible implement variable constraints. how can express constraint instead? is way out? forall(k in produkte, t in perioden, z in perioden: z>=t)

Add icons left of toolbar Android (xamarin) -

i downloaded sample new v7 toolbar. can add custom icon right don't know how add left.(s please view image see how looks http://postimg.org/image/qnf67g4tz/ code using here. <?xml version="1.0" encoding="utf-8" ?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/menu_share" android:icon="@drawable/ic_action_content_create" android:background="@android:color/holo_blue_light" local:showasaction="ifroom" android:title="share" /> </menu> and: layoutinflater inflater = (layoutinflater)maincontext.getsystemservice (context.layoutinflaterservice); view v = inflater.inflate (resource.layout.toolbar,null); toolbar toolbar = v.findviewbyid (resource.id.toolbar); toolbar.tit...

javascript - updating ionic 1.5.0 to 1.6.3 causes networking feature not to work - only happens on android -

when upgraded ionic 1.5.0 1.6.3 (latest), networking ajax calls not work anymore. not sure why. required remove android , re add android platform. not sure did change apk names mainactivity-debug.apk android-debug.apk this problem happens on android not ios. here simple ajax call: $scope.dologin = function () { urlcd = "http://desolate-eyrie-5848.herokuapp.com/offsprings.json"; console.log("xxx:" + urlcd); var request = $http({ method: "post", url: urlcd, timeout: 90000, data: {email: email, password: password}//$scope.dologin }); request.success(function (data) { console.log('data: ' + data.status); }); request.error(function (data, status) { console.log('xxx error data:' + data + " status:" + status); }); here android debug traces: 07-30 11:32:18.399: i/web console(21850): xxx doing login @ fi...