Posts

Showing posts from August, 2010

C# & SQL Server : escaping SQL column name AND param? -

i using reserved keywords column names frowned upon, in database didn't design i'm running that. i understand escaping column name tablename.[count] column using reserved keyword, in instance you're working within custom data adapter? my question this, here's mock update statement: sqlcomm = new sqlcommand("update mytable set <stuff>", sqlconn) one of updateable items update mytable set [count] = @count... is there escaping needs take place on @count well? or above appropriate syntax?

linux - Redmine 1.1.2 Default Home Page -

currently /projects/redmine/wiki home page. want change /projects/ have tried in past no success. want state here can follow directions when comes linux barely newb. can myself around have know it. please not tell me change xyz file without telling me heck is. although know how customize wiki page person inheriting site me not know how left me figure out how make simple possible next in line. unfortunately predecessor did not same so here answer came in simple steps. pre-warning worked me depending on how installation performed may bit different. sudo /etc/init.d/nginx stop sudo /etc/init.d/redmine stop /etc/nginx/sites-enabled$ sudo nano redmine ****change ***** location = / { rewrite ^/ /projects/redmine/wiki last; } ****to***** location = / { rewrite ^/ /projects/ last; } ctrl+x press y , enter then run following commands sudo /etc/init.d/redmine start sudo /etc/init.d/nginx start

c - Building Minix 3.3 Errors -

i installed minix 3.3 ,then downloaded source , tried build followd link instructions. got error building minix follows: *** error code 1 stop. make: stopped in /usr/src/gnu/usr.bin/texinfo *** error code 1 stop. make: stopped in /usr/src/gnu/usr.bin/texinfo *** error code 1 stop. make: stopped in /usr/src/gnu/usr.bin *** error code 1 stop. make: stopped in /usr/src/gnu *** error code 1 stop. make: stopped in /usr/src *** error code 1 stop. make: stopped in /usr/src i found same problem discussed in link ,i followd instructions mentioned there: #pkgin in gtexinfo #cd /usr/src/gnu/usr.bin/texinfo #makeinfo -i/usr/src/gnu/dist/texinfo/doc --no-split -o info-stnd.info /usr/src/gnu/dist/texinfo/doc/info-stnd.texi #makeinfo -i/usr/src/gnu/dist/texinfo/doc --no-split -o info.info /usr/src/gnu/dist/texinfo/doc/info.texi #makeinfo -i/usr/src/gnu/dist/texinfo/doc --no-split -o texinfo.info /usr/src/gnu/dist/texinfo/doc/texinfo.txi #cd ../../.. #make -c gnu/usr.bin/texinfo

Which "Select Main Type" should I select when using Eclipse to debug Play Framework based Java Project? -

Image
i 'eclipsified' project - play-java-test created. when using debug configuration - main class should select? i using play framework 2.4.2 you don't start play application via eclipse. use activator command in terminal that. e.g. activator -jvm-debug 9999 run in folder of application runs play/activator in debug mode. debugging eclipse connects running application: in debug configurations go remote java application, choose project. host localhost , port 9999. click debug .

text - C++ (VC): How to detect whether Windows clipboard contains CF_TEXT data? -

i'm complete beginner @ c++, i've managed modify other people's code , put program writes windows clipboard text file, text encoded in codepage specified command line parameter program (for example, myprog.exe 437) write text in codepage 437. if no codepage specified, program writes text file in standard windows codepage 1252. the trouble program crashes if clipboard contains (for example) shortcut or file, not text. can tell me how can exit gracefully if there no cf_text data in clipboard? (or have misunderstood problem?) i've searched answer no success. here vc2010 code (which don't entirely understand, seems work, when clipboard contains cf_text; doesn't work cf_unicodetext, way - output few bytes.): #include <stdafx.h> #include <windows.h> #include <iostream> #include <fstream> #include <codecvt> // wstring_convert #include <locale> // codecvt_byname using namespace std; void bailout(char *msg) { fprintf(stder

c# - Correct way to prevent high CPU usage with infinite while loop (Console/Forms hybrid) -

