Posts

Showing posts from May, 2011

server - Suggestions to store an integer in an android app -

i new android programming, need store integer on server, app can consult , update value of int. listen useful suggestions of more experienced android developers whether if need server or there simpler solution. thanks! for purpose want store int on server . if want store int within phone , have different techniques that

mysql - Getting data from POST [id] form in PHP -

on table displays data database, have form has text area on user can type receipt number , submit save in database specif row. php code below updates database after form submitted. want pick rest of details specific row used $_post['id'] on receipt has been submitted. id primary key. i'm having challenge since can't fetch data database using $id = $_post['id']; i created before outside function update statement works select statement doesn't . how go it? one? if(isset($_post['submit'])) { $rec = $_post['receipt']; $id = $_post['id']; //reate connection $sql = "update customer set `receipt` = '".$_post['receipt']."', `date_entered` = now(), `receipt_lock` = 1 `id` = '".$_post['tid']."' , receipt_lock = 0"; if ($conn->query($sql) === true) { // echo "new record created successfully"; } else { echo "error: " . $sql . "<

c# - Allow user to modify method from outside assembly? -

basically, i'm trying write library people entity management games in c# , wondering if there's way user add functionality (similar override except won't inheriting class) method without directly changing .dll? know in c++ people use callbacks , wondering if there's similar in c#? one option (instead of modifying method ) use mef framework allow users extend application. the managed extensibility framework or mef library creating lightweight, extensible applications. allows application developers discover , use extensions no configuration required. lets extension developers encapsulate code , avoid fragile hard dependencies. mef not allows extensions reused within applications, across applications well.

Fortran calling C: How do I get an efficient vectorised function -

i have call c function fortran, want in vectorised loop. working intel 16.0.3 compilers on linux. so options are: can try , function inline or can use simd function (i want use openmp simd this, want portable , use openmp). if call fortran fortran works both ways. passing arguments use linear/ref clause pass reference vector of values rather vector of references , seems work efficiently. in c linear/ref clause not recognised. i can function nominally vectorise inserting gathers , scatters , performance no better scalar (at least small test function). if put linear(ref(r,s)) in fortran interface block message the uval or ref modifiers must not used on dummy argument value attribute. i can performance using trick of passing value fortran , returning value function return. produces vectorised function, , performance good, unfortunately real function needs return more 1 value. if try inline c function, won't work. opt-report tells me callsite cannot inlined. tr

c++ - How to begin writing a smart pointer? -

i've received task in university, write smart pointer. received skeleton, , need implement needed methods. if i'm right, smart pointer type of pointer counts reference numbers given object (?) and, if counter reaches zero, deletes given object. this skeleton: template<class t> class my_pointer { public: my_pointer(); }; class refcounted { /* reference counted types should have public interface defined here */ public: int increfcnt(); int decrefcnt(); }; int main() { my_pointer<refcounted> obj1 = new refcounted(); my_pointer<refcounted> obj2 = obj1; return 0; } firstly, should line do? refcounted not child of my_pointer, how can possibly instantiate new refcounted object , reference my_pointer object (pointer?)? my_pointer<refcounted> obj1 = new refcounted(); why isn't there counter in my_pointer class, , why counter in refcounted class? how should start this? i'm not in c++. in advance!

php - Cannot access to my Propel's classes -

i have problem accessing propel's classes. example, try access livre class. my code in index.php : use biblio\biblio\livre; //load propel's autoload require 'vendor/autoload.php'; $collect = new livre(); $collect->setnom("aventure"); $collect->save(); and output error : fatal error: class 'biblio\biblio\livre' not found in /applications/mamp/htdocs/propel/index.php on line 7 my classe livre in folder biblio/biblio/livre.php code, eclipse finds livre . when php executes, there error. somebody have solution ? you're going need add composer.json file (obviously modifying autoload data entire json file, rather appending as-is): { ... "autoload": { "classmap": ["biblio/"] } } without this, require vendor/autoload.php; won't include propel classes , php won't able find namespace/class. don't forget run php composer dump-autoload command line update autoload

Run .bat file - Maven/Eclipse -

i want run batch file using maven. my pom.xml looks this: <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <artifactid>test--clients</artifactid> <packaging>war</packaging> <name>test--clients</name> <parent> <artifactid>test--app</artifactid> <groupid>de.timetoact.test-</groupid> <version>10.0.0</version> </parent> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-war-plugin</artifactid> <version>2.4</version> <configurati

postgresql - SQL: Group by attributes from one table but not the other in a join? -

essentially have 2 tables joined need group attributes in first table, not second. i can this... select "table1".* ...to produce columns first table in output. following results in error when trying group them... group "table1".* is there way group them elements in first table without typing individual columns in table1? postgres supports ansi feature called functional dependency. so, if have unique id in table1 , can aggregate that: select t1.* table1 t1 group t1.id; the id has declared correctly either primary key or unique key.

Java for loop making asterisk matrix -

i've trying make form loop in java: ********** ********* ******** ******* ****** ***** **** *** ** * my code looks this: (int row = 1; row <= 10; row++) { (int star = 10; star >= 1; star--) { if (star >= row) { system.out.print("*"); } else { system.out.print(" "); } } system.out.println(); } the output looks this: ********** ********* ******** ******* ****** ***** **** *** ** * i can't seem figure out make whitespace go before stars. i've tried switching loop conditions, gives me same result. there's these for-loops i'm not getting. can point me in right direction :) so tried analyze code , found is your mistake: here see desired output , output becomes different output line number 2 , reason found if condition star >= row lets iterate loop of star

git - How can I transfer the commit history of a repository to another repository? -

i've spent few months working on project. broke, started new project , transfered files, transfer commit history new repository/project? little familiar git. command line codes need transfer commit history? basically want add new remote, in old project need add new remote: $ git remote add origin git@remote-path/project.git then run: $ git remote -v and should have 2 remotes. if have error: fatal: remote origin exists. just use other name remote: $ git remote add new-origin git@remote-path/project.git

ios - uiview and uitableview in same uiviewcontroller showing different sizes on iphone, ipad -

Image
i have uiview , uitableview under 1 uiviewcontroller. pl see image below. in top level view controller, need uiview (checkoutntotal) few buttons , textfields. below want uitableview. shows fine in simulator or on actual device iphone. ipad, checkoutntotal shows large on screen. said height constraint of 130 uiview. going on? here warnings in xcode 7.1 thank you unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. ( "<_uilayoutsupportconstraint:0x7c2d2790 v:[_uilayoutguide:0x7c50b360(64)]>", "<_uilayoutsupportconstraint:0x7c2d3ba0 v:|-(0)-[_uilayoutguide:0x7c50b360] (names: '|':uiview:0x7c50bd20 )>", "", "", "", "" ) will attempt recover breaking constraint

struct initialization in C -

before mark duplicate/downvote, i have read books, spend decent amount of time on internet researching this, cannot find answer. i want initialize struct when create it. want declare type using typedef here trying do typedef struct clock_tag clock; struct clock_tag{ int time; }clock = { 0 }; and gives me error "redefinition of 'clock' different kind of symbol" typedef struct clock_tag{ int time; }clock = { 0 }; gives "illegal initializer (only variables can initialized)" i know have use name of struct in order initialize it, want initialize @ time of it's creation, please not suggest having init() method. this example code, i want understand how can have typedef , struct initialization in .h file know there many ways around this, can omit using typedef or initialize struct members other way, want understand why gives me error , how fix it. p.s legal malloc struct in .h file? a typedef alias, when stating: typede

format - python padding decimals with zeros -

i'm looking way pad float decimals zeros: this 1 reference: in [37]: '{:5.5}'.format(round(4.123456, 5)) out[37]: '4.1235' i have this: in [38]: '{:5.5}'.format(4.1) out[38]: ' 4.1' but have this: out[38]: '4.1000' for formatting floating point numbers should use "f" specifier : >>> '{:f}'.format(4.1) '4.100000' now ":5.5f" uses 5 decimal places , pads complete output @ least 5 characters, doesn't make sense. specify precision only: >>> '{:.4f}'.format(4.1) '4.1000'

php - Symfony select by defaut various options -

i'm working in form symfony , in select want have, default, options selected. i've try: ->add('idgroupe', choicetype::class, array('label' => 'groupes', 'attr' => array('expanded'=> false, 'data'=>$g, 'multiple'=>'true', 'class' => 'form-control' ), 'choices' => $groupes ) ) where $g array like: array(1) { [0]=> string(18) "vue1",[1]=> string(18) "vue2" } but i've got error: an exception has been thrown during rendering of template ("notice: array string conversion") try with: ->add('idgroupe', choicetype::class, array('label' => 'groupes', 'attr' => array(&#

How to implement python style indentation in yacc or bison? -

i have been trying implement python style indentation in bison grammar, insights or ideas implementation nice. the best way have lexer track indentation level , insert indent/unindent tokens token stream appropriately. here's flex code have that: %x linestart %s normal %{ static std::stack<int> indent; static int indent_depth(const char *); %} %% <initial>.*|\n { yyless(0); begin(linestart); indent.push(0); } <linestart>[ \t]* { int depth = indent_depth(yytext); if (depth < indent.top()) { indent.pop(); yyless(0); return unindent; } begin(normal); if (depth > indent.top()) { indent.push(depth); return indent; } } <linestart>. { yyless(0); if (indent.top() >

c# - MVC Json to HTML table -

i trying pass serialized json string (serialized using jsonconvert.serializeobject) html table. call values inside json string table this: "model.jsonvalue". not sure how make variables out of json string. my json string: { "stats": { "global": { "cache": { "misses": "5" }, "download": { "total-downloaded": "500" }, "error": { "config-failed": "50", "retries": "20" }, "instance": { "resets": "2016-06-23 09:45:07" }, "servers": { "server-in-config": "1", "servers-running": "1", "servers-relays": "1" } }, "servers": { "12345": { "uptime": "0d, 18:01:30",

Setting up .htaccess with apache and laravel -

this seems have been asked hundreds of times, , read , tried different things. nothing seems work, after reading 5 google pages gave , want see if can give me answer. i want remove /public url i'm using apache 2.4 server on windows . installed laravel. i made sure rewrite module on in apache (php's get_apache_modules() shows it) , i'm trying write .htaccess - , can't understand how works. don't want change in apache configurations (i'm using machine develop multiple apps) my current .htaccess files : in app route directory options -multiviews rewriteengine on rewriterule ^ public/index.php [l] and in public folder options -multiviews rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ /texteditor/public/index.php [l] right localhost/texteditor/ - , after isn't public/ gives me 404 also can recommend easy .htaccess tutorial dummies? i have done thing doing following , work

javascript - Angular : Detect click event inside a div with ngFor inside -

i'm working on application lot of dropdowns, able close dropdown whenever click happens outside of one. i found solutions, none of them handle case of having ngfor in it, when log click event target in ngfor, element 1 doesn't have parent. can not detect 'find' or 'contains' neither. does have solution detect if target part of dropdown ? the directive import { directive, elementref, eventemitter, input, oninit, output, simplechange } '@angular/core'; @directive({selector: '[clickoutside]'}) export class clickoutside implements oninit { @output() clickoutside:eventemitter<event> = new eventemitter<event>(); constructor(private _el:elementref) { this.onclickbody = this.onclickbody.bind(this); } ngoninit() { document.body.addeventlistener('click', this.onclickbody); } private onclickbody(e:event) { if (!this.isclickinelement(e)) { this.clickoutside.emit(e); } } private isclickinelement(e:a

jquery - DataTables: how to reorder a column in datatables using Javascript or any function -

i using colreorder extension of datatables . , want rearrange column in table using function , not manually dragging column. know there function order() takes array parameter. but method not move single column @ time has performance constraints when number of columns large you have pass array new order : var table = $('#table').datatable({ colreorder: true }); $('button#neworder').click(function() { table.colreorder.order([3,4,2,0,1], true); }); see more details here https://datatables.net/reference/api/colreorder.order()

c++ - Loop using a template variable not working? -

here situation: i made function called myfunction myfunction accepts 2 arrays using parameter definitions template<std::size_t n1, std::size_t m1, std::size_t n2, std::size_t m2> . then made myfunction follows: void myfunction(double (&w)[n1][m1],double (&td)[n2][m2]){ and in myfunction have for loop for(int i; i<n1; i++){...} . it won't compile , there has warning saying: warning: comparison between signed , unsigned integer expressions. i don't know warning means. if knows why happening please help. :) std::size_t unsigned type , int signed type. warning clear: trying compare i , of signed type, n1 , of unsigned type. , presumably have -werror turned on or that. the reason why warning exists can counterintuitive results. example, -1 < (std::size_t)(0) false , since -1 converted std::size_t , end large positive value. (technically, happens because relational operators perform usual arithmetic conversions, favour

Selectively Filling PostgreSQL Lookup Table -

i followed tutorial create postgresql lookup table following schema: create table public.link_categories ( id integer not null default nextval('link_categories_id_seq'::regclass), name character varying(16) not null, description text, constraint link_categories_pkey primary key (id) ) ( oids=false ); alter table public.link_categories owner postgres; as understand it, first field numerical "sequence" key doesn't need populated; automatically fills numerals add or delete rows. i want fill second field data spreadsheet, , have nothing put in third field @ moment. so copied 1 field want import new spreadsheet, added field on either side of it. have three-column table data in center column only. saved csv file. when try import it, following error: warning: null value in column "id" violates non-null constraint how can fill table data 1 csv file, using postgresql 9.5 , pgadmin iii? i assume using copy ? you can specify col

plot - How to set the origin to the center of the axes in Matlab -

Image
when plot function f(x) in matlab, example, sine function, graph this: i want plot in rather different way, such this, generated mathematica: note axes position (together ticks), , x , y labels position. any appreciated. because not readers have latest version of matlab, decided make answer little bit more general, it's function, input handle figure manipulate, , sets origin in center: function axesorigin(figureh) % set origin of 2-d plot center of axes figureh.color = [1 1 1]; % original properties: del_props = {'clipping','alignvertexcenters','uicontextmenu','busyaction',... 'beingdeleted','interruptible','createfcn','deletefcn','buttondownfcn',... 'type','tag','selected','selectionhighlight','hittest','pickableparts',... 'annotation','children','parent','visible','handlevisibility',&

Mule request-reply - why can't we use transactional VM or JMS inside the scope -

mule doc says that, vm or jms connectors set transactional can’t used inside request-reply scope. not understand well. can 1 please explain example? what trying achieve? url point explains why isn't possible. v m or jms connectors set transactional can’t used inside request-reply scope. both vm , jms connectors allow perform transactions of several different types, none of these compatible how request-reply scope works. this because request sent out request-response isn’t sent until transaction committed – transaction in turn not committed until entire flow has been executed (including execution of request-response scope). leads situation both processes blocking each other: flow isn’t executed because it’s still waiting response on request-reply scope, response never arrive since request hasn’t been sent yet (as mentioned before, message sent once transaction committed) .

javascript - jQuery expand element from center not working -

first say: have read numerous web articles questions , answers find here. many helpful, not solution. also, started learning jquery 5 days ago :) i trying make zoom-like effect on hover event in gallery excercise. need image seem expand center, not down , right. if understood correctly, need move half way left , work. also, i'm using ems, try convert ems pixels here. please help! relevant html: <div id="gallery"> <img src="img/cool1.gif"> <img src="img/cool2.gif" id="gal2"> <img src="img/cool3.gif" id="gal3"> </div> css: #gallery { width: 31em; margin-left: auto; margin-right: auto; } #gallery img { width: 10em; height: auto; position: absolute; } #gal2 { margin-left: 10em; } #gal3 { margin-left: 20em; } finally, jquery: var fontsize = $("#gallery img").css("font-size");//equal 1em? var fontint = parseint(fontsize); var t = $(&quo

c# - Program not calculating correctly -

i have 2 calculations correct, parts , tax, service , labor , total wrong. insight overlooked appreciated. code: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace windowsformsapplication10 { public partial class form1 : form { public form1() { initializecomponent(); } //method calculating oil , lube charges private int oillubecharges() { int total = 0; //if oil checked, add 28 total if (chkoilchange.checked) { total += 26; } //if lube checked, add 18 total if (chklube.checked) { total += 18; return total; } //if nothing checked return 0 else {

encryption - Got stuck with Caesar.c -

i trying run program assignment caesar.c edx introduction programming. requires program able encrypt string caesar encryption: therefore, user has enter key (command-line); example key of 2 'a' character needs encrypted in 'c' character; problem starts when have enter key greater 26, number of alphabetical letters. key of 27 , 'a' character example, program must return 'b' key of 1. i have tried transform ascii values of characters alphabetical values 0 26 in order use modulus operator when key equal or greater 26. returns me segmentation fault. can me suggestions of causes of error? here's program: #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int key; // function alphabetic value non capital letters int alpha_low( char c ) { int alpha_value; alpha_value = (int) c - 97; return alpha_value + ( key % 26 ); } // function return ascii valuee non ca

spring data - ResourceProcessor is not working with PagedResources -

hi i'm trying add custom links paged resources without success. issue may related datarest-375 can please verify i'm doing right. @restcontroller @requestmapping(value = "/photos") public class photocontroller implements resourceprocessor<pagedresources<resource<fileinfo>>> { private static final string media = "media"; @autowired private filesystemservice photoservice; @requestmapping(method = requestmethod.get) public httpentity<pagedresources<resource<fileinfo>>> getallphotos( pageable pageable, pagedresourcesassembler<fileinfo> asemb ) throws ioexception { page<fileinfo> imagesinfo = photoservice.getimagesinfo(pageable); return new responseentity<>( asemb.toresource(imagesinfo), httpstatus.ok ); } @requestmapping(value = "/{id}", method = requestmethod.get) public responseentity<gridfsresource> getphoto( @pathvariable("id") string id ) throws ioexc

how can i list MySQL databases in a Python array -

i working on piece of software can store clients , jobs doing them in mysql database, ui work way want need have every 1 of databases or tables in array reference later. example mysqltables = [customers,clients,jobs] mysqltables[0] = [joshua,alex,james] mysqltables[0][0] = ["computer issue"] this way can reference , display information in frontend ui other solution of displaying visual navigation in pyqt4 using tree widget appreciated i still pretty new using mysql python , having trouble understanding everything, have found don't understand it how list tables in databases in sql server in single result set? from can depict might wanting similar have no idea how implement , not contain job information of client. i wrote similar project did, had database interface in gui, , allowed user edit , add entries database without having go mysql workbench. you're going need 2 functions interact database, 1 retrieve entries, , 1 execute changes. this

unit testing - HowTo test Modal emitter in Angular2? -

this class component: export class goalsettingspage { public goal: goal; dismiss() { this.viewctrl.dismiss(); } } this test: it('should emit on click', () => { let g = new goal() let settingmodal = modal.create(goalsettingspage, { g:goal }); settingmodal.subscribe(hc => { console.log(hc); expect(hc).toequal({hascompleted:true}); }); settingmodal.dismiss() }) this error: 04 07 2016 16:36:48.438:error [chrome 51.0.2704 (mac os x 10.11.3) | goal settings | should emit on click]: typeerror: cannot read property 'remove' of undefined @ modal.viewcontroller.dismiss (http://localhost:9876/absolute/var/folders/zb/tpysrhsx7hbg1dnsn4gwtqq00000gn/t/65a6294f711f882f7429da26bc12e438.browserify?2c82fe582a9911b998cb77bce54ea6804460d5cd:59060:25) any idea doing wrong?

data.table - how to find outliers in multiple rows when the first column is in id form in R -

i have data looks this mem_id age1 age2 age3 age4 age5 age6 age7 age8 age9 age10 1 3 5 5 6 7 8 9 10 11 15 2 5 6 7 8 10 10 11 11 12 13 3 7 7 7 7 8 8 8 9 9 9 4 8 8 8 8 8 8 9 9 9 9 5 12 13 14 9 15 16 16 16 16 16 i want find out outliers in each row using criteria value of element in row particular mem_id not in range of q1-1.5*inter quartile range,q3-1.5*inter quartile range q1 first quartile , q3 third quartile classify has outlier so want output mem_id outliers 1 age2 3, age1 5 2 age3 6,age4 7 that output tell me location of outliers , value of outliers each mem_id. probably not after (though bit confused still output should like) code create true / false grid outlying values have true value , in-lying values have false value x <- c (1 , 3 , 5 , 5 , 6 , 7 , 8 , 9 , 10 ,

php - I retrived the BLOB image from MySQL DB but it does not appear on browser -

i inserted image mysql db it's done, image isn't showing. here codes (i've left other blocks php, db connection , basic html tags): (it's learning purpose) html form: <label for="user_pic">upload picture:</label> <input type="file" id="user_pic" name="user_pic" size="30" /> <br /> insert.php $image = $_files[$image_fieldname]; $image_filename = $image['name']; $image_info = getimagesize($image['tmp_name']); $image_mime_type = $image_info['mime']; $image_size = $image['size']; $image_data = file_get_contents($image['tmp_name']); $insert_image_sql = sprintf("insert images (filename,mime_type,file_size,image_data) values ('%s','%s',%d ,'%s');",mysql_real_escape_string($image_filename),mysql_real_escape_string($image_mime_type),mysql_real_escape_string($image_size),mysql_real_escape_string($image_data)); mysql_

transactions - Mule Transactional scope with Rollback exception strategy not working -

i have mule flow configured multi-resource transaction transactional scope , rollback exception strategy roll exception , redelivery message start transaction again. rollback exception strategy doesn't redeliver message. below flow config. <ee:multi-transactional action="always_begin" doc:name="transactional"> <db:insert config-ref="mysql_configuration" autogeneratedkeys="true" autogeneratedkeyscolumnindexes="1" autogeneratedkeyscolumnnames="generated_key" doc:name="database" transactionalaction="always_join"> <db:parameterized-query> <![cdata[insert demo(name, age) values(#[payload.customer.name],#[payload.customer.age])]]> </db:parameterized-query> </db:insert> <component class="org.ram.businesscomponent" doc:name="throw exception" /> <jms:outbound-endpoint queue="${queue.name}&q

r - Amending a dataset using multiple 'Or' statements to match column data -

i have dataset consisting of hundreds of diagnosis codes. i'm intending reduce these broader condition. example, dt <- data.frame(diagnosis=c("a415","a419","b519","b589","t814"),broader.condition=na) is snapshot of current data. thought might able iterate through each diagnosis code, check if 1 interested in, input broader diagnosis corresponding column, here attempt for(i in 1:length(dt$diagnosis)){ if(dt$diagnosis[i] == "a415"||"a419"||"b519"||"b589"||"t814"){ dt$broader.condition[i] = "skull , face fractures"} however don't believe i'm using || 'or' statements correctly throws "error in dt$diagnosis[i] == "a415" || "a419" : invalid 'y' type in 'x'||'y' any advice on or 'or' statements within loops appreciated. i'm going extend each code , corresponding broader condi

Can't access socket from external device on Android -

i wrote simple http-proxy android listening on device external ip address , specific port (e.g. 192.168.1.20:8080). i can access ip/port device - tries external devices never accepted in run-loop. the simplified code looks this: public class mainactivity extends appcompatactivity implements runnable { private serversocket socket; private int port = 8080; private thread thread; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); wifimanager wm = (wifimanager) getsystemservice(context.wifi_service); string ip = formatter.formatipaddress(wm.getconnectioninfo().getipaddress()); log.v("tag", "http://"+ip+":"+port); try { log.v("tag", inetaddress.getbyname(ip).tostring()); socket = new serversocket(port, 5, inetaddress.getbyname(ip)); socket.setsotim

mysql - PHP exception handling after SQL insert -

i creating simple registration form in php, when user tries register there popup javascript alert succes or fail message. now want catch sql exception show if username or email excists in database instead of standard fail message. this code have far: if(isset($_post['btn-signup'])) { $uname = mysql_real_escape_string($_post['uname']); $email = mysql_real_escape_string($_post['email']); $upass = md5(mysql_real_escape_string($_post['pass'])); if(mysql_query("insert user(username,password,email) values('$uname','$upass','$email')")) { ?> <script>alert('successfully registered ');</script> <?php } else{ ?> <script>alert('error while registering you...');</script> <?php } } ?> how can check if email or username excists in database? both variable's unique in database. from comments: i don't want 2 queries while database c

jquery - Displaying part of JSON data using javascript -

i'm trying use json print content screen. i'm trying print out 2 different sections "albumdata" displays columns in "albumdata" div , audio equipment goes in div further down page. have tried having {audio: [ ...]} in json array never seems work. issue right js file outputting munch data , not stopping when the object not in array. ideally, put out 4x4 layout albums, , 4x3 layout devices instead both sections outputting 4x7 , many of text 'undefined'. do guys have tips on targeting specific json data? html code: <h1 class="headtext">wall of fame</h1> <hr class="style14"></hr> </br></br> <h2>albums: </h2> <div id="albumdata" class="row"></div> </br></br> <h2>equipment: </h2> <div id="devicedata" class="row"></div> <script src="js/wall.js"></script> js code

javascript - Google map styled map marker not showing up -

i'm trying set add marker styled map , not showing reason. i've tried know fixed wont show. (function () { var map, mapoptions, styledmap, styles, marker, mylatlng; styles = [ { stylers: [ { hue: '#00ffe6' }, { saturation: -20 } ] }, { featuretype: 'road', elementtype: 'geometry', stylers: [ { lightness: 100 }, { visibility: 'simplified' } ] }, { featuretype: 'road', elementtype: 'labels', stylers: [{ visibility: 'on' }] } ]; mylatlng = new google.maps.latlng(-33.882895, 151.204266); styledmap = new google.maps.styledmaptype(styles, { name: 'styled map' }); marker = new google.maps.marker({ position: mylatlng, map: map }); mapoptions = { zoom: 15, center: mylatlng, maptypecontroloptions: { maptypeids: [ google.maps.map

ios - Custom Row in Eureka -

Image
i trying create custom row shows image. started trying basic custom row indicated in eureka's page: https://github.com/xmartlabs/eureka#basic-custom-rows here's code using: import eureka public class customcell2: cell<bool>, celltype{ @iboutlet weak var switchcontrol: uiswitch! @iboutlet weak var label: uilabel! public override func setup() { super.setup() switchcontrol.addtarget(self, action: #selector(customcell2.switchvaluechanged), forcontrolevents: .valuechanged) } func switchvaluechanged(){ row.value = switchcontrol.on row.updatecell() // re-draws cell calls 'update' bellow } public override func update() { super.update() backgroundcolor = (row.value ?? false) ? .whitecolor() : .blackcolor() } } public final class customrow: row<bool, customcell2>, rowtype { required public init(tag: str

c++ - Caffe classifocation.cpp always returns 100% probability -

Image
i'm trying use caffe c++ classification example (here code ) classify image handwritten digit (i train model on mnist database), returns probabilities [0, 0, 0, 1.000, 0, 0, 0, 0, 0] (1.000 can on different position) even if image has no number on it. think should like [0.01, 0.043, ... 0.9834, ... ] also, example '9', it's predicts wrong number. 1 thing change in classification.cpp i'm using cpu //#ifdef cpu_only caffe::set_mode(caffe::cpu); // <----- cpu //#else // caffe::set_mode(caffe::gpu); //#endif this how deploy.prototxt looks like name: "lenet" layer { name: "data" type: "imagedata" top: "data" top: "label" image_data_param { source: "d:\\caffe-windows\\examples\\mnist\\test\\file_list.txt" } } layer { name: "conv1" type: "convolution" bottom: "data" top: "conv1" param { lr_mult: 1 } param {