Posts

Showing posts from August, 2010

javascript - generic ajax form submission -

ajax/javascript problem: have app consist of multiple forms. want achieve make generic js function submit forms respective controllers getting form id.. m getting form ids in form_id variable m unable use them. tried replacing $('patient_form') form _id , got following error: typeerror: form_id.on not function here following code better understanding of problem: $(function () { var form = document.getelementsbytagname("form"); var form_id = "'#" + form[0].id + "'"; form_id.on('submit', function (e) { e.preventdefault(); $.ajax({ type: 'post', url: 'controllers/c_insertpatient.php', data: $('#patient_form').serialize(), success: function (result) { alert(result); } }); }); }); in addition other answers, want keep form id dynamic, right, can insert whatever values want? $(f...

Main Menu choice prompt is gathered even on sub Function scanf (C) -

im creating program has main menu linked couple of other functions. main menu code int main(){ int imenuchoice,exit; imenuchoice=0; exit =1; while (exit !=0){ system("cls"); printf("**********main menu************\n"); printf("*1) cartesian plane *\n"); printf("*2) number words *\n"); printf("*3) b *\n"); printf("*4) c *\n"); printf("*5) d *\n"); printf("*6) e *\n"); printf("*7) exit *\n"); printf("*******************************\n"); scanf("%d",&imenuchoice); switch (imenuchoice) { case 1: cartisian(); break; case 2: num2word(); break; case 3: break; case 4: break; case 5: ...

linux - Creating SYMLINK with PHP on Hostgator jailed shell - Get Perm Denied error -

so come problem: givens: i have hostgator isp. i'm using php 5.5 the linux box centos shared hosting environment i professional coder , experienced lamp many years problems: i'm not familiar jailed shell have idea i've tried script , have been searching answer still stuck... here's current code: function getmyfakedir($myfile) { $target = ""; $link = 'content/purchased-items/link'; symlink($target, $link); echo "read link: ". readlink($link); return readlink($link); } here's called function: $linktext = getmyfakedir('somepdfthattheusercandownload.pdf'); then pass "$linktext" var phpmailer , wala!!! user clicks download through symlink , i've written code make expire after 24 hours. yeah, got php.net. so, that's problem.... here's error: warning: symlink(): permission denied in /homesomewhere/somemasterdir/public_html/webservices/somephpfile.php on ...

csv - Optimizations for MySQL Data Import -

so far every time have done data load, on enterprise grade hardware , guess never realized 3.4 million records big. question... i have local mysql server on windows 7, 64 bit, 4 gb ram machine. importing csv through standard 'import table' functionality shipped developer package. my data has around 3,422,000 rows , 18 columns. 3 columns of type double , rest text. size of cvs file 500 mb both data source (csv) , destination (mysql) on same machine guess no network bottle neck. it took 7 hours load 200,000 records. speed might take me 4 days load entire data. given widespread popularity of mysql think there has better way make data load faster. i have data in csv format , rudimentary way can think of split different blocks , try loading it. can please suggest optimizations can speed ?

asp.net - getting Roles that already set to custom Authorization attribute? -

i customized authorize attribute of asp.net not know how roles set attribute when set attribute method or class for example have customeauthorizeattribute [attributeusage(attributetargets.class | attributetargets.method)] public class customeauthorizeattribute : authorizeattribute { protected override bool authorizecore(httpcontextbase httpcontext) { if (httpcontext.current.user.identity.isauthenticated && httpcontext.current.user.isinrole("super")) { return true; } else return false; } } but not know how roles when set them attribute [customeauthorizeattribute(roles="admin,super-admin")] by default inhirits roles property base authorize class can roles directly using roles property for example if (httpcontext.current.user.identity.isauthenticated && httpcontext.current.user.isinrole(roles)) { return true; } or create new properties...

javascript - Google maps not working in Firefox (gray box) -

i have plugin i'm working on uses google maps api v3. works charm, except in firefox! i present following url: [redacted because solved]. you'll notice if you're using firefox there gray box google maps stuff available. if use chrome, you'll see nice map google maps stuff. so that's problem, , i'm hoping here can point me solution. this code i'm using create map: function initialize() { var mylat = document.getelementbyid('latitude').innertext; var mylng = document.getelementbyid('longitude').innertext; var mylocation = new google.maps.latlng(mylat, mylng); var mapoptions = { center: mylocation, zoom: 15, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("map"),mapoptions); var markeroptions = { position: mylocation }; var marker = new google.maps.marker(markeroptions); marker.setmap(map); } google.ma...

watchkit - watchOS 2 Heart Rate Sensor -

does know how access heart rate sensor available in watchos 2 in xcode 7 beta? watchos 2 allows use healthkit . within kit, may use hkworkout access variables such heart rate.

javascript - How to replace old table with new one in Handsontable? -

i have interface allows users type in mysql queries , click button execute queries. result of queries displayed in table created handsontable. following code: var output = document.getelementbyid("output"); var hot = new handsontable(output, table_setting); the problem is, every time button clicked, creates new table on old one. new 1 replace old one. tried using output.innerhtml = ""; before var hot = new handsontable(output, table_setting); rid of old table. seems rid of old table, new table not appear anymore. best way this? thank you! you want first hot.destroy() , create new hot instance.

Parse JSON from IBM Watson Personality Insights and get values in Android -

i having json output not able parse after lot of try. new this. getting json string ibm watson personality insights. output following, can me how can parse ? need name,id,percentage , sampling error of json objects in it. how can achieve in android ? ? { "id": "*unknown*", "source": "*unknown*", "word_count": 2196, "tree": { "id": "r", "name": "root", "children": [ { "id": "personality", "name": "big 5 ", "children": [ { "id": "openness_parent", "name": "openness", "category": "personality", "percentage": 0.9493716242287923, "children": [ { "id": "op...

cloud9 ide - how does one configure xdebug nginx and cloud9ide -

its imp me xdebug working nginx , cloud 9 ide if ever want use cloud 9 ide. i know demo uses apache can't use . as know, c9.io uses php -s debug (aka php built-in). anyways, configure nginx run in c9.io (create runner , so) , configure php-fpm xdebug. it's not out of box, believe it's possible :) don't forget npm install debug make work c9 :)

Custom C++ Quaternion Rotation Not Working Correctly -

in code, have quaternion used rotation camera player. rotation seems work fine, directional vectors moving , rotate on not rotate correctly. quaternion multiplication: quaternion quaternion::operator*(vector3 other) const { float x_ = w * other.x + y * other.z - z * other.y; float y_ = w * other.y + z * other.x - x * other.z; float z_ = w * other.z + x * other.y - y * other.x; float w_ = -x * other.x - y * other.y - z * other.z; return quaternion(x_, y_, z_, w_); } quaternion quaternion::operator*(quaternion other) const { vector4 r = other.getvalues(); float x_ = x * r.w + w * r.x + y * r.z - z * r.y; float y_ = y * r.w + w * r.y + z * r.x - x * r.z; float z_ = z * r.w + w * r.z + x * r.y - y * r.x; float w_ = w * r.w - x * r.x - y * r.y - z * r.z; return quaternion(x_, y_, z_, w_); } conjugate function quaternion quaternion::conjugate() const { return quaternion(-x, -y, -z, w); } vector rotation: void vector3:...

c++ - vector/array bounds check only when a define is declared -

i've create own container inherited vector. reimplement operator[] in way makes checking bounds decided #define. so putting example, , ignoring template parmameters they're complicated , irrelevant class myarray : vector<double> { //... virtual double& operator[](const size_type& index); virtual const double& operator[](const size_type& index) const; //... } double& myarray::operator[](const size_type& index) { #ifdef debug_enabled return this->at(index); #else return (*this)[index]; #endif } however, doesn't work because since operator[] overloaded, calling operator[] @ #else become recursive. i make check bounds based on #define, , not based on whether use std::vector<>::at() or std::vector<>::operator[] . how can resolve this? edit: since it's offered lot use std::vector member instead of inheriting, have mention doing isn't solution me because i'll...

IFC - Representation of triangle mesh -

what best way represent simple triangle mesh in ifc? this seems way: ifcfacebasedsurfacemodel -> ifcconnectedfaceset -> ifcface -> ifcfacebound -> ifcpolyloop -> ifccartesianpoint however, seems little complex since functionality of ifcface , ifcpolyloop exceed 1 needs simple triangle mesh. any other options? since ifc4 there geometric representation type ifctriangulatedfaceset , represents surfaces tesselations of triangles, using point list , index list triangles.

objective c - UIView cocos2d Support -

i'm following tutorial add banner in app, don't understand thing, here: "for show bannerview first create uiview , add top of root uiview : uiview *adview = [[uiview alloc] initwithframe:adrect]; [[ccdirector shareddirector].view addsubview:adview]; " add bannerview it: [[myadmobcontroller sharedcontroller] addbannertoview:adview]; where says create uiview , means have create new scene? because don't know uiview (i'm beginner), can give me example of have do? in order add uiview cocos2d project have add window. director creates , handles main window , cocos2d view. ccdirector inherits cc_viewcontroller equivalent uiviewcontroller . uiview isn't new scene "visible object" added view via ccdirector . (your eyes) admobbanner | adview | window (device) all doing creating box sit on top of window banner fit into.

twitter bootstrap 3 - Can we change width of container in css using Bootstrap3 -

how can change width of container in bootstrap3. want content in center of browser (70% of browser's width). <p> use bootply design, prototype, or test bootstrap framework. find examples, share code , rapidly build interfaces bootstrap. use bootply design, prototype, or test bootstrap framework. find examples, share code , rapidly build interfaces bootstrap. </p> <p> use bootply design, prototype, or test bootstrap framework. find examples, share code , rapidly build interfaces bootstrap. use bootply design, prototype, or test bootstrap framework. find examples, share code , rapidly build interfaces bootstrap. </p><p> positive energy nature <br> sun there </p> <p> use bootply design, prototype, or test bootstrap framework. find examples, share co...

entity relationship - Creating the ER Model after the creation fo the database -

i've created program runnning on web (html) booking tickets on cinema theater. i want create er model. as far know, logical sequence of actions is: create er model generate physical model create database so now, when try create er model, relation between entities doesn't seem right. on other hand, if add more entities customer or admin, means have created more tables database don't need. anyone can me in one?

android - Retrieve Image from sqlite3 database and directly display on kivy window -

Image
what getting code? image retrieved database, created in same folder code with open(self.filename, 'wb') output_file: output_file.write(self.ablob) then can access image. cannot directly image database , display it. what want get? when click on button id: display_picture image column id: image should display image directly database without first being created in same folder. please see image below idea of want main.py file from kivy.app import app import sqlite3 import os.path kivy.uix.boxlayout import boxlayout class database(boxlayout): def __init__(self,**kwargs): super(database,self).__init__(**kwargs) self.cols = 2 def on_release(self): try: self.conn = sqlite3.connect('test.db') print "done" self.sql = '''create table if not exists sample( id integer primary key autoincrement, picture blob, type text, ...

php - Codeigniter Ionauth generating wrong email in forgot password -

when click forget password, link in email is: http://10.50.2.124/ticket/auth/res=t_password/chkp7v2vaxxe09ijx060refc9881e6bb20ab2013 insted of http://10.50.2.124/ticket/auth/reset_password/chkp7v2vaxxe09ijx060refc9881e6bb20ab2013 the setting in ion_auth.php is: $config['use_ci_email'] = true; $config['email_config'] = array( 'mailtype' => 'html', ); you should try set crlf fix issue: $this->email->set_crlf("\r\n"); or $config['crlf'] = "\r\n";

python - How to send SOAP requests in php -

okay have python server running , i've been using "suds" client side has been surprisingly easy, when tried run similar code in php got confused since beginner it? from suds.client import client url = 'http://localhost:8080/flightservice?wsdl' client = client(url=url) output = client.service.getflightlist("dxb","ksa") print(output) is there ease in php or can show me sample code return same result? considering server receives this: class input(complextypes.complextype): dpt = str arr = str and returns list of flights class flight(complextypes.complextype): id = int dpt = str arr = str price = float date = str tickets = int this webservice: @webservice(_params=input,_returns=[flight]) def getflightlist(self, input): my php segment: <?php $url = 'http://172.27.130.98:8080/flightservice?wsdl'; $client = new soapclient($url); echo("hello!"); $resu...

sql - “ORA-00922: missing or invalid option” when trying to insert into table -

when run sql query in oracle sql developer work, in jdbc query doesn't work , catch java.sql.sqlsyntaxerrorexception: ora-00922: missing or invalid option. me ? there query below create global temporary table my_table ( id varchar2(30 byte) primary key, name varchar2(20 byte)); insert my_table ( id, name) values ('my_id' , 'my_name' ); it quick guess, because have no oracle available proof it, mybatis (which based on jdbc) had behavior last ; . please try remove in jdbc query. please create temporary table in first statement, in second statement add data.

c++ - Unwanted database file being generated, how to prevent and remove? -

when generating new c++ project - specifically, create new "empty project", directory file stored in seems contain .sdf file. seems generated whenever open project in visual studio 2013, after delete it. seem unable open it, though sincerely doubt contain anything. this project use sfml 2.3, won't using databases in real capacity, had not specified in options should done. i'm not quite sure why system doing this, then. basically, want stop vs making file upon opening project. i'm not sure if uninstalling sql server solve this, or if there else need consider. the sdf file created , owned visual studio, not program. when open solution visual studio check see if file exists. if doesn't vs create 1 , populate code browsing , other information projects manages. if file exists vs open , update database code changes happened outside of vs. although file not required visual studio load solution or project required useful functionality work correct...

c - OpenMP shared variable seems to be private -

i don't understand why in code thread 0 has n = 1 while other ones have n = 0 shared n : int main() { int n, tid; #pragma omp parallel shared(n) private(tid) { tid = omp_get_thread_num(); n = 0; if (tid == 0) { n++; } printf("i'am %d, n: %d\n", tid, n); } return 0; } output: i'am 5, n: 0 i'am 7, n: 0 i'am 0, n: 1 i'am 2, n: 0 i'am 4, n: 0 i'am 3, n: 0 i'am 6, n: 0 i'am 1, n: 0 i'am new omp library. i'am working through ssh on cluster 8 nodes, can problem? thank you. you practically resetting n 0 each thread. thread tid==0 increment n prior printing. here, may encounter program print i'am 0, n: 0 instead of expected i'am 0, n: 1 since produced so-called race condition . if intend initialize n 0 @ beginning of runtime, need initialize n earlier, e.g. prior starti...

google app engine - Designing an API on top of BigQuery -

i have appengine app tracks user various sorts of impression data across several websites. we're gathering 40 million records month , main bigquery table closing in on 15gb in size after 6 weeks of gathering data , our estimates show within 6 more weeks, gathering on 100 million records month. relatively small dataset in terms of bigdata, potential grow quite bit quite fast. now faced successful trial need work on api sits on top of bigquery allows analyze data , deliver results dashboard provided us. my concern here of data being analyzed customer spans few days @ (per request) , since bigquery queries in fact full table scans, api may in time become slower respond table grows in size , bq needs process more data in order return results. my question therefore this. should shard bigquery log tables, instance month or week, in order reduce data needs processing, or "wiser" pre-process data , store results in ndb datastore? result in blazingly fast api, requires p...

c++ - Real time drawing and saving as image(jpeg,png etc), process image, and again displaying the processed image -

i building application in c++. lets simplicity gets image , reverse it, , produces output reversed image. now, trying make user interface user draws , in real time able see reversed image. that user interface should able save image in real time(as application needs image processed) , should load result image(i.e. output image of application). not graphics person , never built user interface. so, don't know in language should be? can made in c++ itself? many questions... help? you can use opencv c++ library image operations , basic interface (console + windows images). for building more advanced interfaces can @ mfc or qt , use opencv images them (or not).

Waiting for Ionic Loading dialogs with Protractor -

there similar questions (linked below) none solves problem. i'm writing protractor tests ionic project. need execute tests @ times when ionic loading dialog appears , disappears. i've created repo bare bones of app , tests need made. solve , solve problem (i describe problem below): https://github.com/tmantman/stackoverflowq . adapt path chrome system in conf.js. to simulate asynchronous ionic loading dialog add controller in blank ionic project: $interval( function() { $ionicloading.show({ template: 'async ionicloading', duration: 5000 }); }, 5000 , 1); }) i need protractor wait dialog appear, tests, wait dialog disappear, , more tests. latest attempt in test file is: it('should test when ionicloading appears', function() { browser.wait(function(){ return element(by.css('.loading-container.visible.active')).ispresent(); }, 10000); var ionicloadingtext = element(by.css('.loadin...

d3.js - MongoDB Collection as data source for cs.js in Meteor app -

as title says i'm using c3.js plot charts in meteor app. examples, however, statically set variables data source. i can't find correct way use c3 mongo. have simple template below <template name="model1"> <div class="chart"></div> </template> and chart code follows template.model1.rendered = function () { var chart = c3.generate({ bindto: this.find('.chart'), data: { json: [ {name: 'www.site1.com', upload: 100 , download: 200, total: 400} ], keys: { value: ['upload', 'download'] } }, axis: { x: { // type: 'category' } } }); }; how can populate json field result of querying mongo, models.find({"model" : "model1"},{"actual" : 1, "_id": 0}) . running e...

ios - Check row selected for textfield in tableview cell using Swift? -

i trying create table view user can edit textfield on each cell. each cell allow transition detail view controller. when user tap on cell's textfield, should allow editing , storing input text array respectively. the problem that, how check cell/row selected when textfield tapped using swift? (i able check cell being tapped, not case of textfield in cell.) there's couple ways this. the superview property of text field uitableviewcell (unless have embedded within view in middle). in own code, subclass uitableviewcell (and controls within cell) give property indicates row number we're working with.

c - No prompt for an integer -

this question has answer here: c/c++ printf() before scanf() issue 2 answers i'm using eclipse c/c++ tried out code making pascal's triangle , when run doesn't print "enter number of rows: " until after enter number though printf comes before scanf int main(void) { int rows, coef = 1, space, i, j; printf("enter number of rows: "); scanf("%d", &rows); printf("\n"); //i added (i = 0; < rows; i++) { (space = 1; space <= rows - i; space++) printf(" "); (j = 0; j <= i; j++) { if (j == 0 || == 0) coef = 1; else coef = coef * (i - j + 1) / j; printf("%4d", coef); } printf("\n"); } return 0; } my question whether there wrong eclipse c/c++ because never had problem on eclipse java when asked input this. ho...

c# - wcf rest send dictionary as parameter -

i have rest service [operationcontract] [webinvoke(method = "post", requestformat = webmessageformat.json, responseformat = webmessageformat.json, uritemplate = "dispatche")] string dispatche(dictionary<string, dispatchparameter> dispatchparameters); and dispatchparameter code public class dispatchparameter { public string servicename { get; set; } public string serviceurl { get; set; } public string parameter { get; set; } } in client when call service service parameter(dispatchparameters) dose not value httpclient client = new httpclient(); var param = new dictionary<string, dispatchparameter>(); param.add("persons",new dispatchparameter(){servicename = "personservice",serviceurl = "personservice url"}); var result = client.postasjsonasync("http://localhost:1822/dispatcherservice.svc/dispatche", dispatchparameters).result; is there mistake in code? ...

c - String manipulation code using char ** pointer gives unexpected result -

i trying implement string parsing code need substring of given string deed following: the header file : test.h #ifndef header_file #define header_file #include<stdio.h> #include<string.h> int increment(char **); #endif the source files : main.c test.c test.c : case1 :test.c #include"test.h" int increment(char **string){ char *temp = *(string); int value; if(temp != null){ *(string) = ++temp; value = 1; } else{ value = 0; } return value; } case2 :test.c #include"test.h" int increment(char **string){ char *temp = *(string); int value; if(*temp != '\0'){ *(string) = ++temp; value = 1; } else{ value = 0; } return value; } main.c: #include"test.h" int main() { char str[30] = "i have done form here comes."; char strs[50]; ch...

php - Implement single logout in simplesamlphp -

this in continuation previous question central login saml , making site work identity provider now have sessions @ cauth.com , a.com (or b.com).what can best way logout sessions on both site on click of "logout" button.? this code have witten logout in cauth.com public function actionslo(){ $metadata = \simplesaml_metadata_metadatastoragehandler::getmetadatahandler(); $idpentityid = $metadata->getmetadatacurrententityid('saml20-idp-hosted'); $idp = \simplesaml_idp::getbyid('saml2:' . $idpentityid); \sspmod_saml_idp_saml2::receivelogoutmessage($idp); assert('false'); //destroy session session_destroy(); //redirect spentity $spid = $_get['spentityid']; header("location:".$spid); } it seems me logout take 3 http redirects 1 . when user click on "logout" requested page cauth.com/slo. then user taken logout of main site (a.com or b.com). ...

java - org.hibernate.MappingException: Repeated column in mapping for entity -

i have 2 domain-models: "userbean" , "loginbean". it's one-to-many relationship, user has many record of login. loginbean.userid foreign key of userbean.id . here ddl of database: create table `users` ( `id` int(11) not null, `username` varchar(255) default null, `password` varchar(255) default null, `register_date` datetime default null, primary key (`id`) ) create table `login` ( `id` int(11) not null, `user_id` int(11) not null, `login_date` datetime not null, `login_result` char(1) not null, primary key (`id`), key `user_id` (`user_id`), constraint `login_ibfk_1` foreign key (`user_id`) references `users` (`id`) ) @entity @table(name = "login") public class loginbean { @id @column(name = "id", nullable = false) @genericgenerator(name = "ddd", strategy = "increment") @generatedvalue(generator = "ddd") private integer id...

r - function tm::tm_map encounter an error -

i have vcorpus "oanc" , want change words lower case, use following function oanc1 <- tm_map(oanc, content_transformer(tolower)) but got warning: warning message: in mclapply(content(x), fun, ...) : scheduled cores 2 encountered errors in user code, values of jobs affected the vcorpus "oanc" of size 586mb while "oanc1" 4mb. in addition, contents, except first text, broken, , when run writelines(as.character(oanc1[[2]])) i got error in fun(content(x), ...) : invalid input 'o<8c><be>bĭĪ<e2>=<f3><81>̡@>9<c2>au<b7>l<99><c5>u <c4>%<a0>[,<9c><93><b8><90>w<b7><97><f7>58<e3><d7>><91><bf>"~wd<cf>2<c3><84>1gq<dd><ed>ـ\<e2><fb><f3><d3>x]<fe>5t!<9f><89>ٍdh<e3><d6>zu<bc><e8><b6>_rs<f0><f7...

linux - Bash: Loop through file and read substring as argument, execute multiple instances -

how now i have script running under windows invokes recursive file trees list of servers. i use autoit (job manager) script execute 30 parallel instances of lftp (still windows), doing this: lftp -e "find .; exit" <serveraddr> the file used input job manager plain text file , each line formatted this: <serveraddr>|... where "..." unimportant data. need run multiple instances of lftp in order achieve maximum performance, because single instance performance determined response time of server. each lftp.exe instance pipes output file named <serveraddr>.txt how needs be now need port whole thing on linux (ubuntu, lftp installed) dedicated server. previous, very(!) limited experience linux, guess quite simple. what need write , what? example, still need job man script or can done in single script? how read file (i guess easy part), , how keep max. amount of 30 instances running (maybe timeout, because extremely unresponsive se...

android - onActivityResult not being called when launching another app -

i trying call app through intent, app called onactivityresult not being called. please me on this? below code: public class encryptcommandactivity extends activity{ encryptionfactory encryptionfactory = new encryptionfactory(); protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.encrpyt_command_activity); activitycontexts.setencryptcommandactivitycontext(this); intent intent = new intent("asd.com.qweapi.main_activity"); bundle bundle = new bundle(); bundle.putint("function", 1006); bundle.putstring("msg", mqttfactory.getbyid()); intent.putextras(bundle); startactivityforresult(intent, 0); finish(); } @override protected void onactivityresult(int requestcode, int resultcode, intent pdata) { super.onactivityresult(requestcode,resultcode,pdata); log.d("encrypt","inside"); //not called toast.maketext(activityconte...

How to embed layout in shiny widgets within R Markdown? -

i want embed shiny code within markdown document. i've seen, there 2 options: have widget , output in code chunk embed full shiny application however, goal break down 1 full shiny app within different parts. if create , embed shiny app each part, have no idea how make values flow 1 app another. if include widgets, can't retain ui design. so question is, possible have layout around shiny widgets within code chunk? for example: fluidpage( tabpanel("example", titlepanel("example"), sidebarlayout( sidebarpanel( checkboxinput('simple', 'simple widget', true) ))))) instead of just: checkboxinput('simple', 'simple widget', true) inside markdown code chunk. thanks!

hash - C - operations on bits representing a structure -

i'm trying write hashset in c, , i've found 1 hash function, hashes according bits in data. have following structure: struct triple { int a; int b; int c; }; the question - how bit representation object of type struct triple ? let's want xor bits 8-bit integer. how that? iterate on bytes of struct , xor each 1 individually, e.g., void bytexor(unsigned char xor_byte, void *data, size_t size) { unsigned char *p = data; while (size--) { *p++ ^= xor_byte; } } usage be: struct triple my_struct; // ... bytexor(0xff, &my_struct, sizeof my_struct); (note: answers question of how xor struct byte. implementing general hash function based on this, may not particularly idea since struct may have padding, i.e., bytes potentially non-deterministic values unrelated values of actual payload fields.)

javascript - Fixed Navbar sub dropdown won't display correctly -

i've created custom navigation bar i've decided make responsive because of mobile trend nowadays. however when creating sub-dropdown menu in fixed nav bar, messes (wont show correctly) , aside page wont scroll down show sub navigation items. here jsfiddle: http://jsfiddle.net/7j6ckx0g/ i've tried changing position of navbar static , , fixes second issue want navbar fixed. thanks :) 1st add function function sybnavtop(){ var rowheight = $('.row').outerheight(); $('#nav-visible').css('top',rowheight); } this function height of row class div detrmine top list , call in window resize , call in document load $(window).on('resize',function(){ sybnavtop(); }); in media screen make in #nav-visible position: fixed; overflow-y: auto !important; overflow-x: hidden !important; bottom:0; #nav-visible { border-top: 2px solid #e0e0e0; border-bottom: 2px solid #e0e0e0; display: no...

ruby - How does `Hash#sort{|a, b| block}` work? -

in ruby-doc see example: h = { "a" => 20, "b" => 30, "c" => 10 } h.sort {|a,b| a[1]<=>b[1]} #=> [["c", 10], ["a", 20], ["b", 30]] can explain a[1]<=>b[1] means? comparing here? a key , b value? why comparing index 1 ? a , b both arrays of [key, value] come hash#sort . converts hsh nested array of [ key, value ] arrays , sorts it, using array#sort. so a[1]<=>b[1] sorts resulting pairs value . if a[0]<=>b[0] sorting key .

ruby - Rails 4: Save Checkbox Results to Serialized Array -

i have campaign model channel column. channel store serialized array of chosen results via checkboxes. here's model.. app/models/campaign.rb class campaign < activerecord::base serialize :channels, array end app/controllers/compaigns_controller.rb class campaignscontroller < applicationcontroller def index @campaigns = campaign.all.order("created_at desc") end def new @campaign = campaign.new end def create @campaign = campaign.new(campaign_params) if @campaign.save zip = uploadzip.find(params[:uploadzip_id]) zip.campaign = @campaign zip.save flash[:success] = "campaign launched!" redirect_to @campaign else flash[:error] = "there problem launching campaign." redirect_to new_campaign_path end end def show @campaign = campaign.includes(:prog...

php - Wordpress List Pages and their Post Thumbnails -

needing on listing pages have in wordpress , 1st depth child sub pages, post thumbnails (or featured image). also, want exclude specific pages being listed i looked @ wp_list_pages(); see no way of including post thumbnails edit: andy, can't find appropriate example of how use code so. sorry, green php , using wordpress. i think looking for: $pages = array(); $exclude = '1,2,3'; // page id of pages want exclude $args = array( 'exclude' => $exclude, 'parent' => 0, 'post_type' => 'page', 'post_status' => 'publish' ); $parents = get_pages( $args ); foreach( $parents $parent ) { $parent -> thumbnail = get_the_post_thumbnail( $parent -> id, 'thumbnail'); $args = array( 'exclude' => $exclude, 'child_of' => $parent -> id, 'number' => 1, 'post_type' => 'page', 'post...

stackexchange api - How to trace one specific page and users who are accessing this page in Rails App? -

Image
i trying build stackoverflow-like rails app, , finding has cool functionality: when accessing 1 question page belonging other member, @ same time, third member appends new answer question, new message in question page follows: i want ask: sending notification members accessing 1 question, information should trace when there new answer question?

ssas - Errors in the OLAP storage engine: The attribute key cannot be found when processing -

Image
i know design problem. 've read there workaround issue customising errors @ processing time not glad have ignore errors, cube process scheduled ignore errors not choice @ least one. this part of cube error thrown. dimtime pk (int) mymonth (int, example = 201501, 201502, 201503, etc.) another columns factbudget pk (int) month (int, example = 201501, 201502, 201503, etc.) another columns... the relation in dsv set follows. dimtiempo = dimtime, factpresupuesto=factbudget, periodo = mymonth, periodopresupfk = month translated understanding. the relationship in cube follows: the cube built without problem, when processing errror: the attribute key cannot found when processing thrown. it thrown due factbudget has month values (201510, 201511, 201512 in example) dimtime don't, integrity broken. as mentioned in answer here can solved @ etl process. think can nothing relationship if 1 fact table has foreign keys has not been inserted in dimensions. ...

java - Android JUnit: assert inside the handler -

i trying make assert inside of handler without success. tried execute threads, runnables, etc. next code 1 example: public class servertest extends androidtestcase { private final string tag = this.getclass().getsimplename(); private final int ack = 1; public void testsendtoserver(){ final serverstub server = new serverstub(); final countdownlatch signal = new countdownlatch(1); new thread(new runnable() { handler handler = new handler(new handler.callback() { @override public boolean handlemessage(message msg) { // log never appear log.w(tag, "handlemessage(message "+msg+")"); assertequals(ack, msg.what); signal.countdown(); return true; } }); @override public void run() { // log n...