Posts

Showing posts from May, 2013

html - Authentication required? javascript -

i wondering how can require authentication website. such in picture: https://kb.tanium.com/images/thumb/5/58/authenticationrequired.png/700px-authenticationrequired.png can javascipt? help that's basic http response code 401 sent browser upon request. can on webserver securing folder/page .htaccess file or directive, or can return 401 http response in code (java, php or whatever use) example in java: response.setstatus(httpservletresponse.sc_unauthorized); normally handle of 401 responses job of browser, has nothing javascript. can try change defaut behavior of browser using javascript, try take @ page . i'd recommend not doing instead html form can freely customize , let return form identifiers.

php - where to use mysql_real_escape_string on JSON data in GET request -

i using json data request selecting & inserting mysql. if had used mysql_real_escape_string json, please let me know $json_data = mysql_real_escape_string($_get['json_data']); json_decode($json_data, true); mysql_queries this way ok or else have on every variable like $json_data = mysql_real_escape_string($_get['json_data']); $string = json_decode($json_data, true); $variable1 = mysql_real_escape_string($string['variable1']); $variable2 = mysql_real_escape_string($string['variable2']); $variablen = mysql_real_escape_string($string['variablen']); mysql_queries where use mysql_real_escape_string on json data in request you put 3 different domains in single sentence, each of them having different syntax , different escape rules. don't mix them! // $text text received in query string // might correct json representation of data structure // may else well; source injection // nonetheless, have thoroughly checked

c# - .Net WebAPI not responding when returning HttpResponseMessage -

i'm having problem web api action when returning httpresponsemessage . object return stream of audio, file have 60kb , in first time have success when call web api, however, in next time web api not responds , browser stay loading. below following code: why web api not works/responds in next time call? [httpget] [route("api/card/playaudio/{text}")] public async task<httpresponsemessage> playaudio(string text) { var audiostream = await _cardservice.getstream(text); return createaudioresponse(audiostream); } private httpresponsemessage createaudioresponse(system.io.stream audiostream) { var result = this.request.createresponse(httpstatuscode.ok); //httpresponsemessage result = new httpresponsemessage(httpstatuscode.ok); result.content = new streamcontent(audiostream); result.content.headers.contentdisposition = new contentdispositionheadervalue("attachment"); result.content.headers.contentdisposition.filename = string.

how to design routes for nesting resources in rails? -

i want create web application. one user has many articles; one article has many comments; the codes below: class user ..... has_many :articles end class article .... belongs_to :user embeds_many :comments end class comment .... embedded_in :article, inverse_of: :comments end i want use nesting routes: resources :users resources :articles resource :comments end end but rails guide told avoid multiple nesting resource. can give me ideas. in advance! you can avoid deep nesting using shallow nesting . resources :users resources :articles, shallow: true resources :comments end end it give same routes as: resources :users resources :articles, only: [:index, :new, :create] end resources :articles, only: [:show, :edit, :update, :destroy] resource :comments, only: [:index, :new, :create] end resource :comments, only: [:show, :edit, :update, :destroy] and urls this: users/1 users/1/articles articles/1 articles/1/edit articl

sap - Return a list of all atributes of a persistent class in abap -

i got persistent class on custom table. get_persistent_by_query can list of objects. how can objects of atributes printed user (e.g alv)? can call instance function if click on somehow? here dynamic solution, query_data result returned call get_persistent_by_query( ). in end data stored in structured table <table>, can use display in alv. note there little control on order of field. real use you'd have add error handling well. data: pers_obj_desc type ref cl_abap_classdescr, pers_query_data type ref data, field_cat type lvc_t_fcat. field-symbols: <table> type standard table. loop @ query_data assigning field-symbol(<pers_data>). @ first. pers_obj_desc ?= cl_abap_typedescr=>describe_by_object_ref( p_object_ref = <pers_data> ). loop @ pers_obj_desc->attributes assigning field-symbol(<attr_desc>). append initial line field_cat assigning field-symbol(<field_cat>). <field_cat>-

gitlab - Git push is stuck and does not throw any errors -

i trying push after merging temporary branch master. 'git push' not doing job. local processing gets stuck @ last step. how can resolve this? i did following: git checkout master git merge --no-ff dev_08_15 git commit -a -m "dev_08_15 merge commit" git push origin master and git stuck @ place. below output get. counting objects: 61, done. delta compression using 4 threads. compressing objects: 100% (19/19), done. writing objects: 100% (28/28), 2.20 kib, done. total 28 (delta 14), reused 0 (delta 0) i can pull changes others pushing. can't push of changes now.

