Posts

Showing posts from September, 2014

c - How compare number with numbers inside myfile -

i'm developing software , need insert students , check if same students registered in system. int setnumaluno() //definir num de aluno { int num; printf("\n"); printf("numero de aluno: \n"); scanf("%d", &num); printf("a verificar se existe o aluno\n"); checkstudent(num); return num; } void checkstudent(int num)//metodo responsavel por verrificar no ficheiro se o mesmo existe { int numerofile=0; int r = 0; while (numerofile != eof) { numerofile = fscanf(fp, "%d", &r); if (num == numerofile) printf("numero existe"); else if (num != numerofile) setnomealuno(); } } i've tryed implement while cycle can't check if number exists in file. file called when fscanf() instruction can't check if have member number. how can perform, code, verify if student exists or not? do way: use fopen

input - read.table line 15 does not contain 23 elements - R -

here code used: d = read.table("movies.txt", sep="\t", col.names=c( "id", "name", "date", "link", "c1", "c2", "c3","c4", "c5", "c6","c7", "c8", "c9","c10", "c11", "c12","c13", "c14", "c15","c16", "c17", "c18", "c19"), fill=false, strip.white=true) and here text file: 1 toy story (1995) 01-jan-95 http://us.imdb.com/m/title-exact?toy%20story%20(1995) 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 goldeneye (1995) 01-jan-95 http://us.imdb.com/m/title-exact?goldeneye%20(1995) 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 3 4 rooms (1995) 01-jan-95 http://us.imdb.com/m/title-exact?four%20rooms%20(1995) 0 0

c# - Drawing into a shared graphics buffer out of different threads? -