i put console/forms hybrid program, , achieve behavior looking had "run" console in thread, , launch dashboard another. i used backgroundworker this. in main method start console background worker in dowork block performs normal while loop keep console going. repetitively checking input console , passing along corresponding action. while (true && !program.shutdown) { string consoleinput = ""; consoleinput = program.readfromconsole(); if (string.isnullorwhitespace(consoleinput)) continue; try { program.shell(consoleinput); } catch (exception ex) { program.writetoconsole(ex.message); } } after background worker starting console called i.e. consolebackgroundworker.runworkerasync() call method performs loading sequence. this loading sequence can call second background worker internally launches dashboard on separate thread. now problem faced loop @ end of load sequence. loop prevent

Server error, google.script.run fails when using a shared library -

i have 2 google apps script projects, both of spreadsheet type. let's call 1 server , other client . i want expose functions server can call them client . libraries seem perfect this. unfortunately when add server library client using resources --> libraries... menu option, stuff breaks. note, though server library added client , never use server library functions. (in fact server code.gs totally blank.) server code.gs //nothing, totally blank, these test projects created find out wrong client code.gs //this our entry point //it instantiates sidebar sidebar.html function test() { spreadsheetapp.getui().showsidebar(htmlservice.createhtmloutputfromfile('sidebar') .setsandboxmode(htmlservice.sandboxmode.iframe)); } function testreturn() { logger.log("dotest() called"); return 1; } client sidebar.html <script> function yay(d) { alert('yay: ' + d); } function boo(d) { alert('boo: ' + d);

simplexml - Eclipse xdebug inspect SimpleXMLElement -

Image
i'm using xdebug , eclipse. when load valid xml string simplexml_load_string this: $responsexml = simplexml_load_string($response); i can't seem inspect simplexmlelement variables. when drill down variable, nothing shows. in screenshot below, try drill down $responsexml nothing shows: i can access variable know there: $body = $responsexml->children('soap-env')->body; below xdebug settings. any ideas? that's because simplexmlelement has internal serialization methods. print_r , var_dump produce same. best way debug convert string using: $responsexml->asxml()

associativity - Please explain the output of this simple C program -

this question has answer here: trouble float on c [duplicate] 1 answer what behavior of integer division? 5 answers int = 2, j = 3, k, l ; float a, b ; k = / j * j ; l = j / * ; = / j * j ; b = j / * ; printf( "%d %d %f %f", k, l, a, b ) ; } it simple c program yashwant kanetkar not relate answer . if compile program output getting 0 2 0.00000 2.00000 this simple program not able explain output may getting confused associativity. both / , * have l r associativity , / has unambiguous left operand (necessary condition l r associativity) performed earlier. answer different in case . it simple associativity of operators , nothing complex. i think it's "integer division" property making confused. k = / j * j ; answer 0, because of integ

java - How to run maven project in IntelliJ that requires a file to be in class path? -