php - How to send mail in zend2.2 using DKIM -

i new dkim concept. have been provided private , public keys of dkim. do need make changes in code or have setup domain keys server ? if need make changes should enabling dkim in mails. i using zend 2.2 , php 5.3.3 got link https://github.com/fastnloud/zf2-dkim requiring minimum zend 2.3. in advance.

xpages - populate combobox with values from column from two dimensional array -

i have 2 dimensional array. example : viewscope.mytest = []; viewscope.mytest.push(["row1col1", "row1col2", "row1col3"]); viewscope.mytest.push(["row2col1", "row2col2", "row2col3"]); etc in combobox show values of column3. how can ? to iterate through 3rd columns of array, need this: // creating structure got var viewscope = { mytest: [] } viewscope.mytest.push(["row1col1", "row1col2", "row1col3"]); viewscope.mytest.push(["row2col1", "row2col2", "row2col3"]); viewscope.mytest.push(["row3col1", "row3col2", "row3col3"]); // combobox id var mycombobox = document.getelementbyid("mycombo"); // iterate through options of mytest (var in viewscope.mytest) { // create new option select var option = document.createelement("option"); // add 3rd columns text option.text = viewscope.mytes

powershell - Building bootable iso using mksisofs -

i'm trying build bootable linux iso under windows using mkisofs this command i'm executing: mkisofs -r -v “modified iso” -o d:\mor.iso -cache-inodes -j -l -b isolinux\isolinux.bin -c isolinux\boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table d:\modified\iso\ the output is: uh oh, cant find boot image 'isolinux\isolinux.bin' inside target tree. the structure of d:\modified\iso\ folder is: [boot]\ efi\ images\ isolinux\ packages\ repodata\ sbin\ .discinfo .treeinfo comps.xml ks.cfg

c# - How to open a website with Firefox and set authentication in a Coded UI Test? -

i want make coded ui test vs2015, opens website - using firefox browser. unfortunately when website opens, authenitication-popup appears , labels (like "username:") entryfields have same name. when playback recording, coded ui tries set text of label instead of textbox. is there possibility - per example browserwindow.launch or - launch website , set authentication in 1 line of code? best regards, patrick looking @ popup crosshairs tool of coded ui may show differences between label , textbox, differences can added searchproperties used find control. if not work them consider using getchildren or findmatchingcontrols methods on (some control within) popup. expect them return both label , textbox. may return other unwanted controls well. can write own code distinguish 2 controls. if nothing else available may find comparing left and/or top and/or boundingrectangle properties shows relative positions or sizes of 2 items on popup.

c# - Check if date exist in list of dates -

how can compare mounth , day (not year) list of dates? datetime[] dates= new datetime[] { new datetime(datetime.now.year, 1, 1), new datetime(datetime.now.year, 5, 1), new datetime(datetime.now.year, 5, 8) }; // result datetime date_1 = new datetime(2016, 1, 1); // ok datetime date_2 = new datetime(2022, 1, 1); // ok datetime date_3 = new datetime(2016, 1, 2); // ko datetime date_4 = new datetime(2016, 1, 3); // ko you use ienumerable extension any check if array contains date required month , day datetime date_1 = new datetime(2016, 1, 1); bool exist = dates.any (d => d.month == date_1.month && d.day == date_1.day); console.writeline(exist); datetime date_3 = new datetime(2016, 1, 2); exist = dates.any (d => d.month == date_3.month && d.day == date_3.day); console.writeline(exist); of course requires using system.linq

java - Singleton returning two instances -

Image
i'm trying use singleton (photostorage) provide arraylist of photo objects, seems photostorage instance not behaving singleton (two instances). i using dagger inject singleton class named photointeractor. objectgraph seems a-ok point. same photointeractor instance used in 3 fragments in viewpager. these fragments instantiated @ runtime: recentfragment: historyfragment: notice how instance @4067 of photointeractor same both fragments. also: mappcontext@4093: same photostorage@4094: same when click photo object (grid image) recentfragment, photostorage.addphoto(url) method called. correctly adds photo object photostorage instance array (4094). ok. problem: when close applicaton, intended photostorage.savephotostofile method serialzes arraylist object json on filesystem. the following method called same photointeractor instance: @override public void savephotos(){ photostorage.get(mappcontext).savephotostofile(); } when debug application, photos

windows runtime - C# - Winrt read binary readonly file -