i'm trying write class drawing operation directy draw onto screen. idea have constant loop, rendering graphics buffer , several functions, write graphics buffer (lines, rectangles, etc). there problem threads. can't write graphics buffer, when used in loop in different thread. need different thread keep constant performance/framerate. tried kind of create "shared" buffer in form of bitmap, performance sucks. has got idead, how solve this? current error message is: system.invalidoperationexception @ mygraphics.clear(color.black); class drawingonscreen { intptr desktop; //a pointer desktop graphics g; //the graphics object bufferedgraphicscontext currentcontext; bufferedgraphics mybuffer; //graphics buffer thread renderthread; //the thread [dllimport("user32.dll")] static extern intptr getdc(intptr hwnd); public void drawline(vector2d point1, vector2d point2, float width, color color) //vector2d point2d {

JavaScript RegEx format string containing American Express card number -

i'm trying format string containing american express credit card number using regular expression. here's i'm using visa, mastercard , discover number formatting, doesn't work american express: var formatvisamastercarddiscover = function ( number) { return number.split(/(?=(?:\d{4})+($))/).filter(function ( n) { return (n != ""); }).join("-"); }; so, i'm curious regular expression amex number be. format should {4}-{6}-{5} . i'd appreciate because couldn't find while searching except how validate not want. want format it. you can use: var ccnum = '341256789012345'; var ccfmt = ccnum.replace(/\b(\d{4})(\d{6})(\d{5})\b/, '$1-$2-$3'); //=> 3412-567890-12345 regex demo

java - How is it possible that an interface is being instantiated in this sample code? -

this question has answer here: can instantiate interface in java [duplicate] 5 answers a manual i'm reading includes example, scheduledexecutorservice being created. however, api shows scheduledexecutorservice interface, not class. how possible being instantiated? here's sample code shown: import java.util.concurrent.scheduledexecutorservice; import java.util.concurrent.executors; import java.util.concurrent.scheduledfuture; import static java.util.concurrent.timeunit.*; class beepercontrol { private final scheduledexecutorservice scheduler = executors.newscheduledthreadpool(1); public void beepforaminute() { final runnable beeper = new runnable() { public void run() { system.out.println("beep"); } }; final scheduledfuture<?> future = scheduler.sch

proof - Why Coq doesn't allow inversion, destruct, etc. when the goal is a Type? -

when refine ing program, tried end proof inversion on false hypothesis when the goal type . here reduced version of proof tried do. lemma strange1: forall t:type, 0>0 -> t. intros t h. inversion h. (* coq refuses inversion on 'h : 0 > 0' *) coq complained error: inversion require case analysis on sort type not allowed inductive definition le however, since nothing t , shouldn't matter, ... or ? i got rid of t this, , proof went through: lemma ex_falso: forall t:type, false -> t. inversion 1. qed. lemma strange2: forall t:type, 0>0 -> t. intros t h. apply ex_falso. (* changes goal 'false' *) inversion h. qed. what reason coq complained? deficiency in inversion , destruct , etc. ? i had never seen issue before, makes sense, although 1 argue bug in inversion . this problem due fact inversion implemented case analysis. in coq's logic, 1 cannot in general perform case analysis on logical hypothesi

c# - You must add a ref to System.Runtime... when deployed to Azure Websites -

site runs fine locally, throws windows azure websites hosting environment. cs0012: type 'system.object' defined in assembly not referenced. must add reference assembly 'system.runtime, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' so infamous message , has known fix; <compilation ... > <assemblies> <add assembly="system.runtime, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" /> </assemblies> </compilation> i understand asp.net pages/views compiled @ different time controllers , other logic, (that vnext going address this), , above adding reference page compilation side of things. but question is: why work on development machine needs config on waws environment, you'd think setup? i know what's different, what's missing on target environment such referencing portable library (portable, meaning should 'just work' in variety of environments) br

powershell - Power shell append with export-csv -

i know question has been answered many times apologize asking again. wrote first power shell script perform aggregation task. cant figure out how append existing csv file. right script aggregating column, want modify aggregate multiple columns need append output. my input file looks this: salesid qty amount 1 2 5 1 3 6 2 5 9 2 6 5 my current output is: salesid sum 1 5 2 11 but want output this: salesid sum amount 1 5 11 2 11 14 my script: import-csv $infilepath | group-object $groupbycolumname| %{ new-object psobject -property @{ $groupbycolumname= $_.name sum = ($_.group | measure-object $sumcolumnname -sum).sum } }| export-csv $outfilepath -encoding "utf8" -notype please me out here. thanks. the information there access need it. $data | group-object salesid | %{ new-object pscustomobject -property @{ sale

angularjs - how I make <a> to show me alone element with a filter? -

this code want filter 'marcas' when click .... <body ng-controller="marcascontroller"> <a>chevrolet</a> <a>renault</a> <ul ng-repeat="marca in marcas"> <li ng-repeat="tipo in marca.modelo">{{tipo.nombre}}</li> </ul> </body> ---show me alone renault or chevrolet depends click--- var app = angular.module('app', []); app.controller('marcascontroller', ['$scope', function($scope) { $scope.marcas =[ { "nombre": "chevrolet", "image": "images/aveo.jpg", "modelo": [ {"nombre":"aveo", "color":"black"}, {"nombre":"corsa", "color":"yellow"} ], "tab": "aveo" }, { "nombre": "renault", "image": "images/aveo.jpg", "modelo": [ {"n

php - Proper way to access parent's methods in child class -

i have childclass extends parentclass . parentclass has constructor takes 2 arguments __construct('value2', parentclass::common) . trying call inherited newselect() method within child class. far has not been succesfull. how call newselect() childclass ? possible though parentclass has constructor takes 2 parameters? parent class parentclass { const common = 'common'; protected $db; protected $common = false; protected $quotes = array( 'common' => array('"', '"'), 'value2' => array('`', '`'), 'value3' => array('`', '`'), 'value4' => array('`', '`'), ); protected $quote_name_prefix; protected $quote_name_suffix; public function __construct($db, $common = null) { $this->db = ucfirst(strtolower($db)); $this->common = ($common === self::common); $this->quote_name_prefix = $this->quotes[$this->db][0];

C code behaves differently as a main, as a called function -

i writing program processes users text. first wrote functions different mini-programs consisting of main-func , worked perfectly. assembling code got stuck, because 1 function behaves differently. function used input text user , place dynamically allocated memory. input ends when "end" string entered. first was: #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char** text = null; int i,j,flag=1; int count_strings; char c; for(i=0;flag;i++) { text = (char**)realloc(text,sizeof(char*)*(i+1)); *(text+i) = null; c = 0; for(j=0;c!='\n';j++) { c = getchar(); *(text+i) = (char*)realloc(*(text+i),sizeof(char)*(j+1)); *(*(text+i)+j) = c; } *(*(text+i)+j-1) = ' '; *(*(text+i)+j) = '\0'; if(strcmp(*(text+i),"end ")==0) { flag = 0; free(*(text+i)); } } count_strings = i-1; for(i=0;i<count_strings;i++) {

sql - Bulk Insert - Row Terminator for UNIX file + "\l" row terminator -

so have been wrestling perplexing issue bulk insert time. files come linux box , when @ them in hex edit mode/notepad ++ appear have linefeed (0a) row terminator. store bulk insert statements in table later job selects , executes statement in table load data staging table. the particular case perplexing me table has 7 columns. data file has first 4 columns, rest should left null. typically this: bulk insert staging_table 'file_location' ( datafiletype = 'widechar' , fieldterminator = ',' , rowterminator = 'something_here' ); the row terminator has been biggest source of issues. when try use "\n" bulk insert fails on truncation error-- seems treat file 1 long string , delimits columns correctly until runs out of columns (hence truncation error). when use "0x0a" bulk insert fails on "unexpected end of file" error. there blank line @ end of file when removed still threw same error i'm n

java - Running .war files with Jetty -

i'm struggling creating basic of examples of running jetty application , launching .war package @ same time. find says put .war in "$jetty_home/webapps", i'm not sure how verify "$jetty_home" is. i'm trying extend simple heroku default application found @ https://github.com/heroku/java-getting-started.git . directory structure: src/ -- main/ ---- java/ ------ main.java target/ -- (lots of stuff in here) pom.xml procfile webapps/ -- workbench.war i run application java -cp target/classes:target/dependency/* main . main.java identical to: https://raw.githubusercontent.com/heroku/java-getting-started/master/src/main/java/main.java . how can application run .war files? whenever visit localhost:5000/workbench see "hello world" should seeing workbench application contained in workbench.war . i guess trying run jetty embeded in application, , want serve war file. check link http://www.eclipse.org/jetty/documentation/current/embe

php - Apache 2.4 SSL 1.0.1 ports conflicting -

have apache enviornment hosting php based website. having issues configuring ssl. httpd-ssl.conf file pointing port 443. changed assumed needed point same port configured within httpd.conf the following of important httpd.conf configurations listen 882 <virtualhost *:882> serveradmin admin@example.com documentroot "/u/apache/htdocs/hil" servername server1 </virtualhost> <virtualhost *:882> serveradmin admin@example.com documentroot "/u/apache/htdocs/hil" servername server1 <directory "/u/apache/htdocs/hil"> order allow,deny allow # new directive needed in apache 2.4.3: require granted </directory> </virtualhost> <ifmodule mod_rewrite> rewriteengine on rewritecond %{request_method} ^(trace|track) rewriterule .* - [f] </ifmodule> traceenable off below have configured httpd-s

node.js - Emit an event to a child object -

i'm writing nodejs module , trying bind event emitter "scrappy.get". seems can bind "scrappy" .... "scrappy.get(key).on('complete'...." not work. how send event child object 'get'? my nodejs module: var util = require('util'), eventemitter = require('events').eventemitter; function scrappy(id) { } util.inherits(scrappy, eventemitter); scrappy.prototype.get = function (key) { var self = this; self.emit('complete', "here"); **return this;** } module.exports = scrappy; my nodejs app code: var scrappy = require('./scrappy.js') var scrappy = new scrappy("1234"); scrappy.get("name").on('complete', function(data){ console.log("secondary"); }); result: scrappy.get("name").on('complete', function(data){ ^ typeerror: cannot call method 'on' of undefined edit: solved. adding

c# - Try catch not catching exception with input -

i creating blackjack game , far have made card class. card class works, when go test card class when test3 exception should catch because "x" not in values array reason doesn't catch , displays x instead of error message "invalid input". want happen value set accessor should search string[]values array , determine if value argument valid or not , if isn't throw new exception. not sure on how fix this. can't use enum values need use values array. any appreciated here have card class class card { public enum suit { hearts, spades, diamonds, clubs }; private suit _suit; private string _value; public card(suit suit, string value) { _suit = suit; _value = value; } public suit suit { { //return member variable value return _suit; } set { _suit = value; } } private string[] values = { "a", "2&

node.js - Nodejs https does not fail on ssl certificate failure -

Image
i using https library nodejs send https request using following code. valid 200 status though certificate of server being tested expired. https.get(options, this.onresponsecallback.bind(this)); the value of options shown below. { protocol: 'https: ', slashes: true, auth: null, host: 'xxxxxxxx', port: '443', hostname: 'xxxxxxxx', hash: null, search: 'xxxxxxxx', query: 'xxxxxxxx', pathname: '/xxxxxxxx/xxxxxxxx', path: '/xxxxxxxx/xxxxxxxx?xxxxxxxx', href: 'https://xxxxxxxx', headers: { 'user-agent': 'nodeuptime/3.0(https://github.com/fzaninotto/uptime)' }, rejectunauthorized: true } if hit same url in browser following error. how nodejs fail when cert expired? i think browser security policy bit stricter can in node. you can access info server's certificate by: https.request(options, function(response)

asp.net mvc - WebAPI Controller Names with Underscores -

webapi has naming convention "foocontroller" controller names. similar asp.net mvc. our codebase uses underscores separate words in identifier named, e.g. "foo_bar_object". in order controller names follow convention, need way name our controllers "foo_controller". basically, don't want url routes "oursite.com/api/foo_/", , don't want have make exceptions everywhere underscore (e.g. route config, names of view folders, etc). in mvc, do: global.asax protected void application_start() { ... controllerbuilder.current.setcontrollerfactory(new custom_controller_factory()); } custom_controller_factory.cs public class custom_controller_factory : defaultcontrollerfactory { protected override type getcontrollertype(requestcontext request_context, string controller_name) { return base.getcontrollertype(request_context, controller_name + "_"); } } this seems take care of problem in once place i

arraylist - Parse.com - Android: boolean on if a User belongs to an Array -

i have array of users in class, under column "likers" want check whether or not current user contained in likers array, in minimal time current (dysfunctional) code: arraylist<parseuser> likers = (arraylist<parseuser>) rating.get("likers"); boolean contained = likers.contains(parseuser.getcurrentuser()) //always returns false how can change make work? feel it's match on objectid . maybe there function in parse sdk? thanks! you can use next approach. parseobject rating = parseobject.create(parseobject.class); arraylist<parseuser> likers = (arraylist<parseuser>) rating.get("likers"); boolean contained = containsuser(likers, parseuser.getcurrentuser()); method private boolean containsuser(list<parseuser> list, parseuser user) { (parseuser parseuser : list) { if (parseuser.hassameid(user)) return true; } return false; } little bit code. works correct,

vb.net - How to automatically restart a program after it's closed -

i'm developing timer kids automatically shut down computer once time , trying figure out way program automatically restart if closed via task manager. i've posted code program bellow if it's help. imports system imports system.io imports system.text imports system.collections.generic public class digparent 'add startupp: ' my.computer.registry.localmachine.opensubkey("software\microsoft\windows\currentversion\run", true).setvalue(application.productname, application.executablepath) 'remove startup 'my.computer.registry.localmachine.opensubkey("software\microsoft\windows\currentversion\run", true).deletevalue(application.productname) 'use application setting boolean not add same application startup more once 'charge feature 'to ' 'wrongn height when make timer unstopable 'above dim x, y integer dim newpoint new system.drawing.point public second integer public checkdone boolean public checkoff boolean pub

html - Dash between elements of a list -

this first question here apologies if has been answer somewhere else, could't find related entry. basically have horizontal list has dashes between elements. how target , remove these dashes? here code: http://fiddle.jshell.net/5rbkbm5w/1/ your <a> tags not closed, causing white space underlined, showing underline seemingly no reason. close tags: <li><a href="#">maps </a> </li>

Tagging XCode's Archive builds in Git or another SCM -

i'd xcode archive builds automatically tag scm (git in project). i've noticed in schema editor, archive builds can run pre , post step build scripts . ideal if post steps run if build successful, , tag go there. i'd tag name refer name of build configuration (i have testflight , appstore configurations, debug , release, not archived), version number built, , build number. tag might go like: testflight_2.1.3_#11 or appstore_2.9.0_#3 . in xcode's project settings, can use variable substitutions, such $(build_configuration) . can these used in archive build script? i'm not sure if there variable current version string , build number of app. i've not managed find 1 if there is. in xcode's project settings, can use variable substitutions, such $(build_configuration). can these used in archive build script? yes. build settings available environment variables scripts run part of run script build phase. easy way see variables set (if don

javascript - Removing border when the form field is in focus -

i making border appear form field during form validation. appending error class name div class name achieve it: document.getelementbyid("name").classname = document.getelementbyid("name").classname + " error"; document.getelementbyid("email").classname = document.getelementbyid("email").classname + " error"; &.error { border:3px solid #cc4337; transition:#cc4337 .2s linear 0; -webkit-transition:#cc4337 .2s linear 0; -moz-transition:#cc4337 .2s linear 0; } now, when click onto form field retype want border disappear. there way can remove error (or style border:none) class name tracking field focused? thanks try &.error:focus{ border: none; border-color: transparent; } or try document.getelementbyid(id).style.property=new style eg. <script> document.getelementbyid("error").style.border-color = "transparent"; </script> and possibl

DROOLS pattern matching nested lists with complex objects -

i'm struggling pattern-matching routine in drools traverses lists of complex nested objects. i have pojo structure this: class myfact { private list<a> listofa; public list<a> getlistofa() { return listofa; } } class { private list<b> listofb; private string stringfield; public list<b> getlistofb() { return listofb; } public string getstringfield() { return stringfield; } } class b { private string otherstringfield; public string getotherstringfield() { return otherstringfield; } } i trying find correct syntax collect objects of type 'a' match set of criteria includes matching fields in objects contained within 'a's listofb . i think rule needs this, pattern have won't compile while inside collect( ... ) import java.util.arraylist; rule "tricky syntax" when $myfact: myfact() $filteredlistofa: arraylist( size > 0 ) collect ( a( stringfield == "something"

ruby on rails - Using RSpec to test a method relying on an external Cassandra call -

i trying improve test coverage on activerecord model creates csv file querying cassandra database. use rspec. i'm having hard time figuring out how test cassandra_file method shown below, since calls cdbh (also shown below), creates live connection cassandra database. i tried doing like: it 'copys cassandra' cdbh = cassandra.stub(:connect) date = '2013/12/27' expect(device).to receive(:save_csv).with(date, cdbh.execute(options)) device.raw_file(date.new(2013,12,27)) end but error: failures: 1) device raw_file generic device copys cassandra failure/error: unable find matching line backtrace nomethoderror: undefined method `stub' cassandra:module i looked @ other questions dealing stubbing api calls, of suggested gems vcr or webmock seem aren't useful specific use case, since i'm not trying replicate http request. there better way test this? that's going reasonable test, or more trouble it's worth? t

java - Is this caching a closure thread save? -

public class exampleservlet extends httpservlet{ private closure closure; @override protected void dopost(final httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { // stuff here... if (this.closure == null){ this.closure = new closure(){ @override public void somefunction(){ req.getrequesturi(); // it... } } } // later... this.closure.somefunction(); // << thread-save?? // more stuff here... } } in example, have no control on closure ! if test this, works fine. question is: does every request-thread new copy of closure -field? otherwise, when new request comes in, referenced req -field change while somefunction() still executing. or handled declaring req final ? the same servlet instance used requests. so closure created first request , shared among subsequent req

templates - type as returntype in c++ -

is there possibility return type returntype function , use member variable using this: constexpr type myfunction(int a, int b){ if(a + b == 8) return int_8t; if(a + b == 16) return int_16t; if(a + b == 32) return int_32t; return int_64t; } template<int x, int y> class test{ using type = typename myfunction(x, y); private: type m_variable; }; when trying example in qt says error: 'constexpr' not name type error: 'test' not template type class test{ ^ in earlier question showed me http://en.cppreference.com/w/cpp/types/conditional function, works 2 types. you cannot normal function. however, done using template meta-programming. kind of template called type function . #include <cstdint> template<int bits> struct integer { /* empty */ }; // specialize bit widths want. template<> struct integer<8> { typedef int8_t type; }; template<> struct integer<16> { typedef in

python - Assign key & value for list? -

here program far: file = open('cass.txt', 'r') f = file.readlines() file.close() classcode = input('please enter class code: ' ) print("class list for", classcode) line in f: if line.find(classcode)>=0: names = line.split() names1 = names[0].split(',')[0:3] print(names1) and output class tda3m102 is ['abdull', 'sonia', 'f'] ['armstrong', 'sammi', 'f'] ['barrey', 'tina', 'f'] ['bu', 'kyle', 'm'] ['cheng', 'henry', 'm'] ['dance', 'daniel', 'm'] ['east', 'adam', 'm'] ['frasier', 'annie', 'f'] ['han', 'brandon', 'm'] ['huang', 'peter'] ['kauffman', 'fredricka', 'f'] ['lunsford', 'mike', 'm'] ['leung', 'dan', 'm&

angularjs - Cannot get the scope os a controller in anugular.js -

i trying test javascript file has in controller , html dom elements interacts with. the class under test is: function baseconceptmenu(options) { var baseconceptmenu = new basemenu(options); //public function -->method under test function showcodeconcepttoolbar() { var scope = angular.element('#toolbar').scope(); scope.$apply(function() { scope.toolbarcontroller.show(baseconceptmenu.someobject); }); } i trying mock controller , create html dom element "toolbar" on fly without trying create external html template sake of testing. i trying create div "toolbar" inside before each , mocking "codeconcepttoolbarcontroller" controller beforeeach(inject(function ($rootscope, $compile) { elm = document.createelement('div'); elm.id = 'toolbar'; scope = $rootscope.$new(); createcontroller = function() { return $controller('codeconcepttoolbarcontroller'

ios - AMSlideMenu:Content ViewController must to be UINavigationController? -

i add slide menu effect in ios project, , trying library github( https://github.com/socialobjects-software/amslidemenu ) . in readme or demo, says: add content viewcontroller have to following: • create content view controller , embed in uinavigationcontroller • connect amslidemenulefttableviewcontroller or amslidemenurighttableviewcontroller custom segue amslidemenucontentsegue , set identifier. my content viewcontroller must uinavigationcontroller ? anybody has practice in project ( https://github.com/socialobjects-software/amslidemenu )? in advance.

java - JavaFX 8 TabPane - Tab buttons keep getting scrolled out of the viewport of TabPane header -

Image
i got weird issue tabpane has tab buttons on left. problem present during runtime of applications not in scenebuilder (2.0) preview. every time selected tab changes (either user click or changing selectedindex via code) tabs shift position upwards , out of viewport of tab button area can see in examplary picture below . amount of pixels shifted seems depend on width of tabpane (the lower width, more shifts) , of time buttons in tabpane shifted out of viewport. it possible tab buttons normal position focusing different window or scrolling upwards or downwards in tab button area. once in normal positions they're shifted again when selected tab changes again. i tried access tabheaderskin objects (style class "tab") seem runtime objects in tabpane header area change result of shifting. according scenic view, localy value changes. however, mytabpane.lookupall(".tab") finds nothing. except that, there seems no possibility @ access auto scroll beha

c++ - OpenMP reduction with template type -

template <typename t, std::size_t n> static t sum(const std::array<t, n>& a) { t result; // type of result (t) not determined when pre-process? #pragma omp parallel reduction(+: result) for(int = 0; < static_cast<int>(n); i++) { result += a[i]; } return result; } i can compile , run above code msvc , gcc. yes, it's excellent! but question in code comment; "because type of result (t) not determined while pre-processing '#pragma', how compiler validate type of result suited openmp reduction?" . i'm sure it's ok if t=double , ng if t=std::string, how pre-processor know type of t? i remember couldn't compile above code minor c++ compiler long time ago. let me ask behavior (compilable or uncompilable) correct in context of c++/openmp specifications. it's unspecified (for openmp 3.0 or later) or undefined (for openmp 2.5) reduction 1 of data-sharing attribute clause

Can a function return more than one value in C? -

i'm beginner in c. heard function in c cannot return more 1 value, not case in program; it's returning more 1 value , code running fine. please explain. #include<stdio.h> int main () { int a=10,b=9; return a,b; } function can return single value . #include<stdio.h> int main () { int a=10,b=9; return a,b; } when returning that. here comma (,). operator work. return last value list.

mysql - How to make foreign key update based on parent -

i have 2 tables, , i've made relation using designer between id column of first table user_id column of second table. , how add code or when, example, parent (id) deleted, user_id values correspond deleted id deleted? tried deleting 1 of registered ids, corresponding rows in child table didn't deleted. i've done searching, i'm still confused. thank you. note: i'm experimenting mysql , php, , little blog i'm making. please add on delete referential action foreign key constraint. more details found here: https://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html for case, on delete cascade should fine.

sql - multiuser log in at same time -

i have created online examination system. working fine single user @ time. however, problem occurs when more 1 user logs in. there 20 questions in each test. if single user doing test works fine. user can 20 questions. user logs in @ same time. user not getting 20 questions. user1 has completed 12 question. user2 8 question. suppose there there user1,user2,user3 logged in @ same time. user1 did 8 questions, user2 did 6 questions , user3 8 questions. arrive @ result page without completing 20 questions. means if there 20 users 1 question instead of 20. can help? try { sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["hasexaminationconnectionstring"].connectionstring); sqlcommand cmd = new sqlcommand(); sqldatareader dr; cmd.connection = con; cmd.commandtext = "select * tblregister name=@name , email=@email"; cmd.parameters.add("@name", sq

oracle - PL/SQL functions with one parameter -

i wondering if help. i'm @ wits end this. i want create function take 1 parameter. here code. keep getting error when run: error(3,19): pls-00103: encountered symbol ";" when expecting 1 of thefollowing: begin function pragma procedure subtype type current cursor delete exists prior external language code set serveroutput on; create or replace function checkbooktype ( p_book_type titles.category ) return boolan is; begin if (p_book_type = 'business') return true; else return false; end if; return v_returnvalue; end checkbooktype; least verbose solution: create or replace function checkbooktype ( p_book_type in titles.category%type ) return boolean begin return p_book_type = 'business'; end checkbooktype;

Determine which of a set of images has been recompressed/resaved the least -

Image
i'm working on system fuzzy image deduplication. right now, have functional system can large-scale phash fuzzy image searching , deduplication via either dct-based or gradient-based perceptual hashes. however, while determining if image has been reduced in size programatically trivial, how can determine image parent of which? basically, if have 2 images same resolution, 1 resaved version of other (either in different format (jpg/png), or recompressed), how can determine 1 original in reliable manner? (note: assume metadata has been stripped images, wish simple.) bonus points if solution easy implement in python. this isn't positive answer, spent while of time evaluating use of average entropy per-pixel determine if useful metric determining how compressed image is. i have write here . some excerpts: variance in entropy across compression levels on sipi reference image database images. in retrospect, x-axis should labeled "jpeg quality le

jquery - Show Selected Category => Product limit in each Page [ 1,2,3,... ] using PHP and MySQL -

when click on next link or page after page 1, following error: notice: undefined index: id in c:\wamp\www\rd\view\client\fg-shop.php on line 116 warning: mysql_num_rows() expects parameter 1 resource, boolean given in c:\wamp\www\rd\view\client\fg-shop.php on line 121 warning: mysql_num_rows() expects parameter 1 resource, boolean given in c:\wamp\www\rd\view\client\fg-shop.php on line 135 no products displaying in page , [ 1,2,3,...] link. <?php include_once("../../config.php"); include_once __base_path."/model/categorymodel.php"; include_once __base_path."/model/categoryimagemodel.php"; $catid = $_request['id']; if($fkcategoryp=="") $pageresult = $categoryimagemodel->categoryimageselect('status=1 , fkcategory='.$catid,'sortorder','asc',''); else $pageresult = $categoryimagemodel-categoryimageselectparent($fkcategory,'sortorder','asc'

height - How can we handle out of memory error? -

how can handle out of memory error? one of our customers contacted , said when uploads images, face error out of memory i asked size of images said 4mb, upload 7 mb image successfully. so tried upload big images until faced error, of them uploaded faced same error when uploading of them i found error not related in size of image, it's related width , height of image you can understand better @ link memory error but don't know max-width , max-height are, can validate prevent error. i forgot say, resize images dynamically. but can't users resize images because them take large pictures phone maybe of them didn't know how can resize images photoshop. please help ideally should restructure code use less memory. there ways decrease memory overflow jvm process. just give jvm more memory -xmx option. you should decode insamplesize option reduce memory consumption. another option injustdecodebounds can find correct insamplesiz