Image
i studying book , having difficulty running example code. the code causing problem is: public static void main(string[] args) { classpathxmlapplicationcontext applicationcontext = new classpathxmlapplicationcontext("/com/wiley/beginningspring/ch2/ch2-beans.xml"); the error getting is: exception in thread "main" org.springframework.beans.factory.beandefinitionstoreexception: ioexception parsing xml document class path resource [com/wiley/beginningspring/ch2/ch2-beans.xml]; nested exception java.io.filenotfoundexception: class path resource [com/wiley/beginningspring/ch2/ch2-beans.xml] cannot opened because not exist what tried is, in intellij, imported code maven project , did clean install: [info] --- maven-install-plugin:2.4:install (default-install) @ xml-based-configuration --- [info] installing /users/koraytugay/downloads/spring-book-ch2/xml-based-configuration/target/xml-based-configuration-0.0.1-snapshot.jar /users/koraytug

ajax - Having trouble making an HTTP request to an API using Bigcommerce -

so i'm working on bigcommerce build website client. since bigcommerce not allow upload of php files on system i'm using ajax in script tag in html file. documentation api i'm using says use api key in username field http basic authentication, , requests must transmitted on https. so firstly, here's code $.ajax({ type: 'post', url : "https://www.freightview.com/api/v1.0/rates", data : ({ myrequest }), datatype : "jsonp", accept: 'application/json', beforesend : function(xhr) { xhr.setrequestheader("authorization", "basic " + "mykey:"); } }) i've tried doing username : 'mykey' , other various ways put key in there keep getting 401 unauthroized i've searched around ways , noted few possible issues: ajax request on https it's mentioned on page ajax cannot make cross-domain https requests. m

java - Weblogic send file through ssl -

i have following problem: need send request attached file ip. use jsp page send data. here code example: httpurlconnection connection = (httpurlconnection)url.openconnection(); connection.setdoinput( true ); connection.setdooutput( true ); url url = new url("%myurl"); connection.setrequestmethod( "post" ); connection.setrequestproperty( "content-type", "text/xml" ); connection.setrequestproperty( "accept", "text/xml" ); connection.setrequestproperty( "user-agent", "agent" ); connection.setconnecttimeout( 100000 ); connection.setreadtimeout( 100000 ); outputstream outputstream = null; bufferedreader reader = null; stringbuilder result = new stringbuilder(); outputstream = connection.getoutputstream(); outputstream.write( data ); when use https connection (%myurl= h

c# - How to tell JSON.NET to deserialize JArray to a List<object> when object type is provided? -

let's have following class: class foo { public object any; } this class accepts in field any . when call: jsonconvert.deserializeobject<foo>("{any: 5}") any contains system.int64 . however, when call: jsonconvert.deserializeobject<foo>("{any: [5]}") any contains newtonsoft.json.linq.jarray . how configure json.net in case any contain list<object> ? clarification: there anything, can call: jsonconvert.deserializeobject<foo>("{any: 'c'}") or jsonconvert.deserializeobject<foo>("{any: ['c', 5]}") more clarification: i tell somehow json.net (maybe using jsonserializersettings): when encounter object , json contains array, deserialize (for instance) list<object> . your answer here your [5] array. have cast list. you create own converter, described here

Regex Lookahead character restrictions? -

i trying learn things regex. starting off trying hide matches 9 digit number, such ssn, let through 9 digit numbers have word "order" or "routing number" seems strings have same length work. there way around without creating multiple lines? thanks! (?<!(order:\s|routing\snumber:\s)) (?!000|666)([0-6]\d\d|7[01256]\d|73[0123]|77[012]) ([-]?) ([1-9]{2}) \3 ([1-9]{4}) (?!([\w&/%"-])) for blocking out ssns, 1 seems work ^(?!000)(?!666)(?!9)\d{3}([- ]?)(?!00)\d{2}\1(?!0000)\d{4}$ want not block out 9 digit numbers have words "order" or "routing number" in front of them. many regular expression engines require lookbehind of fixed length, , refuse execute variable-length lookbehind; if case yours, should see warning. if you're not seeing warning, chances problem regexp doesn't wok way think does. however, possible lookbehinds match text prefer count lookbehind, discard/ignore when you're inspecting captures

php - How to insert multiple rows? -

i have set of rows between 10 200, need insert database. active records slow task, using command builder way: $builder = yii::app()->db->schema->commandbuilder; $command=$builder->createmultipleinsertcommand('aviaorders',$ordersinfotosave ); $command=$builder->createmultipleinsertcommand('itineraryinfo',$itineraryinfotosave ); $command->execute(); where $ordersinfotosave , $itineraryinfotosave arrays of attributes following structure. array(array(name=>value,...),array(name=>value,...),...) since using yii-1.1.3, have not commandbuilder's method createmultipleinsertcommand . so, how insert multiple rows, using activerecords commandbuilder ? you can create string of mysql insert command as $ordersinfotosave=''; foreach ($records $record) $ordersinfosave.="('{$record['attribute1vlaue']}','{$record['attribute2vlaue']}'),"; if($order

performance - Swift Dictionary slow even with optimizations: doing uncessary retain/release? -

the following code, maps simple value holders booleans, runs on 20x faster in java swift 2 - xcode 7 beta3, "fastest, aggressive optimizations [-ofast]", , "fast, whole module optimizations" turned on. can on 280m lookups/sec in java 10m in swift. when @ in instruments see of time going pair of retain/release calls associated map lookup. suggestions on why happening or workaround appreciated. the structure of code simplified version of real code, has more complex key class , stores other types (though boolean actual case me). also, note using single mutable key instance retrieval avoid allocating objects inside loop , according tests faster in swift immutable key. edit: have tried switching nsmutabledictionary when used swift objects keys seems terribly slow. edit2: have tried implementing test in objc (which wouldn't have optional unwrapping overhead) , faster still on order of magnitude slower java... i'm going pose example question see if ha

debugging - Microsoft.AspNet.Mvc.Core.pdb not loaded -

i have asp.net 5 , mvc 6 project has reference cl in same solution. when try debug unable enter cl's breakpoints. when come function calling cl , hit f11 continues , doesn't enter function debug. when debug , on function of cl , choose "step specific" , choose function says : microsoft.aspnet.mvc.core.pdb not loaded. microsoft.aspnet.mvc.core.pdb contains debug information required find source module microsoft.aspnet.mvc.core.dll module information version : 6.00.0.10417 original location : <path in local disk> try 1 of following options : change existing pdb , binary search paths , retry: microsoft symbbol servers so when try load microsoft symbol server says : microsoft.aspnet.mvc.core.pdb not found in selected paths my main project in mvc 6 , dll target framework : .net 4.5.2 i think due beta nature pdb files not on symbol servers. assume after rtm (remember vs rc asp.net 5 still beta) added symbol servers.

c# - Errors with CopyRequest and RewriteRequest in Google Cloud Storage -

i'm trying copy , move objects between buckets in google cloud storage using .net api. far can tell constructing request correctly , have verified properties setting below correct , should following cryptic error: google.googleapiexception : google.apis.requests.requesterror required [400] errors [ message[required] location[ - ] reason[required] domain[global] ] here code google.apis.storage.v1.data.object moveobj = new google.apis.storage.v1.data.object() { name = key, size = (ulong)length, contenttype = contenttype }; objectsresource.rewriterequest req = new objectsresource.rewriterequest(_gcsclient, newobj,sourcebucket, key, destbucket, key); req.execute(); any idea might doing wrong? i figured out on own, answer if you're having same issue. credit poorly written , inconsistent cloud storage api more anything. every other operation when create storage 'object' specify name (see first param): new google.apis.storage.v1.data.object() { nam

mysql - Iterate through a column and summarize findings -

i have table (t1) in mysql generates following table: type time full 0 11 yes 1 22 yes 0 11 no 3 13 no i create second table (t2) summarize information found in t1 following: type time num_full total 0 11 1 2 1 22 1 1 3 13 0 1 i want able iterate through type column in order able start summary, for-loop. types can value of n, rather not write n+1 where statements, have update code every time more types added. notice how t2 skipped type of value 2? has been escaping me when try looping. want the types found have rows created in t2. while direct answer nice, more helpful pointed sources figure out, or both. this may want create table t2 if not exists select type, time, sum(full) num_full, count(*) count t1 group type,time order type,time; depending on how want aggregate time column. this starting point reference on group functions : https:

Grails/GORM : org.hibernate.AssertionFailure: null id in xyz (don't flush the Session after an exception occurs) -

i've grails/jaxrs app fails persist nested object graph automatically, , wondering if there datamodel make work. the resource deserializes object properly, save parent object (tauthor), fail save children (tooks) automatically. children have null ids, null references parent. i can manually create child objects, looking better way manage this. domain classes class tauthor { string nameshort integer age static hasmany = [tooks:took] } class took { string title; static belongsto = [tauthor:tauthor] } resource @consumes([mediatype.application_json, "application/json"]) @produces([mediatype.application_json, "application/json"]) @path('/api/tauthor') class tauthorresource { tauthorservice tauthorservice @post tauthor create(tauthor dto) { tauthor created = tauthorservice.save(dto) if(!created.haserrors()) { return created } } } desired, broken service class tauthorservi

shell - bash: get path to parent directory by name -

i'm trying path nearest parent directory named foo : /this/is/the/path/to/foo/bar/baz yields /this/is/the/path/to/foo any idea how this? using bash string manipulation: p='/this/is/the/path/to/foo/bar/baz' name='foo' r="${p%/$name/*}/$name" echo "$r" /this/is/the/path/to/foo or better use: p='/this/is/afoo/food/path/to/foo/bar/baz' echo "${p/\/$name\/*/\/$name}" /this/is/afoo/food/path/to/foo bash faq reference

excel - Highlighting data according to whether the same value turns up in another file -

in excel want highlight names in table tab1 . table looks (but lot longer): name surname luke skywalker han solo leia organa ... (up 50 names) i have table tab2 (saved in excel file) of names. want is: whenever name turns in tab2 , occurrence in tab1 should highlighted (color, or font size or such). i read (german) tutorial , gives me mistake. code following: ="vergleich(a2;teilnahmeliste ausgefüllt!b2:b51;0)" (i'm working german version of excel; vergleich means compare in english; "teilnahmeliste ausgefüllt" name of second file, a.k.a. tab2 .) i think mistake have not included name of spreadsheet ( tab2 has 3 spreadsheets; 1 need called "komplett"). yes, here no use pointing workbook containing several sheets without mention of sheet. the real name of "tab2" workbook has space in it, in formulae references need enclosed - single inverted commas usual. the full name of workbook include extensio

javascript - NodeJS mysql2 Bluebird? -

been testing mysql vs mysql2, seems 2 has made improvments it's not exact drop in replacement. @ same time q library seems easier integrate bluebird seems take less memory , run faster so... my current mysql-bluebird connector follows , allows straight forward use of query('select email users.users id=?',id).then(function(res){var email=res[0][0];}); /* global module, require */ var conf=require('./conf.js').conf; var mysql = require('mysql'); var promise = require('bluebird'); var using = promise.using; promise.promisifyall(require('mysql/lib/connection').prototype); promise.promisifyall(require('mysql/lib/pool').prototype); var pool = mysql.createpool(conf.mysql); var getconnection = function () { return pool.getconnectionasync().disposer(function (connection) { return connection.release(); }); }; var query = function (command) { return using(getconnection(), function (connection) { return connection.queryasync(comman

android - Save ParseObject (subclass) to cloud => [success], pin it immediately => [success], get objects from pinned group [0 results]? -

i have simple subclass of parseobject - wallet . creating 1 new instance , saving cloud via saveeventuall() , afterwards trying pin localstore (and broadcast signal app can update uis since reads objects localstore perfrormance. here's how register subclass in application.oncreate(): public void oncreate() { super.oncreate(); parsecrashreporting.enable(this); parseobject.registersubclass(wallet.class); // <---- parse.enablelocaldatastore(this); parse.setloglevel(parse.log_level_verbose); parse.initialize(this, "private stuff", "private stuff"); parseuser.enableautomaticuser(); parseacl defaultacl = new parseacl(); parseacl.setdefaultacl(defaultacl, true); parseinstallation.getcurrentinstallation().saveinbackground(); if (parseuser.getcurrentuser() == null) parseuser.getcurrentuser().signupinbackground(); } here full subclass itself: @parseclassname("wallet") public class wallet

android - Simple way to store a Linked List -

hi working on android application, , need store linkedlist when user terminated app app processes. have looked @ question easy way save linkedlist in android application? and accepted answer doesn't seem work , androidstudio complains expects , array list rather linked list. realise question 3 years old , must have changed in time not work. can linked lists stored in bundle anymore? or have better way of making linkedlist persistant? cheers as mentioned in comment, won't able save linkedlist bundle, can, however, convert linkedlist arraylist save it, convert when load application again. constructor arraylist , linkedlist accept collection , add elements in order iterator returns them (i.e. fifo linkedlist) public void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); arraylist<myobject> listtosave = new arraylist<myobject>(mylinkedlist); outstate.putparcelablearraylist("key", listtosave); }

javascript - Dynamically access object property using variable -

i'm trying access property of object using dynamic name. possible? const = { bar: "foobar!" }; const foo = 'bar'; something.foo; // idea access something.bar, getting "foobar!" there two ways access properties of object: dot notation: something.bar bracket notation: something['bar'] the value between brackets can expression. therefore, if property name stored in variable, have use bracket notation: var foo = 'bar' something[foo]

dropzone.js - How to run Dropzone processQueue() when not initiating programmatically? -

im trying initiate dropzone adding class form : <form class="dropzone ng-pristine ng-valid dz-clickable" id="photodropzonediv" action="/panel/vehicles/3/photos" accept-charset="utf-8" method="post"> now dropzone works. next set dropzone not auto process queue : dropzone.options.photodropzone = { paramname: "file", // name used transfer file maxfilesize: 5, // mb autoprocessqueue: false, paralleluploads: 500, acceptedfiles: '.jpg,.jpeg,.jpeg,.jpg,.png,.png', addremovelinks: true, init: function(file, done) { this.on("queuecomplete", function(file) { this.removeallfiles(); }); } }; now when call processqueue : photodropzone.processqueue(); it says uncaught typeerror: photodropzone.processqueue not function . how can fix this? dropzone.options.addfiles = { maxfilesize : 4, paralleluploads : 10, uploadmultiple:

symfony - How to store User Roles into the session -

i saw on every page user-object gets fetched again database. though user-object serialized correctly, thought because of relationship roles. how possible store information session? added roles property serialize function of user , added serializable interface roles.

data structures - Why not always use circular array deques instead of array lists? -

almost programming languages have implementation of list uses dynamic array, automatically expands when reaches capacity. example, java has arraylist , , c++ has std::vector . recently learned circular array deques, implemented using dynamic arrays. keep track of starting index of list, , use modular arithmetic access elements. array lists, allow o(1) lookup , o(1) insertion @ end, , space proportional o(n). however, allow o(1) insertion @ beginning. (while java's arraydeque implements data structure, doesn't allow lookup of elements. c++'s std::deque appears use different implementation.) if these array deques have same or better performance characteristics array lists, why not use them default implementation lists? if don't need insertion @ head of list, circular deque gives unnecessary overhead, e.g. indexed methods. in circular deque, accessing index requires adding index of head element , looping around (e.g. using modulo, or bitwise operators

c# - Can't add user to role with SimpleMembership (MySQL) -

i'm trying use simplemembership mysql in code first project. initializer made: websecurity.initializedatabaseconnection("myconnectionstringname", "userprofile", "userid", "username", false); if (!roles.roleexists("employee")) { roles.createrole("employee"); } if (!websecurity.userexists("kurt")) { websecurity.createuserandaccount("kurt", "test"); roles.addusertorole("kurt", "employee"); } the following exception appears "addusertorole": an exception of type 'system.invalidoperationexception' occurred in mysql.web.dll not handled in user code additional information: usertablename configuration not initialized. the user added table "userprofile" (and "webpages_membership") , role "webpages_roles". "webpages_us

ios - When using cocoapods, what is the best way to change the PRODUCT_NAME? -

i created app name "abc". months later decided change name "abcd". believe way changed it, in podfile, changed target "abc" do target "abcd" do . however, recall going through quite few issues/errors afterward in workspace caused lot of stress. long ago can't quite recall though. now i'm ready submit, , want change name 1 last time. i've changed name in itunes connect, want change product_name, , bundle identifier match. what best way this? should change target fields in podfile? or should leave them, , change else in xcode? or need change both or more 1 thing? when have pod file .xcworkspace , pods.xcodeproj generated dynamically pod install process. so 1 way deal is change product name close project in xcode discard existing .xcworkspace , pods folder & podfile.lock run pod install again. the cocoapods engine regenerate project, pull pods cache , recreate pods.xcodeproj new project settings.

java - How do I set a relative path for an .SO file? -

this error: 06-29 16:52:37.729 24144-24144/com.my.app e/androidruntime﹕ fatal exception: main process: com.my.app, pid: 24144 java.lang.unsatisfiedlinkerror: dlopen failed: not load library "build/obj/local/armeabi/libavformat.so" needed "libffmpegwrapper.so"; caused library "build/obj/local/armeabi/libavformat.so" not found build/obj/local/armeabi/libavformat.so looks wrong me. code worked earlier build of ffmpeg - suspect it's way build ffmpeg. the libavformat.so file in apk i'd expect be. this build script ffmpeg: #!/bin/bash ndk=/users/eran/downloads/android-ndk-r10e prebuilt=$ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 platform=$ndk/platforms/android-12/arch-arm prefix=/usr/local function build_one { ./configure --target-os=android --prefix=$prefix \ --pkg-config=./fake-pkg-config \ --enable-cross-compile \ --cpu=armv7-a \ --enable-shared \ --disable-static \ --disable-as

File upload size is not even 2MB in PHP -

i want upload image folder image having size less 20kb being uploaded. not able upload file upto 2mb default in php.ini file. have changes values upload_max_filesize=40m post_max_size=40m i dont know problem is. using xammp server <?php include_once("connect.php"); session_start(); if(isset($_post['subm'])) { extract($_post); $_session['artsubmit_error'] = ""; $title1 = $_post['title']; $intro1 = $_post['intro']; $descr1 = $_post['descr']; $imgname= $_files["file"]["name"]; $artid = "".$_session['logged_user_email'].""; $allowedexts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_files["file"]["name"]); $extension = end($temp); echo "$extension"; if ((($_files["file"]["type"] == "image/gif") || ($_files["file&quo

python - Django API: Upload user files to S3 using Celery to make process async -

i have requirement save user uploaded files s3 , file url returned in response. have considered using django-storages . problem django-storage file first uploaded server s3. i trying make solution file uploaded server, celery task pushes file s3. in case url should return in response s3(file might not have been uploaded before user requests it) or server url , have server redirect s3? since want return value before know s3 storage location can't be s3 storage location. best can return value user can use get s3 storage location server when gets stored (or information it's still waiting stored).

asp.net - How to declare variable of the type System.Collections.Generic.IEnumerable? -

how declare variable of type system.collections.generic.ienumerable? if try: var selecteddata=""; type selecteddata=null; i errors. system.collections.generic.ienumerable<dynamic> since results db.query rows of dynamic. c# compiler doesn't know type @ compile time of query return.

sql - How to prevent certain data from being inserted into the database with If Else statements? -

i have 2 comboboxes, messagebox , send button. when app startups , click on send button comboboxes , messagebox empty, pop-up box comes , says "select client" after doing this, go database , see has added new record table, though didn't put in data after clicking on "send" button. same applies when 1 of 3 controls have has data in it, other 2 don't, , program asks me enter data before succeeds. still adds record despite having if statements. doing wrong? my code: using con new sqlconnection(configurationmanager.connectionstrings("constr").connectionstring) con.open() using cmd new sqlcommand cmd.connection = con cmd.commandtext = "insert tblmytable(client, username, message) values('" & cboclient.text & "', '" & cbouser.text & "', '" & rtfmessage.text & "')" cmd.executenonquery() end using if cboclient.text = &q

javascript - Ajax: rest api call give error: Uncaught SyntaxError: Unexpected token : -

i trying understand problem code work rest api i using "espocrm" , want start working api. in documentation ask use: uses basic authentication like: "authorization: basic " + base64encode(username + ':' + password) so try use code: <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript" > var creds = { username: "myuser", password: "mypass" }; var credentials = btoa(creds.username + ":" + creds.password); $.ajaxsetup({ xhrfields: { withcredentials: false }, beforesend: function (xhr) { xhr.setrequestheader("authorization", "basic" + credentials); return true; } }); $.ajax({ url: 'http://crmurl.com/api/v1/app/user', type: 'get', datatype: 'jsonp', async: false, success: function (data) { co

c# - How to Avoid Injecting User Object Throughout my Web API -

i have project have embedded jwt in header of calls restful web services. jwt includes relevant user information (name, username, roles, etc...) , each of web api controllers pulls session headers , makes available local private variable use in endpoint specific authorization. but need information not @ restful endpoints, need each call database (auditing). only, doesn't seem elegant pass user object every call , have calls pass along in calls too. ultimately, have auditing component embedded in guts of ef logs every call , database. want user object attached have clear audit trail includes not changed, changed it... is there way make user object (which grabbed constructor of web api controller) available may need without injecting each call? *session have worked nicely, services restful , subsequently, session not available.

sql group by dob in decades -

hi question lets say we have student students table student name dob ali 03/05/1991 apo 30/05/1993 haz 04/02/1983 nur 03/05/1986 how can group them dob in decades result should be 1980-1989 haz nur 1990-1999 ali apo thanks assuming dob column date or datetime , re-use first 3 digits in year part of dob, adding 0 or 9 create decade "grouping": select [student name], left(convert(varchar(4), year([dob])), 3) + '0-' + left(convert(varchar(4), year([dob])), 3) + '9' decade students you can't group here, since every student unique. ui should responsible presenting students [decade] .

makefile - Zombie window in C++ software writen on Ubuntu -

i wrote c++ software using gtk2 library ui. it'a simple software analyze map coded on xml file calculate shortest path between 2 points , draw on image (i'm using cairo library this). the compilation (with makefile) gave no errors when execute program window appears empty.if try compile debug option (-g) , execute program ddd debugging returns "no debugging symbols found". makefile is cxxflags += -wall `pkg-config --cflags --libs gtk+-2.0` objectsmy = main.o interface.o callback.o map.o path.o draw.o navigator: dependenciesmy $(objectsmy) g++ -g $(objectsmy) -o navigator `pkg-config gtk+-2.0 --cflags --libs` dependenciesmy: g++ -mm main.cpp interface.cpp callback.cpp map.cpp path.cpp draw.cpp > dependenciesmy -include dependenciesmy .phony: clean cleanall clean: rm $(objectsmy) dependenciesmy rm $ map.png cleanall: rm $(objectsmy) navigator dependenciesmy rm $ map.png can see error in this? you passing -g linke

mysql - How to send database to server with HttpPost in Android and check -

i using code (which copied tutorial) send information database in mysql. in android app: class uploadtodatabase extends asynctask<string, string, string> { list<namevaluepair> namevaluepairs= new arraylist<namevaluepair>(1); //metemos valores al database del server @override protected string doinbackground(string... params) { namevaluepairs.add(new basicnamevaluepair("_id", "2")); namevaluepairs.add(new basicnamevaluepair("columnname", params[0])); namevaluepairs.add(new basicnamevaluepair("columnimage", params[1])); namevaluepairs.add(new basicnamevaluepair("columnsound", "tercero")); try{ //jsonobject json = jsonparser.makehttprequest(url_create_product, // "post", params); httpclient httpclient= new defaulthttpclient(); httppost httppost= new httppost("http://192.168.1.35/androidfileupload/upda

c# - Arcs/vertices to MultiPolygon -

Image
i have list of arcs (vertices) in form: public class arc { public guid id { get; set; } public double x1 { get; set; } public double y1 { get; set; } public double x2 { get; set; } public double y2 { get; set; } } which can serialize multilinestring geojson in case of 2 arcs: { "type": "multilinestring", "coordinates": [ [ [100.0, 0.0], [101.0, 1.0] ], [ [102.0, 2.0], [103.0, 3.0] ] ] } my underlying data represent polygons. more precisely multipolygon : { "type": "multipolygon", "coordinates": [ [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]] ] } just curious, possible transform original arcs multipolygon? thinking doing via sql server's gis functionalities. did ever en

java - ORA-01858 insert log in database -

i writing class in application insert logs oracle database. have used log4j. made these configurations: <appender name="db" class="org.apache.log4j.jdbc.jdbcappender"> <param name="url" value="jdbc:oracle:thin:@10.60.2.8:1521:dbname"/> <param name="driver" value="oracle.jdbc.driver.oracledriver"/> <param name="user" value="test"/> <param name="password" value="test"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="insert log_overloadrequest values('%x{today}','%x {currentrequesturi}','%x {username}','%x {uri}','%x {method}','%x {cpuload}','%x {timespent}','%x {lastcpuload}','%x {firstfreememory}','%x {lastfreememory}','%x {appid}','%x {sessionid}')"/> </

javascript - Weird `$evalAsync` behaviour -

abstract hi, i'm trying manipulate scroll logic of angular application (by hand), since there no such thing onloaded event in angular, trying accomplish within $interval loop. worked ui flickering, looked scroll first goes way , down again making terrible. i've started looking solution problem , found this answer. in said have looking $evalasync capable of queueing operation before ui it's rendering. lead me following code: var restorescroll = function (scroll) { angular.element($window).scrolltop(scroll); var fn = function () { debugger; var value = angular.element($window).scrolltop(); if (value !== scroll) { angular.element($window).scrolltop(scroll); $rootscope.$evalasync(fn); } } $rootscope.$evalasync(fn); }; which hangs , shows misunderstanding of angular's $evalasync method. question according code above need method trying

How to call a function using object prototype in Javascript -

i had doubt.is possible call 1 function/method present inside 1 class using object prototype in javascript ? if possible can make below code correct. (function(){ window.peer=function(){ var peer=this; peer.getmessage=function(){ alert("hello!!! site.") } } })(); <button type="button" id="btn">click here</button> <script> document.getelementbyid('btn').onclick=function(){ peer.prototype.getmessage(); } the above code throwing error.please give me idea resolve this. (function(){ window.peer=function(){} window.peer.prototype.getmessage=function(){ alert("hello!!! site.") } })(); <button type="button" id="btn">click here</button> document.getelementbyid('btn').onclick=function(){ var peer = new peer(); peer.getmessage(); } you can treat peer object