how read in windows store app (winrt, c#) readonly binary file? 'isreadonly' property set true. i able create storagefile object openasync(fileaccessmode.read) results in exception of type 'system.unauthorizedaccessexception'. how can read byte content of readonly file?

chart.js - Chartjs Graph is not showing in colorbox -

i trying display doughnut chart in popup(colorbox) dummy values giving error, if call in browser(via url) display graph. indexsizeerror: index or size negative or greater allowed amount. var doughnutchart = [{ value: 60, color: "#fcc79e" }, { value: 30, color: "#beefd2" }, { value: 50, color: "#ffddfb" }, { value: 20, color: "#cdecff" }, { value: 90, color: "#fff5bc" }]; var mydoughnutchart = new chart(document.getelementbyid("canvas").getcontext("2d")).doughnut(doughnutchart); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <canvas id="canvas" height="450" width="600"></canvas> chart.js needs canvas have rendered size before can rendered. need have chart in

ios - Share authentification between WKWebview and NSURLRequest -

i trying replace login screen of website custom, native one. the way website set up, login ui on front page ( http://www.example.com/ ), ajax credentials api ( http://api.example.com/ ). because of this, setting auth header on front page not work, , needs set first time hitting api. my idea send login request api through nsurlrequest , workd great itself. however, token not retained or shared wkwebview, therefore front page not recognise user logged in. is there way share auth token between 2 requests, or add auth token page requested through ajax? thank you. check out nsurlprotocol , defines how urls loaded in application. inject credentials/sessionid in each request in application after login successful. here great tutorial : http://nshipster.com/nsurlprotocol/ , 1 webviews : http://www.raywenderlich.com/59982/nsurlprotocol-tutorial

c++ - Calling `this` member function from generic lambda - clang vs gcc -

issue: passing generic lambda (to template function) captures this , calls member function of this without explicit this-> not compile on gcc. if lambda not generic, or if lambda not passed other function called in place, compiles withoit explicit this-> . clang cool code in situations. time round of clang vs gcc . who's right? wandbox example template<typename tf> void call(tf&& f) { f(1); } struct example { void foo(int){ } void bar() { call([this](auto x){ foo(x); }); } }; int main() { example{}.bar(); return 0; } with bar() = call([this](auto x){ foo(x); }); clang++ 3.6+ compiles . g++ 5.2+ does not compile. error: cannot call member function 'void example::foo(int)' without object call([this](auto x){ foo(x); });` with bar() = call([this](auto x){ this->foo(x); }); clang++ 3.6+ compiles . g++ 5.2+ compiles. with bar() = call([this](int x){

PHP MySQL - Display saved forms submitted by a specific user -

i'm coming developer trying develop online ordering system. users login system, create form, save form , display saved forms. i can create login system, can create form, , know how save/edit forms problem how show forms submitted specific users. if joe logs system, want joe able see saved forms. should have form database per user? should have login database , 1 single form database users? it work have 2 tables inside database: users storing user info. should have things unique id column, user's name, email... forms saved forms. should have user_id column know given form user saved it. stores the fields in form.

java - JavaFX 8, controllers inheritance -

i have sort of problem during migration javafx 2.2 javafx 8; javafx 8 doesn't support static @fxml elements. i have following situation (code simplified): parent controller: public abstract class parentcontroller implements initializable { @fxml protected label parentlabel; @override public void initialize(url location, resourcebundle resources) { // smth } } child controller (there not 1 child): public class childcontroller extends parentcontroller { @override public void initialize(url location, resourcebundle resources) { super.initialize(location, resources); parentlabel.settext("text"); } } in previous version of code parentlabel static , worked fine. have nullpointerexception while trying settext on label. i'm looking simplest solution in situation. upd 1. child fxml: <anchorpane id="" fx:id="apdentalclinics" maxheight="-infinity" maxwidth="-infinity" minheight="-infinity

java - Cannot Catch arithmetic exception in junit -

the method process throwing exception when test in junit not working eventhough placed next @test annotation expected exception thrown test fails why happening? java.lang.arithmeticexception: / 0 @ com.javageek.junit.calculator.process(calculator.java:88) @ com.javageek.junit.calculatortest.calculatortestdivisionbyzero(calculatortest.java:50) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:47) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:44) @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:17) @ org.junit.internal.runners.statements.expectexception.evaluate(ex

java - jsonwebtoken causes unit tests to fail -

i have interesting problem regarding json web token . moment add dependency maven pom, unit tests spring rest controller throw gibberish, like resultactions results = mockmvc.perform(post("/customers/" + customerid + "/orders") .contenttype(mediatype.application_json).content(new gson().tojson(order))); is expected give 200, gives 400. i've noticed upon investigating issue problem happens tests test post/put (transactional http requests guess call them). i've tried excluding dependency testing using information in this link, no avail. i'm not sure other information provide, because don't have faintest idea causing issue. i've solved issue. problem dependency conflict. jjwt depends on jackson , i've been using gson jsons. 2 conflicted in weird way. i've solved issue changing jjwt jwt lib.

delphi - setTimeout not working in injected JavaScript? -

i have external javascript file mypapopup.js content: function mypopup() { alert("hello stackoverflow") } in delphi xe8 vcl form application, tembeddedwb.execscript inject javascript loaded document in embeddedwb: procedure tform1.btnpopupjsclick(sender: tobject); begin embeddedwb1.execscript('var script = document.createelement(''script'');' + 'script.src = "mypapopup.js";' + 'script.setattribute(''type'', ''text/javascript'');' + 'document.getelementsbytagname(''head'')[0].appendchild(script);' + 'settimeout(mypopup(), 1000);' ,'javascript'); end; please note code script tag being added head section references external javascript file mypapopup.js . then mypopup function external javascript file called d

swift - Passing Core Data objects from UITableViewCell to another View Controller -

currently have application loading data in tableview presented user want them select object wish view further details about. want able read out data in object user in various forms either labels or tableview dependent on data. i have been reading around , trying understand stuff still new me! had guy on here me out saving data , passing data around store reading out seemingly different thing. examples in swift language lead me down right path know need use didselectrow method , call segue , need prepare segue not quite sure how should look. i have read multiple posts , attempt pass objects not in manner in trying to..are able pass whole objects after have been have been selected in tableview view controller present data related object or able pass information object next viewcontroller? have examples of prepareforsegue , perform segue before not sure else missing not able pass information between tableview , viewcontroller. override func prepareforsegue(segue: uistoryboardseg

javascript - scrollTop duplicating values each time function is called -

i have 2 divs each time 1 of them clicked scrolls down common content div called .nbm_specs. first time click scrolls correctly, subsequent clicks make scrolling go crazy , keeps scrolling small amount each time. acting stacking offset top each time click on it. i have established scroll in function call in each .on click function. //hidel @ start $(".prostar,.x10,.x20,.x23,.x30,.x46,.xstar").fadeout(0); //scrol when clicekd function specscrol(){ $('html, body').animate({ scrolltop: $(".nbm_specs").offset().top -80}, 1500); } //navigation section models $("#prostar").on('click', function() { $(".prostar").fadein(0); $(".x10").fadeout(0); specscrol(); }); $("#x10").on('click', function() { $(".x10").fadein(0); $(".prostar").fadeout(0); specscrol(); }); thanks in advance solved. the issue there multiple .nbm_specs div , code wa

Android Design spec for listview looks wrong -

Image
i have listview inside navigation drawer, , consulting design spec set out android ( https://www.google.com/design/spec/components/lists.html#lists-specs ) my list items have 2 lines of text: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="72dp" android:paddingtop="20dp" android:paddingbottom="20dp" android:paddingleft="16dp" android:paddingright="16dp"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="large text" android:id="@+id/title" android:textsize="16sp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="small text" android:id="@+id/note" a

java - spring error :org.springframework.web.context.ContextLoader - Context initialization failed -

i developing simple project in spring have following problem org.springframework.web.context.contextloader - context initialization failed controller: package com.linedata.jaba.controllers; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import com.linedata.jaba.metier.ibanquemetier; @controller public class banquecontroller { @autowired private ibanquemetier metier; @requestmapping(value="/index") public string index() { return "banque"; } } persistence.xml file <?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun

javascript - How to detect user interaction in a directive -

hello want track action when user add new chips run save function html : <md-chips ng-model="contacts" md-autocomplete-snap=""> <md-autocomplete md-selected-item="selecteditem" md-search-text="searchtext" md-items="item in querysearch(searchtext)" md-item-text="item.name" placeholder="specify reviewer(s)"> <span md-highlight-text="searchtext">{{item.name}} {{item.email}}</span> </md-autocomplete> <md-chip-template> <span> {{$chip.email || $chip}}<br> </span> </md-chip-template> </md-chips> js : $scope.$watch('contacts', function(){ if ($scope.chip){ alert("hello") } }) use md-on-append <md-chips md-on-append="newemail($chip)"... > https://github.com/angular/material/tree/master/sr

Error Using Load, Can't Read File in Matlab -

i'm matlab rookie , totally stumped this: i'm trying use "load" read 2 .mat files. 1 works fine. when use "load '/home/filepath/file2.mat'" load other, error using load can't read file if check "exist file2.mat" or "exist file1.mat", see "ans = 2" (same thing full file path). have same permissions , of similar sizes. ideas going on here? i built .mat files in python, possible file source of problem. used scipy, specifically: scipy.io.savemat('./file2.mat', mdict={'wo_scopus': np.asarray(all_unique_word, dtype='object').reshape(len(all_unique_word), 1)}) scipy.io.savemat("./file1.mat", mdict={"an_scopus":np.asarray(all_unique_author, dtype='object').reshape(len(all_unique_author), 1)}) "whos -file file2.mat" produces name size bytes class attributes wo_scopus 137119x1 17711126 cell

android read sms programmatically -

i try read sms broadcastreciver. searched , wrote code: public class incomingsms extends broadcastreceiver { // object of smsmanager final smsmanager sms = smsmanager.getdefault(); public void onreceive(context context, intent intent) { // retrieves map of extended data intent. final bundle bundle = intent.getextras(); try { if (bundle != null) { final object[] pdusobj = (object[]) bundle.get("pdus"); (int = 0; < pdusobj.length; i++) { smsmessage currentmessage = smsmessage.createfrompdu((byte[]) pdusobj[i]); string phonenumber = currentmessage.getdisplayoriginatingaddress(); string sendernum = phonenumber; string message = currentmessage.getdisplaymessagebody(); log.i("smsreceiver", "sendernum: "+ sendernum + "; message: " + message); int duration = toast.length_long; toast

marshalling - c# using SetClipboardData fail with ERROR_INVALID_HANDLE -

when try set string clipboard native method setclipboarddata . fails , error code 6 error_invalid_handle getlasterror() method. can not find out how fails, here code: string copymessage = "need copy clipboard"; const int gmem_movable = 0x0002; const int ghnd = gmem_movable; uint format; uint bytes; intptr hglobal = intptr.zero; format = cf_unicodetext; byte[] copymessagebytes = encoding.unicode.getbytes(copymessage + "\0"); // important: setclipboarddata requires memory acquired globalalloc using gmem_movable. hglobal = globalalloc(ghnd, (uintptr)copymessagebytes.length); if (hglobal == intptr.zero) { return false; } marshal.copy(copymessagebytes, 0, hglobal, copymessagebytes.length); if (setclipboa

Android Studio Copy Module -

i trying make copy of module in android studio, make small changes. how can that? found several solution did not work. instead of posting questions in several old topics decided open new question. i created copy of module-directory, changed name of folder , edited package-name in manifest. stucked: how automatically change package in files , make working android-project again? tried select package , refactor change package in manifest or in project tree not in java-files. thank you! i copied/pasted within android studio, , worked me: in android studio, make sure have project view selected project pane. select module , copy. select folder name of project in project pane (this should name of project , parent directory module). paste in (it ask rename it). add new module settings.gradle file. include 'old-module', "new-module" rebuild/sync project (you should see module option now) run on device/emulator.

php - PayPal SDK error "Credential not found for default user" -

i'm trying integrate paypal sdk site have run problem cannot find solution in documentation or via stackoverflow. i use standard set-up: start.php: <?php //require 'vendor/autoload.php'; require __dir__ . '/../vendor/autoload.php'; use paypal\rest\apicontext; use paypal\auth\oauthtokencredential; define('base_url', 'http://localhost:80/paypaltut/'); if(!defined("pp_config_path")){ define('pp_config_path', '../vendor/paypal/rest-api-sdk-php/tests/'); } $clientid = 'are54bhozrcn13nrgldpist46bwop6pybrylp4nulwwtl2iviuklijrup5ldgzfuc0qpbqiugdvfsmek'; $clientsecret = 'ejariez8b_6wez__gzl0us-dmc-ypa1rh1jof1u4_xljje2iinbrcsarhnyzk-djg7kbjs8ceqf5gnvr'; $apicontext = new apicontext(new oauthtokencredential($clientid, $clientsecret)); index.php: <!doctype html> <html lang="en"> <head> <

android - PublisherAdView is not showing ad,but adListener tells me that ad is loaded -

guys. have 2 publisheradviews in project(here test app) sizes banner , medium_rectangle. banner size working great,but medium_rectangle not,i can see glimpses on screen(like shadow pop-up) , screen background. adlisneter tells me ad loaded , ok. dont know do. tried add publisheradviews in xml , programmatically,but have no results. here xml <com.google.android.gms.ads.doubleclick.publisheradview android:id="@+id/ad_view_small" android:layout_width="match_parent" android:layout_height="wrap_content" ads:adsize="banner" ads:adunitid="/108874508/lebfile-mobileapp-320x50"> </com.google.android.gms.ads.doubleclick.publisheradview> <com.google.android.gms.ads.doubleclick.publisheradview android:id="@+id/ad_view_big" android:layout_width="match_parent" android:layout_height="wrap_content" ads:adsize="medium_rectangle" ads:adunitid="/108

java - Add Charsetprovider to the OJVM -

i need add new charsetprovider ojvm inside oracle 12c database. i load class loadjava : loadjava -v -u user mynewcharsetproviderclass.jar my class go in oracle schema, direct method work. charsetprovider part not load serviceloader. in pure java add in meta-inf/services , serviceloader load in oracle database java vm seem not work way. charsetprovider class not load. class work fine in pure java, use many years ago. meta-inf/services : java.nio.charset.spi.charsetprovider content : com.eric.newcharset.nio.charset.spi.newcharsetcharsetprovider code example inside database : create or replace , compile java source named "myjavadbprocedure" public class myjavadbprocedure { public static string upcase(string text) { string str; try { str = new string("ééeeaarrr".getbytes("windows-1252"), "newcharset"); } catch (exception ex) { return ex.tostring(); } return str; }

c - Why should a struct's size reflect its alignment? -

according wikipedia : the last member padded number of bytes required total size of structure should multiple of largest alignment of structure member in understanding, means in following: struct { char *p; // 8 bytes char c; // 1 byte }; struct b { struct a; // 16 bytes char d; // 1 bytes }; struct a have size of 16 bytes, , struct b have size of 24 bytes. the common explanation arrays of a should have elements accessible @ address of array plus index times size of a . but fail see why case. why not a has size 9 , b has size 10 (both 8 bytes alignment), , use special "array-storage" size when indexing array? of course, we'd still store types in arrays in way compatible alignment (using 16 bytes store each b element). then, we'd compute element addresses taking account alignment, instead of considering size alone (the compiler can statically). for example, store 64 objects in 1kb bytes array of b 's, instead of

woocommerce - Adding pagination to contents -

so, have following code display products in woocommerce <?php get_header() ?> <div class="rfp_hide" id="rhm_product_show"> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'product', 'paged' => $paged, 'posts_per_page' => 20, 'product_cat' => '', 'orderby' => 'date', 'order' => 'desc' ); $loop = new wp_query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); global $product, $userpro, $post, $paged; ?> <div class="rhm_indi_product rhm_profile_items">contents</div> <?php endwhile; ?> <?php wp_reset_query(); ?> <nav> <ul> <li><?php previous_posts_link( '&laquo; prev', $loop-&g

powershell - How to get progress information resulting from Write-Progress? -

i have powershell function calls write-progress . in function, state of displayed progress. possible query state of displayed progress? the use case this: i have function calls function b 10 times. each time function calls function b, write-progress called update -percentcomplete . within function b, update -percentcomplete of progress, don't know current percent complete is. don't want pass around "progress" object b if can query displayed progress object. i have tagged powershell-v2.0 because environment is. i have tried looking in $host variable, $host.ui , $host.ui.rawui , not find want. so else interested, ended defining these 2 functions in module (kudos hal9256 inspiration): function get-progress { [cmdletbinding()] param() if (-not $global:progress) { $global:progress = new-object psobject -property @{ 'activity' = $null 'status' = $null 'id' = $null

javascript - can't figure out why ajax json request to server fails -

i learning how make ajax request jquery , json. have following code: jquery $(document).ready(function(){ $(document).on('submit','#form', function(e){ e.preventdefault(); var nombre = $("#nombre").val(); var apellido = $("#apellido").val(); alert(nombre+apellido); sendajax(nombre,apellido); }); function sendajax(nombre,apellido){ $.ajax({ data: { "nombre": nombre, "apellido": apellido }, contenttype:"application/json", datatype: 'json', url: 'ajax/ajax.php', type: 'post' }) .done (function(response) { alert(response.nombre);