Tuesday 15 February 2011

php - How do I keep a local copy of a large JSON file updated? -



php - How do I keep a local copy of a large JSON file updated? -

i'm writing php-based website, , requires json table other website. it's relatively big file hardly ever gets updated, preferably i'd maintain local re-create , utilize that, rather request server same file.

but need latest version of json file, otherwise lot of links site break.

i'm new web-development i'm not sure how approach this. i've read on things redis , memcaching, i'm not sure if that's i'm looking or how working.

how can maintain local version of json file date, or there improve approach?

normally in situations these request updated re-create of file every x hours , store on server. in pracice: on every page load check how old file (filemtime()); if it's older x hours, download 1 time again , replace contents of cached files. x, number of hours, has adjusted accordingly frequency update original document. example, if know document updated every 6 hours, may want refresh every 2 hours (x=2), example.

you should prepared have outdated cache, however: @ moment cached file can x hours (e.g. if download file , webmasters replace 1 min later, cached file outdated x hours less minute).

there ways can improve process:

if file big, downloading while preparing web page in response visitor can bad idea. indeed, visitors hate waiting, , every ms more takes generate page more visitor go away , lose interest. there studies that (ironically, page took me few seconds load :) - , in meanwhile went tab type). solution: have background job periodically refreshes cached file. can cron; if don't have access cron, there other ways emulate in php. example, see the guys @ techcrunch came with. instead of downloading entire file every time, (if remote server supports it) first create request see if file has changed. that's possible if-modified-since header. see illustration this question. way create head http request , check lastly modified time. note not servers may back upwards these tricks (especially if remote server generating file dynamically). if supported, however, can decrease time interval between each request (the x above), since won't downloading whole file every time.

php json

wsgi - Upgrade to Django 1.7 - AppRegistryNotReady exception -



wsgi - Upgrade to Django 1.7 - AppRegistryNotReady exception -

i'm struggling trying create things work after upgrading django version 1.6.7 1.7. looks i'm not able focus on right matter. seek resume situation far.

thing is: if leave command django.setup() in wsgi.py file, when seek access website internal server error (500). looking @ logs, get:

[sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] mod_wsgi (pid=23258): target wsgi script '/home/thrasher/webapps/django/myproject.wsgi' cannot loaded python module. [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] mod_wsgi (pid=23258): exception occurred processing wsgi script '/home/thrasher/webapps/django/myproject.wsgi'. [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] traceback (most recent phone call last): [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] file "/home/thrasher/webapps/django/myproject.wsgi", line 16, in <module> [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] application = get_wsgi_application() [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] file "/home/thrasher/webapps/django/lib/python2.7/django/core/wsgi.py", line 14, in get_wsgi_application [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] django.setup() [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] file "/home/thrasher/webapps/django/lib/python2.7/django/__init__.py", line 21, in setup [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] apps.populate(settings.installed_apps) [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] file "/home/thrasher/webapps/django/lib/python2.7/django/apps/registry.py", line 78, in populate [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] raise runtimeerror("populate() isn't reentrant") [sun oct 12 12:38:50 2014] [error] [client 127.0.0.1] runtimeerror: populate() isn't reentrant

however, if comment django.setup() call, trying access website gets me stack trace:

environment: request method: request url: http://www.creepyvisions.it/ django version: 1.7 python version: 2.7.8 installed applications: ('django.contrib.auth', 'django.contrib.admin.apps.simpleadminconfig', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'myproject.archivio', 'sorl.thumbnail', 'django.contrib.sitemaps', 'rest_framework') installed middleware: ('django.middleware.common.commonmiddleware', 'django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware') traceback: file "/home/thrasher/webapps/django/lib/python2.7/django/core/handlers/base.py" in get_response 98. resolver_match = resolver.resolve(request.path_info) file "/home/thrasher/webapps/django/lib/python2.7/django/core/urlresolvers.py" in resolve 338. pattern in self.url_patterns: file "/home/thrasher/webapps/django/lib/python2.7/django/core/urlresolvers.py" in url_patterns 367. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) file "/home/thrasher/webapps/django/lib/python2.7/django/core/urlresolvers.py" in urlconf_module 361. self._urlconf_module = import_module(self.urlconf_name) file "/usr/local/lib/python2.7/importlib/__init__.py" in import_module 37. __import__(name) file "/home/thrasher/webapps/django/myproject/urls.py" in <module> 33. url(r'^admin/', include(admin.site.urls)), file "/home/thrasher/webapps/django/lib/python2.7/django/contrib/admin/sites.py" in urls 260. homecoming self.get_urls(), self.app_name, self.name file "/home/thrasher/webapps/django/lib/python2.7/django/contrib/admin/sites.py" in get_urls 221. self.check_dependencies() file "/home/thrasher/webapps/django/lib/python2.7/django/contrib/admin/sites.py" in check_dependencies 159. if not apps.is_installed('django.contrib.admin'): file "/home/thrasher/webapps/django/lib/python2.7/django/apps/registry.py" in is_installed 223. self.check_apps_ready() file "/home/thrasher/webapps/django/lib/python2.7/django/apps/registry.py" in check_apps_ready 124. raise appregistrynotready("apps aren't loaded yet.") exception type: appregistrynotready @ / exception value: apps aren't loaded yet.

for sake of completion, code related wsgi:

myprojext.wsgi

import os import sys os.environ.setdefault("django_settings_module", "myproject.settings") django.core.wsgi import get_wsgi_application application = get_wsgi_application()

wgsi.py

import django django.core.handlers.wsgi import wsgihandler def get_wsgi_application(): #django.setup() homecoming wsgihandler()

things odd me, performed lot of searches in official django docs , in various forums, i'm still unable things work properly. suggestions much appreciated.

it turned out problem duplication, in installed_apps, of django.contrib.admin. looks root of problem. removed sec reference, uncommented django.setup() in wsgi.py , things became sunny , clear again. working fine.

django wsgi

sql - Save row in %ROWTYPE and delete it efficiently afterwards? -



sql - Save row in %ROWTYPE and delete it efficiently afterwards? -

this how currently:

declare tmp message%rowtype; begin; select * tmp [...] delete message m m.id = tmp.id; end;

i'm afraid db 2 queries here: 1 doing select , 1 delete. in case true - can create more efficient somehow? after row should deleted found in select query.

n.b. i'm storing select query , homecoming function. above simplified.

delete message m using ( select * ... ) s m.id = s.id returning s.*

sql postgresql plpgsql

c++11 - std::bind no viable conversion -



c++11 - std::bind no viable conversion -

i created pathfind algorithm can set heuristic method. using a

function<int (point2i origin, point2i destiny)> heuristicfunc;

as function pointer , want initialize default heristic.

so:

pathfind.h

class pathfind{ private: function<int (point2i origin, point2i destiny)> heuristicfunc; int hmethod(point2i origin, point2i destiny); public: pathfind(); }

pathfind.cpp

pathfind::pathfind(){ //1st seek this->heuristicfunc=&pathfind::hmethod; //2nd seek this->heuristicfunc=std::bind(&pathfind::hmethod, this); }

but returns same error:

/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/include/c++/v1/functional:1472:15: candidate function not viable: no known conversion 'int (core::pathfind::*)(point2i, point2i)' 'const std::__1::function, sf::point2)>' 1st argument

why tries convert int(core::pathfind::*) ?

thanks.

using namespace std::placeholders; heuristicfunc = std::bind(&pathfind::hmethod, this, _1, _2);

every argument don't supply has indicated via placeholder.

c++11 functor

wix - Reference a heat generated wxs file from a merge module -



wix - Reference a heat generated wxs file from a merge module -

i want create trivial merge module contains files of directory called "build" , installs them programme files folder. utilize heat generate wxs file these files, , want separated wxs file edit manually merge module. how reference heat generated file other merge module wxs file?

i generate heat wxs file this:

heat dir build -cg heatcomponent -gg -var var.buildfolder -dr programfilesfolder -srd -out heatcomponent.wxs

i know how create msi file of this:

<wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <product name='product' id='9f6edf70-539a-11e4-916c-0800200c9a66' upgradecode='bb651370-539a-11e4-916c-0800200c9a66' language='1033' codepage='1252' version='1.0.0' manufacturer='test'> <package id='*' description="a product" installerversion='301' languages='1033' compressed='yes' summarycodepage='1252' platform='x64'/> <media id="1" cabinet="product.cab" embedcab="yes" /> <directory id='targetdir' name='sourcedir'> <directory id='programfilesfolder'/> </directory> <feature id="files" title="main feature" level="1"> <componentgroupref id="heatcomponent"/> </feature> </product> </wix>

but how do reference componentgroup when want output merge module? if alter product element module element complaints feature element. if remove works, not files in msm.

based on heat command posted, seek making module definition (module1.wxs) this:

<?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <module id="mod1" language="0" version="1.0.0"> <package id="your-guid" manufacturer="acme" /> <directory id="targetdir" name="sourcedir"> <directory id="programfilesfolder" /> </directory> <componentgroupref id="heatcomponent"/> </module> </wix>

then can phone call candle so:

candle module1.wxs heatcomponent.wxs -dbuildfolder="folder-containing-files-here"

followed lite so:

light module.wixobj heatcomponent.wixobj -o module1.msm

wix heat merge-module

Trouble with calling methods in c# -



Trouble with calling methods in c# -

i working on intro level c# calss , having incredibly hard time figuring out methods. book not seem clear in instances. current assignment trying create programme calculates cost of hospital stay. need have 3 different methods program. sense have methods @ to the lowest degree created correctly unsure how create programme output things methods during button click event. here have far(i have tried 1000000 different things in calcbtn_click method , firmly confused).

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 windowsformsapplication6 { public partial class form1 : form { public form1() { initializecomponent(); } private int calcstaycharges() { int lengthofstay; lengthofstay = int.parse(daystayed.text); int totalstaycharges = (350 * lengthofstay); homecoming totalstaycharges; } private double calcmisccharges() { double medcharges; medcharges = double.parse(medcharge.text); double surgcharges; surgcharges = double.parse(surgicalcharge.text); double labfees; labfees = double.parse(labfee.text); double rehabcharges; rehabcharges = double.parse(rehabcharge.text); double misccharge = (medcharges + surgcharges + labfees + rehabcharges); homecoming misccharge; } public double calctotalcharges() { double misccharges = calcmisccharges(); int staycharges = calcstaycharges(); double totalcharges = misccharges + staycharges; homecoming totalcharges; } private void calcbtn_click(object sender, eventargs e) { messagebox.show(calctotalcharges()); } } }

somewhere in code have assign value returned method variable , show/display variable. example:

int staycharcges = calcstaycharges();

let's in textbox user filled in '3'. staycharges '1050'. can show in label or display through messagebox:

resultlabel.text = string.format("charge: {0}", staycharges); //or resultlabel.tekst = staycharges.tostring() //only number //with messagebox messagebox.show(string.format("charge: {0}", staycharge);

c# methods return

Override joomla admin side error reporting via included PHP file -



Override joomla admin side error reporting via included PHP file -

i'm trying implement (quite rough indeed) debug.php file within of joomla index.php file, right @ start of file. since file calls other extension on server , in browser, i'm forced place file right @ top of file, before core joomla statement initiate application, due various conflicts.

in debug.php file there couple lines activate error reporting this:

// study php errors ini_set('display_errors', 'on'); ini_set('error_reporting', e_all);

since include statement before joomla code, when application init called, administration error study set to:none override called settings. i'd maintain error reporting on admin side set none avoid problem on live site, since debug.php file included simple check if server local environment.

how can implement functionality this? i'm using joomla 3 installation

php joomla error-handling joomla3.0

php - Refresh with POST data -



php - Refresh with POST data -

i using next php

header("refresh: 0;url=thankyou.htm");

i want add together hidden variable refresh must add together like.....

<input type=hidden name='varname' value="<?php echo $variable;?>">

how can post hidden variable refresh page?

how can these combined?

thanks

i don't know if it's secret plenty encrypt variable , send $_get:

header("refresh: 0;url=thankyou.htm?varname=".base64_encode($_post['varname']));

on thankyou.htm page have base64_decode() value back.

using session work behind scenes "most secret" @riad suggests.

php post refresh hidden-field

python - What is this object? -



python - What is this object? -

i know info object i'm new python , don't understand user_output doing. trying understand this.

def user_output(self,check): #data object output = "" #loop of info __user_arr user in self.__user_arr: if user.user_bot == str(check): output += ''' <div class='about'> <h1>{user.user_name}</h1> <h2>my favorite band is: {user.user_band} </h2> <div class='business'> <p>why want tickets:<br /> {user.user_business}</p> </div> </div> ''' homecoming output.format(**locals()) else: #this spit error if user not reply lastly question correctly. output = '''<div class='error'><h2>turns out robot. no tickets </h2></div>''' homecoming output

it generate each user div block favorite bands etc. , provided that, user flag user_bot equal check (as far can understand kind of bot check). if user bot (does not pass check) programme generate turns out robot.. block.

python python-2.7

Android Custom View Animation -



Android Custom View Animation -

hy, i'm trying animation of circle drawn on canvas. can pretty objectanimator, i'd start animation when view finishes loading or finishes drawing. if start animation in init(), animation property "ahead" of actual drawing, need start on callback when whole view set up. onmeasure() or onsizechanged() 2 called many times , if have nested layouts doesn't work properly. if utilize startdelay() works don't think accurate procedure.

here basic custom view class animation property changes radius of circle.

public class customview extends view { private static final string tag = customview.class.tostring(); public customview(final context context) { super(context); init(context); } public customview(final context context, final attributeset attrs) { super(context, attrs); init(context); } public customview(final context context, final attributeset attrs, final int defstyle) { super(context, attrs, defstyle); init(context); } private void init(final context context) { // outer circle paint mpaint = new paint(); // adds anti-aliasing drawed elements mpaint.setantialias(true); mpaint.setfilterbitmap(true); mpaint.setstrokewidth(1); mpaint.setstrokecap(paint.cap.square); mpaint.setstyle(paint.style.fill); final int animationtime = getresources().getinteger(animation_time_id); progressanimator = objectanimator.offloat(this, "animprogress", 0f, 0f); progressanimator.setduration(animationtime); log.d(tag, "init ended"); //startanimationcircle(50f); } @override public void ondraw(final canvas canvas) { super.ondraw(canvas); canvas.drawcircle(this.getwidth()/2, this.getheight()/2, animprogress, mpaint); } @override protected void onsizechanged (int w, int h, int oldw, int oldh) { //startanimationcircle(50f); } /** * onmeasure() called automatically right after phone call measure() */ @override protected void onmeasure(final int widthmeasurespec, final int heightmeasurespec) { super.onmeasure(widthmeasurespec, heightmeasurespec); //startanimationcircle(50f); } private paint mpaint; private static final int animation_time_id = android.r.integer.config_mediumanimtime; private float animprogress; private objectanimator progressanimator; public float getanimprogress() { homecoming animprogress; } public void setanimprogress(float animprogress) { this.animprogress = animprogress; this.invalidate(); } public void startanimationcircle(float size) { progressanimator.setfloatvalues(animprogress, size); //progressanimator.setstartdelay(2000); progressanimator.start(); } }

and xml also.

<com.your-package.customview android:layout_width="match_parent" android:layout_height="match_parent" />

android animation view custom-view

windows - Xamarin Build Host Not working in IOS Yosemite 10.10 -



windows - Xamarin Build Host Not working in IOS Yosemite 10.10 -

i cannot connect build host in yosemite 10.10. fine , working until updated osx mavericks yosemite. have prepare issue?

there's prepare that, please read here: http://forums.xamarin.com/discussion/26340/fixed-os-x-yosemite-the-pin-you-entered-was-invalid#latest

windows xamarin osx-yosemite

Merge Problems SQL Server -



Merge Problems SQL Server -

i'm trying create procedure take values temporary table, , load them table. sec table has composite unique constraint across 3 columns (not including primary key) i'm using merge statement seek , handle upload, , maintain getting error saying

msg 2627, level 14, state 1, line 13 violation of unique key constraint 'ix_table'. cannot insert duplicate key in object 'dbo.table'. duplicate key value (aaa, aaa, aaa).

i'm confused because whole reason using merge statement prevent happening. here's relevant portion of procedure (with names changed, , insertion temporary table changed)

create table #temptable(id int , str1 varchar(3) , str2 varchar(15) , str3 varchar(10)) insert #temptable (str1 ,str2 ,str3) values ('aaa','aaa','aaa'), ('bbb', 'bbb', 'bbb'), ('aaa','aaa','aaa') merge dbo.table t using #temptable s on (t.str1 = s.str1 , t.str2 = s.str2 , t.str3 = s.str3) when matched update set t.str1 = s.str1 when not matched insert (str1, str2, str3) values (s.str1, s.str2, s.str3); drop table #temptable

i'm confused why isn't detecting duplicates, ideas?

thanks in advance

you updating same row multiple times in same statement. understand dml set-based. rows not applied 1 after other. forcefulness inefficient execution plans , not in spirit of sql.

i'm not sure how duplicate updates defined in sql server. believe sql server defines at to the lowest degree one of duplicate updates happen. unclear 1 comes through.

here, dealing inserts. you're inserting same row twice. writes computed before write executed. that's why 2 inserts beingness "queued".

sql-server merge unique-key

c# - Hit point with projectile -



c# - Hit point with projectile -

i trying calculate right angle cannon needs @ nail target point. code below sets angle 90 degrees. using c# , unity. suggestions doing wrong?

double x = -(source.x - position.x); double y = (source.y - position.y); double v = 500; //m/s double g = physics2d.gravity.y; double sqrt = (v * v * v * v) - (g * (g * (x * x) + 2 * y * (v * v))); sqrt = math.sqrt(sqrt); double angleinradians = math.atan2(((v * v) + sqrt), (g * x)); double degrees = angleinradians * mathf.rad2deg; //this 90 vector3 angle = new vector3(0,180,(float)degrees); _cannon.transform.localeulerangles = angle;

according mathf.atan2 definition:

if y positive , x 0, θ = π/2.

x sec parameter, g * x results in 0. basic math tells can if or of operands equal 0.

so, in essence, either:

-(source.x - position.x) or physics2d.gravity.y

is equal 0. i'd guess gravity's y value culprit here.

c# unity3d trigonometry

Java serialization - how many bytes for a character? -



Java serialization - how many bytes for a character? -

i'm having string objects in java i'm serializing. i'm wondering size of each serialized character in string.

is true standard english language letters (e.g. 'a' or 'g') need 1 or 2 bytes , special symbols comma or exclamation mark need 8 bytes?

but how much bytes need number symbol (0 - 9) in serialized string?

edit: serialization in next way:

socket = new socket(host, port); objectoutputstream outputstream = new objectoutputstream(new bufferedoutputstream(socket.getoutputstream())); outputstream.writeobject(request); outputstream.flush();

the deserialization done in similar way using objectinputstream.

the object serialize (request) contains field of type string can e.g. "aaaa" or "aaaa" or "a0a3a5" etc. (i.e. uper- , lowercase letters , numbers).

you utilize java serialization complies http://docs.oracle.com/javase/6/docs/platform/serialization/spec/protocol.html.

the representation of string objects consists of length info followed contents of string encoded in modified utf-8. modified utf-8 encoding same used in javatm virtual machine , in java.io.datainput , dataoutput interfaces; differs standard utf-8 in representation of supplementary characters , of null character. form of length info depends on length of string in modified utf-8 encoding. if modified utf-8 encoding of given string less 65536 bytes in length, length written 2 bytes representing unsigned 16-bit integer. starting javatm 2 platform, standard edition, v1.3, if length of string in modified utf-8 encoding 65536 bytes or more, length written in 8 bytes representing signed 64-bit integer. typecode preceding string in serialization stream indicates format used write string.

string serialized utf-8 ascii chars encoded 1 byte , numbers ascii yes encoded 1 byte.

see http://en.wikipedia.org/wiki/utf-8 farther information.

java serialization

java - How to lookup a specific index in Array -



java - How to lookup a specific index in Array -

i have made array containing 40 fields.

system.out.println("opretter felter"); field[] felterispil = new field[40]; (int = 0; < felterispil.length; i++) { felterispil[i] = new field(".felt", i); } felterispil[0] = new field("start", 1); system.out.println(arrays.tostring(felterispil));

i want know, how can lookup name of 4.felt (index 5) up. below can see code, generating 40 fields in main class

my field.java following

class field{ private string name; private int number; public field (string fieldname, int fieldnumber) { this.name = fieldname; this.number= fieldnumber; } public string getfieldname(){ homecoming name; } public int getfieldnumber(){ homecoming number; } public string tostring(){ homecoming number+name; } public boolean equals(object obj){ field field = (field) obj; homecoming (number == field.number && name.equals(field.name)); } }

what mean lookup name , name instance field ?, utilize felterispil[4].getfieldname() retrive it?

java arraylist

asp.net mvc 4 - Types of Action Filters in MVC? -



asp.net mvc 4 - Types of Action Filters in MVC? -

in interview, interviewer asked me types of action filters. never heard or read types of action filters. know , in asp.net mvc there 4 filters i.e. authorizefilter, actionfilter, resultfilter , exceptionfilter. types of actionfilters. how many types of actionfilters exist in asp.mvc?

from : action filtering in asp.net mvc applications , understanding action filters

the asp.net mvc framework includes several action filters:

outputcache – action filter caches output of controller action specified amount of time. handleerror – action filter handles errors raised when controller action executes. authorize – action filter enables restrict access particular user or role.

asp.net-mvc-4

javascript - JavaScriptCore object getting lost -



javascript - JavaScriptCore object getting lost -

we have code in viewdidload

self.context = [self.webview valueforkeypath:@"documentview.webview.mainframe.javascriptcontext"]; self.context[@"mobile"] = [webviewjavascriptinterface class];

and our class methods webviewjavascriptinterface exposed our first web page.

when user navigates page, these methods no longer available. "mobile" object not present.

is because page changed? should placing code, or other code need set in place? want these methods/mobile object available in web frame of pages.

moved lines -(void)webviewdidfinishload:(uiwebview *)webview

javascript ios ios7 ios8

Creating a netsuite record as a particular custom form -



Creating a netsuite record as a particular custom form -

i have custom form 'customerdeposit' record. want create record fields form. best way that? have seen method create it, set customform field, save it, open again, set field values, , save again. there improve way?

var drec = nlapicreaterecord('customerdeposit'); drec.setfieldvalue('customform', 162); var tmp = nlapisubmitrecord(drec, true); var drec = nlapiloadrecord('customerdeposit', tmp); drec.setfieldvalue('fieldfromcustomform', value); nlapisubmitrecord(drec, true);

edit: after trying bit more poking, setfieldvalue vs. setfieldvalues issue coincidentally occurred @ point started setting 'custbody_xxx' fields. open/close not necessary.

you can utilize dynamic mode while creating record replicate ui way of setting fields.

nlapicreaterecord('salesorder', {recordmode: 'dynamic'});

netsuite

Php free QR code generator -



Php free QR code generator -

hi need free commercial utilize library generate qr code in php. suggestion? i've seen google api.

i have tested library , works fine : http://phpqrcode.sourceforge.net/ hope helps :)

php qr-code

android - change color of listview row -



android - change color of listview row -

let me explain in brief.

i have 2 fragments:

1) fragment user enters text. here have defined 5 buttons each of different colors. here, entered text added database.

2) fragment b has listview populates info database using customadapter when user click "save" button in fragment a.

everything working fine. info beingness saved, loaded listview , all. remember 5 buttons 5 different colors?

what want suppose while adding info in fragment a, user selected button color "orange" suppose, row inflated in getview() method of adapter should have background orange. (something ike google keep)

is possible?

my adapter class :

public class notesadapter extends baseadapter { arraylist<notessinglerow> notes; context context; view convertview; private static final string tag = "sampleadapter"; private final layoutinflater mlayoutinflater; private final random mrandom; private sparsebooleanarray mselecteditemsids; private static final sparsearray<double> spositionheightratios = new sparsearray<double>(); public notesadapter(context context, arraylist<notessinglerow> notes) { this.notes = notes; this.context = context; this.mlayoutinflater = layoutinflater.from(context); this.mrandom = new random(); } @override public int getcount() { homecoming notes.size(); } @override public object getitem(int position) { homecoming notes.get(position); } @override public long getitemid(int position) { homecoming 0; } @override public view getview(final int position, view convertview, final viewgroup parent) { this.convertview = convertview; viewholder vh; if (convertview == null) { convertview = mlayoutinflater.inflate(r.layout.notes_single_row, parent, false); vh = new viewholder(); convertview.settag(vh); } else { vh = (viewholder) convertview.gettag(); } vh.txtview = detail(convertview, r.id.notes_grid_text, notes.get(position).getnotes()); vh.notes_title = detail(convertview, r.id.note_title_added, notes.get(position).getnotestitle()); int len = vh.txtview.length(); if (len == 1 || len ==2){ vh.txtview.settextsize(100); } else if (len == 3){ vh.txtview.settextsize(80); } else if (len == 4){ vh.txtview.settextsize(60); } else if (len ==5){ vh.txtview.settextsize(50); } else if (len == 8){ vh.txtview.settextsize(60); } double positionheight = getpositionratio(position); vh.txtview.setheightratio(positionheight); vh.notes_title.setheightratio(positionheight); vh.notes_title.setpaintflags(vh.notes_title.getpaintflags()| paint.underline_text_flag); /* if ((position == 0 || position == 5 || position == 10 || position ==15)) { convertview.setbackgroundcolor(color.rgb(255, 112, 67)); } else if (position == 1 || position == 6 || position == 11 || position ==16) { convertview.setbackgroundcolor(color.rgb(29, 233, 182)); } else if (position == 2 || position == 7 || position == 12 || position ==17) { convertview.setbackgroundcolor(color.rgb(121, 134, 203)); } else if (position == 3 || position == 8 || position == 13 || position ==18) { convertview.setbackgroundcolor(color.rgb(205, 220, 57)); } else if (position == 4 || position == 9 || position == 14 || position ==19) { convertview.setbackgroundcolor(color.rgb(224, 64, 251)); }*/ homecoming convertview; } public void changecolortoorange() { convertview.setbackgroundcolor(color.rgb(255, 112, 67)); } static class viewholder { dynamicheighttextview txtview, notes_title; } private double getpositionratio(final int position) { double ratio = spositionheightratios.get(position, 0.0); if (ratio == 0) { ratio = getrandomheightratio(); spositionheightratios.append(position, ratio); log.d(tag, "getpositionratio:" + position + " ratio:" + ratio); } homecoming ratio; } private double getrandomheightratio() { homecoming (mrandom.nextdouble() / 2.4) + 0.8; } private dynamicheighttextview detail(view v, int resid, string text) { dynamicheighttextview tv = (dynamicheighttextview) v.findviewbyid(resid); tv.settext(text); homecoming tv; } public void toggleselection(int position) { selectview(position, !mselecteditemsids.get(position)); } public void selectview(int position, boolean value) { if (value) mselecteditemsids.put(position, value); else mselecteditemsids.delete(position); notifydatasetchanged(); }

user add together text in fragment buttons of different colors:

public class add_note_frag extends fragment implements view.onclicklistener { edittext note, notetitle; string user_note, user_note_title; button svenote; imageview ora, vio, yel, pin; relativelayout rel; actionbar ab; notesadapter adapter; private arraylist<notessinglerow> notes = new arraylist<notessinglerow>(); @nullable @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.add_notes_fragment, container, false); homecoming view; } @override public void onresume() { super.onresume(); ab = getactivity().getactionbar(); ab.setdisplayhomeasupenabled(true); rel = (relativelayout) getactivity().findviewbyid(r.id.notes_rel_lay); note = (edittext) getactivity().findviewbyid(r.id.note); notetitle = (edittext) getactivity().findviewbyid(r.id.note_title); svenote = (button) getactivity().findviewbyid(r.id.savenote); adapter = new notesadapter(getactivity(), notes); ora = (imageview) getactivity().findviewbyid(r.id.orange); vio = (imageview) getactivity().findviewbyid(r.id.violet); yel = (imageview) getactivity().findviewbyid(r.id.yellow); pin = (imageview) getactivity().findviewbyid(r.id.pink); ora.setonclicklistener(this); vio.setonclicklistener(this); yel.setonclicklistener(this); pin.setonclicklistener(this); svenote.setonclicklistener(this); } public void savenote() { tasks_database_operations tasksdatabaseoperations = new tasks_database_operations(getactivity()); user_note = note.gettext().tostring(); user_note_title = notetitle.gettext().tostring(); long id1 = tasksdatabaseoperations.insertnote(user_note, user_note_title); if (id1 < 0) { log.e("hirakdebug", "add_task_frag failed insertdata operation"); } else { log.d("hirakdebug", "data sent inserted"); } } @override public void onclick(view v) { if (v == svenote) { savenote(); gobacktonotefrag(); ab.setbackgrounddrawable(new colordrawable(getresources().getcolor(r.color.actionbar))); } if (v == ora) { rel.setbackgroundcolor(getresources().getcolor(r.color.orange)); ab.setbackgrounddrawable(new colordrawable(getresources().getcolor(r.color.orange))); adapter.changecolortoorange(); } if (v == vio) { rel.setbackgroundcolor(getresources().getcolor(r.color.violet)); ab.setbackgrounddrawable(new colordrawable(getresources().getcolor(r.color.violet))); } if (v == yel) { rel.setbackgroundcolor(getresources().getcolor(r.color.yellow)); ab.setbackgrounddrawable(new colordrawable(getresources().getcolor(r.color.yellow))); } if (v == pin) { rel.setbackgroundcolor(getresources().getcolor(r.color.pinkk)); ab.setbackgrounddrawable(new colordrawable(getresources().getcolor(r.color.pinkk))); } } public void gobacktonotefrag() { noteslistfrag nlf = new noteslistfrag(); fragmentmanager fm = getfragmentmanager(); fragmenttransaction ft = fm.begintransaction(); ft.setcustomanimations(r.anim.slide_up, r.anim.slide_down); ft.remove(this); ft.replace(r.id.dynamic_content, nlf, "nlf"); ft.commit(); } @override public void ondetach() { super.ondetach(); ab.setbackgrounddrawable(new colordrawable(getresources().getcolor(r.color.actionbar))); }

it possible.

pass selected color fragment b on button click. pass color argument adapter constructor fragment b. now know color within adapter. in getview() function of adapter, based on color, alter background color of inflated view. using : view.setbackgroundcolor(color);

see sample here : https://github.com/vishalvijay/samplecolorlistview

android listview

c# - Content-Type - WebAPI - Request Header -



c# - Content-Type - WebAPI - Request Header -

is possible webapi controller homecoming json, if header "content-type" not present?

in default setup, when header not present, exception "no mediatypeformatter available read object of type ..." raising.

add webapiconfig.cs

config.formatters.jsonformatter.supportedmediatypes.add(new mediatypeheadervalue("text/html") );

now json result unless when send text/xml "content-type"

c# asp.net .net json asp.net-web-api

winforms - Avoid radcombobox suggest list from being collapsed -



winforms - Avoid radcombobox suggest list from being collapsed -

i have raddropdownlist in suggestappend mode , usercontrol keyboard, have buttons controlstyles.selectable = false. mouseup event fires sendkeys.send(key). thing when focus in raddropdownlist , write keyboard (usercontrol) suggest list appears milisecond , desappear. tried command popup event seems have nil suggest list. how can maintain opened showing suggestions until user leaves raddropdownlist?

here how access auto finish suggest popup , cancel closure of popup:

raddropdownlist1.dropdownlistelement.autocompletesuggest.dropdownlist.popupclosing += dropdownlist_popupclosing; . . . void dropdownlist_popupclosing(object sender, telerik.wincontrols.ui.radpopupclosingeventargs args) { args.cancel = true; }

winforms user-controls telerik

python - MySQL not updating after calling connection.commit() with Flask (WORKING) -



python - MySQL not updating after calling connection.commit() with Flask (WORKING) -

i'm using flask build simple web app whatever reason conn.commit() not committing info database. know because when manually add together database info doesn't alter id section increases each time test (because using auto increment). current table has id 1, username test, password test , next entry inserted manually (after trying utilize application) id 5, username blah, password blah. there specific reason commit isn't working?

edit: had alter cursor = mysql.connect().cursor() conn.cursor()

@app.route('/add_data/') def add_tv_to_database(): conn = mysql.connect() cursor = mysql.connect().cursor() cursor.execute("insert _accounts values (null, 'test','test')") conn.commit() homecoming render_template('index.html')

in 4th line of code, alter cursor = mysql.connect().cursor() cursor = conn.cursor(). ensure cursor uses existing connection database (from previous line of code), instead of creating new mysql connection.

python html mysql flask

class - Convert string into a Tkinter notebook frame -



class - Convert string into a Tkinter notebook frame -

ok trying find frame tkinter using, take width , height , resize window fits nicely without ugly spaces left. far have gotten following...

convert = {"tab1_name", "tab1"; "tab2_name", "tab2"; "tab3_name", "tab3") ##(it goes on) = mainframe.tab(mainframe.select(), "text") b = convert[a] w = b.winfo_reqwidth() h = b.winfo_reqheight() mainframe.configure(width=w, height=h)

the names of each frame in notebook tab1, tab2, tab3, etc., labels on them unique because describe happens in tab. want able take string returned convert dictionary function , utilize frame's name. not sure if frame class or else. there way convert string b frame's name , somehow utilize in .winfo_reqheight()? not want have create thing says...

if b=="tab1": w = tab1.winfo_reqwidth() h = tab1.winfo_reqheight() mainframe.configure(width=w, height=h)

for each frame because want easy add together new frames without having add together much code.

thank you

option 1:

you can store actual objects in dictionaries. try:

convert = {"tab1_name": tab1, "tab2_name": tab2, "tab3_name": tab3} = mainframe.tab(mainframe.select(), "text") b = convert[a] w = b.winfo_reqwidth() h = b.winfo_reqheight() mainframe.configure(width=w, height=h)

option 2: executing strings possible 'exec('arbitrary code in string')' function

see how execute string containing python code in python?.

you this: (with text in dictionary or whatever convert is)

convert = {"tab1_name": "tab1", "tab2_name": "tab2", "tab3_name": "tab3"} = mainframe.tab(mainframe.select(), "text") b = convert[a] code1 = "w = %s.winfo_reqwidth()" % b code2 = "h = %s.winfo_reqheight()" % b exec(code1) # python 2 is: exec code1 exec(code2) # python 3 changed exec statement function mainframe.configure(width=w, height=h)

be careful don't allow malicious code exec statement, because python run it. problem if end user can input things function(it sounds don't have worry this).

btw, think first line incorrect. open { close ). proper dictionary syntax be:

convert = {"tab1_name": "tab1", "tab2_name": "tab2", "tab3_name": "tab3"}

notice colons separating key , value, , commas in-between entries.

string class python-3.x tkinter frames

svg - How can I vertically align the 'main' tree branch? -



svg - How can I vertically align the 'main' tree branch? -

i trying utilize d3 tree layout display construction 'main' branch , few smaller branches. nodes in main branch vertically align each other, either on hard left or central column. how can this?

i utilize number of descendants identify main branch , have far tried sorting gives following:

sorting descending sorting median = max value

i've tried manually calculating x coordinates end overlapping nodes:

my code pretty much identical illustration code generating tree graphs other clutter. if illustration code needed i'll provide don't think help.

svg d3.js tree

mysql - SQL error in this query -



mysql - SQL error in this query -

im trying create register cms system. whenever seek create it, gives me error

the next info meant website developer debugging purposes. error occurred while processing request error executing database query. have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '', '0', '500000', '500000', ''2012-11-02 22:12:11'', '20', '1', 'hr-165-45.hd-20' @ line 2

the sql query this:

<cfquery name="insertmale" datasource = "#dsn#"> insert users (id, username, real_name, password, auth_ticket, rank, vip_points, credits, activity_points, activity_points_lastupdate, seasonal_currency, loyalty_points, look, gender, motto, mail, account_created, last_online, online, ip_last, ip_reg, home_room, newbie_status, is_muted, mutant_penalty, mutant_penalty_expire, trade_lock, trade_lock_expire, block_newfriends, hide_online, hide_inroom, vip, vip_expire, birth, talent_status, mysterybox_key_colour, last_name_change, client_volume, nux_passed, seckey, voted, vandeweek, home_txt, donateur, stemmen, waarschuwing) values('#countusers.recordcount+1#', '#form.username#', 'donny', '#password#', 'grandcms-', 1', '0', '500000', '500000', '#dateadd("s", 1351894331, createdatetime(1970, 1, 1, 0, 0, 0))#', '20', '1', 'hr-165-45.hd-208-2.ch-250-64.lg-285-82.sh-290-64', 'm', 'nieuw op grandhotel!', '#form.mail#', '#dateadd("s", 1351894331, createdatetime(1970, 1, 1, 0, 0, 0))#', '#dateadd("s", 1351894331, createdatetime(1970, 1, 1, 0, 0, 0))#', '0', '#cgi.remote_addr#', '#cgi.remote_addr#', '0', '0', '0', '0', '#dateadd("s", 1351894331, createdatetime(1970, 1, 1, 0, 0, 0))#', '0', '#dateadd("s", 1351894331, createdatetime(1970, 1, 1, 0, 0, 0))#', '0', '0', '0', '0', '#dateadd("s", 1351894331, createdatetime(1970, 1, 1, 0, 0, 0))#', '24-12-1995', '0', '0', '#dateadd("s", 1351894331, createdatetime(1970, 1, 1, 0, 0, 0))#', '100', '0', '0', '1', '0', 'geenhometxt', '0', '0', '0'); </cfquery>

i counted column's, it's same isn't problem. know's doing wrong?

sorry bad bad english. i'm netherlands!

change 1', there missing!

mysql sql coldfusion

html - Clearing the layout cache in a Rails application -



html - Clearing the layout cache in a Rails application -

my application.html.slim template looks conceptually:

/ stuff = header() / more stuff = yield / more stuff = footer()

now header() , footer() loaded external source , language-specific.

i have introduced language-change mechanism (based on url) header , footer loaded different source language changed.

my problem:

i start server i load http://myserver.dev/en the content header shown in english language --> ok i load http://myserver.dev/de now header still in english language while content in high german --> not ok now header , footer won't alter until restart server again.

so how can clear layout cache, footer , header re-loaded.

i tried next (to no avail):

manually removing cache files disk (they still seem in memory)

adding next setting in application.rb

config.action_view.cache_template_loading = false config.action_controller.perform_caching = false invoking rails.cache.clear in every request attempting expire individual partial: expire_fragment('external/_header.html.slim') or expire_fragment(%r{external})

i avoided situation using fragment cache , creating block cache each language.

in views define block alter language with:

<% cache("block_1_#{i18n.locale}") %> ... <% end %>

html ruby-on-rails caching ruby-on-rails-3.2

php - unexpected T_STRING on first line of code -



php - unexpected T_STRING on first line of code -

i have been getting error saying unexpected t_string on line 2 of script:

<? php session_start(); $incidentkey = $_session['incidentkey']; $incidentdetailsquery = mysql_query("select * incidents incidentkey='".$incidentkey."'"); while ($incidentdetails = mysql_fetch_assoc($incidentdetailsquery); ?>

and despite looking through forum heaps, have had no luck. coming error saying unexpected t_string on line 2 when code started this:

<? php $incidentkey = $_session['incidentkey']; etc.....

i've gone through other includes , couldn't find missing terminators leading script. can think why else getting error?

remove space in

<? php

to create

<?php

php

mex - matlab coder: cannot transpose a matrix that is incorrectly deemed to be 3-D when it should always be 2-D -



mex - matlab coder: cannot transpose a matrix that is incorrectly deemed to be 3-D when it should always be 2-D -

i have function (with code given below) wish convert mex file. trying utilize matlab coder so.

%% inputs dof = 3; num_divs = 72; ind_cr = 0 0 1 1 1 2 2 2 1 3 2 3 3 3 ind_switch = 1 1 1 0 1 0 0 len_stat_atoms = 1 72 5184 72 373248 5184 72 num_stat_atoms = 108 111 111 3 111 3 3 coordfile = [3x1 double] [3x1 double] [3x72x3 double] [3x5184x3 double] [3x373248x4 double] radii_cell = [108x1x3 double] [111x72x3 double] [111x5184x3 double] [ 3x72x3 double] [111x373248x4 double] [ 3x5184x4 double] [ 3x72x4 double] stat_cell = [3x1x108 double] [3x72x111 double] [3x5184x111 double] [3x72x3 double] [3x373248x111 double] [3x5184x3 double] [3x72x3 double] %% code calls function = 1:(dof*(dof+1)/2+1) %% load matrices radii_mat = radii_cell{i,1}; stat_mat = stat_cell{i,1}; if ind_switch(i) coordfile_mat = coordfile{ind_cr(i,2)+2}; end %% phone call function potential_mat = func_test(i,coordfile_mat,radii_mat,stat_mat,... ind_cr,len_stat_atoms,num_stat_atoms,num_coord_atoms,... counter,num_divs,dof); end %% function code function potential_mat = func_test(i,coordfile_mat,radii_mat,stat_mat,... ind_cr,len_stat_atoms,num_stat_atoms,num_coord_atoms,... counter,num_divs,dof); potential_mat = zeros(num_coord_atoms,num_divs^dof); j = 1:size(coordfile_mat,3) %% compute distances = zeros(3,len_stat_atoms(i)); = coordfile_mat(:,1:len_stat_atoms(i),j); b = zeros(3,len_stat_atoms(i),num_stat_atoms(i)); b = repmat(a,[1 1 num_stat_atoms(i)]); c = zeros(1,len_stat_atoms(i),num_stat_atoms(i)); c = sqrt(sum((b - stat_mat).^2,1)); d = zeros(len_stat_atoms(i),num_stat_atoms(i)); d = shiftdim(c,1); distances = zeros(num_stat_atoms(i),len_stat_atoms(i)); distances = d'; %% compute clashes , potentials clashes = distances < radii_mat(:,:,j); potentials = zeros(size(distances)); potentials(clashes) = (1-(distances(clashes)./radii_mat(find(clashes)+numel(clashes)*(j-1))).^6).^2; %% iterate on nodes col = ind_cr(i,1); row = ind_cr(i,2); if col == 1 ind_kron = repmat(1:size(potentials,2),[num_divs^(dof-row) 1]); potentials = potentials(:,ind_kron(:)'); elseif row == dof vec_repmat = [1 num_divs^(col-1)]; potentials = repmat(potentials,vec_repmat); elseif col > 0 vec_repmat = [1 num_divs^(col-1)]; ind_kron = repmat(1:size(potentials,2),[num_divs^(dof-row) 1]); potentials = repmat(potentials(:,ind_kron(:)'),vec_repmat); else potentials = repmat(sum(potentials),[1 num_divs^dof]); end counter = counter+1; potential_mat(counter,:) = sum(potentials,1); end end

the problem occurs @ sec line below, throws error because cannot transpose nd matrix.

d = shiftdim(c,1); distances = d';

matlab coder identifies c of size 1 x :? x :?, correct. d = shiftdim(c,1) line should yield 2d matrix of size :? x :?, transpose. however, fails correctly shift dimensions of d, , gives size of :? x :? x :?. causes transpose error. how can resolve problem? furthermore, own edification, why matlab coder unable correctly assign dimensions of variables, a, b, c, d, , distances?

the docs describe incompatibility matlab in determining size of variable-size n-d arrays (d created in loop, seems variable size):

for variable-size n-d arrays, size function can homecoming different result in generated code in matlab. in generated code, size(a) returns fixed-length output because it not drop trailing singleton dimensions of variable-size n-d arrays. contrast, size(a) in matlab returns variable-length output because drops trailing singleton dimensions.

for example, if shape of array a :?x:?x:? , size(a,3)==1, size(a) returns:

three-element vector in generated code two-element vector in matlab code

the issue addressed in above documentation pertains utilize of size function. however, in case, want able transpose. workaround utilize permute, since transpose general case of permute:

% after shiftdim: distances = permute(d,[2 1 3]) % same d' 2d array, handles 3d

you cutting out shiftdim entirely:

distances = permute(c,[2 3 1])

also, don't have much experience coder, require initializations zeros? seem unnecessary.

mex matlab-coder

javascript - Meteor Select Box - mark option as selected depending on data context -



javascript - Meteor Select Box - mark option as selected depending on data context -

i have been trying figure out how set 'selected' attribute on alternative within select box , have fallen short today. help appreciated.

what i'm trying accomplish: when user chooses alternative , hits submit, info saves new mongo document , new entry shown on screen (this part works). upon browser refresh, state lost (due no selected attribute beingness set) , select box goes first option. need figure out how set selected state depending on value user has saved on particular document. on page there many of same select boxes allowing user take different options other entries.

references (tried implement no luck):

check equality in spacebars?

https://github.com/meteor/meteor/wiki/using-blaze#conditional-attributes-with-no-value-eg-checked-selected

meteor.js - how can indicate 'checked' or 'selected' in templating scheme when using checkboxes , select options?

select box template:

<template name="tedit"> <div class="form-group"> <div class="controls"> {{> ffedit}} </div> </div> </template>

select box alternative template:

<template name="ffedit"> <select class="form-control" name="ffselect"> {{#each ffselect}} <option value="{{fid}}">{{ff}}</option> {{/each}} </select> </template>

setting info context

template.ffedit.helpers({ ffselect: function() { var ffarray = [ { ff: "foo", fid: 0 }, { ff: "bar", fid: 1 }, { ff: "buzz", fid: 2 } ]; homecoming ffarray; } });

if want state persisted across browser refreshes, should able either fetch server or meteor session.

the sec thing you'd need helper selected state. conveniently, meteor makes info context available under this (for each loop, context individual item).

template.useredit.helpers({ userselected: function() { if(this.id === session.get("selecteduserid")) { homecoming "selected"; } } });

this assumes you've set session variable session.set("selecteduserid", user._id).

then in template:

<template name="useredit"> <select class="form-control" name="userselect"> {{#each users}} <option {{userselected}}>{{username}}</option> {{/each}} </select> </template>

(note: selected state can not seen inspecting dom element inspector.)

javascript mongodb meteor meteor-blaze spacebars

eclipse - No mapping found for HTTP request with URI 3 (resolved) -



eclipse - No mapping found for HTTP request with URI 3 (resolved) -

i have read many posts on issue without beingness able find solution problem. true started in java ee / maven / spring.

the error encounter like: "no mapping found http request uri" displayed in eclipse console when uri :

http://localhost:8080/collecte-cloudvoice/bonjour

i tried follow tutorial: http://rpouiller.developpez.com/tutoriels/spring/application-web-spring-hibernate/

here different parts of code:

porn.xml:

<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/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>fr.conviviance.tools</groupid> <artifactid>collecte-cloudvoice</artifactid> <packaging>war</packaging> <version>0.0.1-snapshot</version> <name>collecte-cloudvoice maven webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupid>javax.servlet</groupid> <artifactid>servlet-api</artifactid> <version>2.5</version> <scope>compile</scope> </dependency> <dependency> <groupid>org.springframework</groupid> <artifactid>spring-webmvc</artifactid> <version>4.0.2.release</version> </dependency> </dependencies> <build> <finalname>collecte-cloudvoice</finalname> </build> </project>

web.xml:

<!doctype web-app public "-//sun microsystems, inc.//dtd web application 2.3//en" "http://java.sun.com/dtd/web-app_2_4.dtd" > <web-app> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/dispatcher-servlet.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- declaration de la servlet de spring et de boy mapping --> <servlet> <servlet-name>servlet-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/dispatcher-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>servlet-dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>

dispatcher-servlet.xml:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <bean id="messagesource" class="org.springframework.context.support.reloadableresourcebundlemessagesource"> <property name="basename" value="classpath:messages" /> <property name="defaultencoding" value="iso-8859-1" /> </bean> <context:component-scan base-package="fr.conviviance.tools" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/vues/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> </beans>

bonjour.jsp:

<%@ page language="java" contenttype="text/html; charset=iso-8859-1" iselignored="false" pageencoding="iso-8859-1"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <title><spring:message code="titre.bonjour"/> : ${personne}</title> </head> <body> <spring:message code="libelle.bonjour.lemonde" arguments="${personne}"/> </body> </html>

bonjourcontroler.java:

package fr.conviviance.tools; import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; @controller @requestmapping("/bonjour") public class bonjourcontroller { @requestmapping(method = requestmethod.get) public string afficherbonjour(final modelmap pmodel) { pmodel.addattribute("personne", "regis"); homecoming "bonjour"; } }

le projet:

http://i59.servimg.com/u/f59/17/36/38/59/projet10.jpg

if start server in debug, can see next on console:

nov. 12, 2014 2:26:48 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions infos: loading xml bean definitions servletcontext resource [/web-inf/dispatcher-servlet.xml] nov. 12, 2014 2:26:48 pm org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping registerhandler infos: mapped url path [/bonjour] onto handler 'bonjourcontroller' nov. 12, 2014 2:26:48 pm org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping registerhandler infos: mapped url path [/bonjour.*] onto handler 'bonjourcontroller' nov. 12, 2014 2:26:48 pm org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping registerhandler infos: mapped url path [/bonjour/] onto handler 'bonjourcontroller' nov. 12, 2014 2:26:48 pm org.springframework.web.servlet.dispatcherservlet initservletbean infos: frameworkservlet 'servlet-dispatcher': initialization completed in 320 ms

eclipse spring maven java-ee dispatcher

PHP Open FTP XML Feed and Save On Another Server -



PHP Open FTP XML Feed and Save On Another Server -

i kindly know if has simple php script can run cron open xml file url have (on different server) , re-save in directory on own server.

the url ftp url username , password.

easy:

file_put_contents(file_get_contents('ftp://user:password@remoteserver.com/file.xml'), '/path/to/new.xml');

php xml cron

java - OS Workflow Replacement -



java - OS Workflow Replacement -

we have java application uses open-symphony workflow, re-designing application , trying replace os workflow new open-source workflow engines, since os wf has reached final stages. best possible replacement of os workflow ?

workflow should facilitate current steps, persist history steps, actions, pre , post conditions each step.

i looked jbpm , activiti workflows, looked pretty heavy application come more features.

any thoughts much appreciated.

my first contribution jbpm (early drools flow) project back upwards osworkflow features. jbpm ultra flexible , can create simple semantic on top of , utilize core engine serve needs.

java workflow jbpm activiti opensymphony

Worklight Analytics and WAS Plugin -



Worklight Analytics and WAS Plugin -

can worklight analytics server loadbalanced using ihs server?

https://www-01.ibm.com/support/knowledgecenter/sszh4a_6.2.0/com.ibm.worklight.installconfig.doc/monitor/t_installing_op_analytics_liberty.html?lang=en

for example, if liberty server @ host.ibm.com on port 8080 , context root analytics, wl.analytics.url property follows:

wl.analytics.url=http://host.ibm.com:8080/analytics/data

could host here ihs server plugin configured balance requests across multiple analytics nodes?

yes, shouldn't necessary.

worklight analytics uses elasticsearch under covers. when anayltics request comes in worklight, info sent elasticsearch automatically route analytics info right node long nodes have been setup correctly.

i suggest reading more how elasticsearch clustering works see if necessary add together additional load balancer.

worklight analytics load-balancing

how to get notification when someone posts a tweet using twitter api and php -



how to get notification when someone posts a tweet using twitter api and php -

i want save notification specific user in friend list in mysql database using php , twitter api

twitter has 2 main apis. http rest , stream api 2 ways think php suitable http api since php not multithreaded.

with php , curl extension periodically poll http twitter api changes on user following.

i utilize stream api has java client implemented twitter staff works charm , receives updates in rt. farther details:

rest api: https://dev.twitter.com/rest/public

streaming api https://dev.twitter.com/streaming/overview

hosebird (streaming client twitter) https://github.com/twitter/hbc

hope helps

php twitter

fine uploader - Upload button appears when not called- but i have 2 instances -



fine uploader - Upload button appears when not called- but i have 2 instances -

i have created 2 instances of s3 uploader in page , have given them different div names. 1 of instances set auto upload , other set manual upload edit file names set.

however instance auto upload pulling upload button other instance well. sits there , nil because upload works intended- automatically. other rogue button both forms work want.

this div button have in 1 instance

class="lang-html prettyprint-override"><div id="triggerupload-feeds" class="qq-upload-button start-upload" style="margin-top: 10px;cursor:pointer;">upload</div>

fine uploader ui looks template in document id of "qq-template". therefore, both uploaders beingness constructed same template. if want multiple uploaders on same page pull different templates, you'll need ensure define multiple templates in markup, each different id. you'll need reference appropriate template when build each fine uploader ui instance.

for example:

class="lang-html prettyprint-override"><script type="text/template" id="qq-template1"> <!-- template markup here --> </script> class="lang-html prettyprint-override"><script type="text/template" id="qq-template2"> <!-- template markup here --> </script> class="lang-js prettyprint-override"><script> var uploader1 = new qq.fineuploader({ template: 'qq-template1' }); var uploader2 = new qq.fineuploader({ template: 'qq-template2' }); </script>

for more info, see templating/styling feature page in docs.

fine-uploader

Eclipse plugin deployment: couldn't find a bundle file -



Eclipse plugin deployment: couldn't find a bundle file -

i developing eclipse plugin, in eclipse kepler platform develop plugin, add together file: bundle org.eclipse.jface.databinding 1.6.200 1 of dependencies. when tried install plugin in eclipse juno in machine, failed. , error message is: ...bundle org.eclipse.jface.databinding 1.6.200' not found.

could tell me how solve problem?

when developing eclipse plugins have think dependencies. osgi (on eclipse built) has ability, unlike normal java jar dependencies) specify versions and/or version ranges dependencies. need think version range want back upwards when developing plugins.

in case, version 1.6.200 of org.eclipse.jface.databinding in latest releases of eclipse (luna , kepler), juno has older version (1.6.0). if want plugin compatible juno need specify version range in dependency on org.eclipse.jface.databinding. @ how many of eclipse plugins declare own depdencies examples.

you should read more educate (this isn't trivial stuff normal java projects adding jars no version information). here useful links:

https://wiki.eclipse.org/index.php/version_numbering plug-in development should done target platform. see here. this question , answer has interesting points, difference between importing packages , depending on bundles.

there lot understand stuff; it's not wise take naive approach, sadly tutorials gloss on or totally ignore these aspects of dependency management.

eclipse plugins deployment

php - http:// wrapper is disabled in the server? -



php - http:// wrapper is disabled in the server? -

the error message:

warning: include(): http:// wrapper disabled in server configuration allow_url_include=0 in c:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27 warning: include(http://localhost/ubergallery/multiple_image_upload/upload.php): failed open stream: no suitable wrapper found in c:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27 warning: include(): failed opening 'http://localhost/ubergallery/multiple_image_upload/upload.php' inclusion (include_path='.;c:\xampp\php\pear') in c:\xampp\htdocs\ubergallery\multiple_image_upload\multiupload.php on line 27

i getting error message.

including stylesheet or jquery file absolute path work out, looking include php script absolute path.

here code:

<!doctype html> <html> <head> <title>upload multiple images using jquery , php</title> <!-------including jquery google------> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="script.js"></script> <!-------including css file------> <link rel="stylesheet" type="text/css" href="style.css"> <body> <div id="maindiv"> <div id="formdiv"> <h2>multiple image upload form</h2> <form enctype="multipart/form-data" action="" method="post"> first field compulsory. jpeg,png,jpg type image uploaded. image size should less 100kb. <hr/> <div id="filediv"><input name="file[]" type="file" id="file"/></div><br/> <input type="button" id="add_more" class="upload" value="add more files"/> <input type="submit" value="upload file" name="submit" id="upload" class="upload"/> </form> <br/> <br/> <!-------including php script here------> <?php include("http://localhost/ubergallery/multiple_image_upload/upload.php"); ?> </div> <!-- right side div --> <div id="formget"><a href=http://www.formget.com/app><img src="formget.jpg" alt="online form builder"/></a> </div> </div> </body> </html>

i looking include "upload.php" absolute path.

when turn "allow_url_include" "on" still same error message. not sure if issue begin with.

any suggestions here?

from php docs on include:

if "url include wrappers" enabled in php, can specify file included using url (via http or other supported wrapper - see supported protocols , wrappers list of protocols) instead of local pathname. if target server interprets target file php code, variables may passed included file using url request string used http get. not strictly speaking same thing including file , having inherit parent file's variable scope; script beingness run on remote server , result beingness included local script.

by obvious inference, supposed utilize local pathname!

change line

<?php include("http://localhost/ubergallery/multiple_image_upload/upload.php"); ?>

to this

<?php include($_server['document_root']."/ubergallery/multiple_image_upload/upload.php"); ?>

the reason allow_url_include=on doesn't work because didn't restart apache server after changing php.ini

php apache

pointers - Segmentation fault core dumped in C while trying to create memory for a Struct -



pointers - Segmentation fault core dumped in C while trying to create memory for a Struct -

i'm getting segmentation fault when trying run next code:

c file

#include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> #include "mydata.h" struct structpointer *sp; struct structpointer *ssp; int recordnumber = 0; int numberofaccesses = 0; int main(void) { sp = (struct structpointer *) malloc(5 * sizeof(struct structpointer)); ssp = sp; memcpy(sp->name,"adam baum",50); memcpy(sp->firenumber,"n1234",10); memcpy(sp->street,"top secret",25); memcpy(sp->city,"manhattan",25); memcpy(sp->state,"new york",25); sp++; recordnumber++; memcpy(sp->name,"adam zapel",50); memcpy(sp->firenumber,"s4321",10); memcpy(sp->street,"throat",25); memcpy(sp->city,"manhattan",25); memcpy(sp->state,"new york",25); sp++; recordnumber++; memcpy(sp->name,"al bino",50); memcpy(sp->firenumber,"w1234",10); memcpy(sp->street,"white",25); memcpy(sp->city,"anchorage",25); memcpy(sp->state,"alaska",25); sp++; recordnumber++; memcpy(sp->name,"anne teak",50); memcpy(sp->firenumber,"e4321",10); memcpy(sp->street,"oak",25); memcpy(sp->city,"woodville",25); memcpy(sp->state,"wisconsin",25); sp++; recordnumber++; memcpy(sp->name,"barb dwyer",50); memcpy(sp->firenumber,"n1234",10); memcpy(sp->street,"keepout",25); memcpy(sp->city,"kilgore",25); memcpy(sp->state,"texas",25); recordnumber++; while (1){ int sel; printf("menu\n"); printf("=====\n"); printf("1. print records\n"); printf("2. print number of records\n"); printf("3. print size of database\n"); printf("4. add together record\n"); printf("5. delete record\n"); printf("6. print number of accesses database\n"); printf("7. exit\n"); printf("=====\n"); printf("enter selection: "); sel = getchar(); sel = sel-48; switch(sel){ case 1: numberofaccesses++; printallrecords(sp); break; case 2: numberofaccesses++; fprintf(stderr,"there total of %d records\n", recordnumber); break; case 3: numberofaccesses++; printsizeofdatabase(sp); break; case 4: numberofaccesses++; sp = ssp; addrecord(sp); break; case 5: numberofaccesses++; deleterecord(sp); break; case 6: numberofaccesses++; fprintf(stderr,"the total number of accesses %d\n", numberofaccesses); break; case 7: exit(0); case -38: printf("code reading in linefeed , displaying menu again\n"); break; default: printf("error: input not valid selection.\n"); break; } } homecoming 0; } int printallrecords(struct structpointer *addresses){ int i; printf("all records: "); for(i=1;i<recordnumber;i++){ printf("address: %d\n", i); fprintf(stderr, "name = \%s\n", addresses-> name); fprintf(stderr, "fire number = \%s\n", addresses-> firenumber); fprintf(stderr, "street = \%s\n", addresses-> street); fprintf(stderr, "city = \%s\n\n", addresses-> city); fprintf(stderr, "state = \%s\n\n", addresses-> state); } homecoming 1; } int printsizeofdatabase(struct structpointer *addressesagain) { int size = 0; int i; (i=1;i<=recordnumber;i++) { size += sizeof(addressesagain->name); size += sizeof(addressesagain->firenumber); size += sizeof(addressesagain->street); size += sizeof(addressesagain->city); size += sizeof(addressesagain->state); addressesagain++; } fprintf(stderr, "the size of database %d bytes.\n", size); homecoming size; } int addrecord(struct structpointer *addressesagaintimes2){ char entryname; char entryfirenumber; char entrystreet; char entrycity; char entrystate; recordnumber++; struct structpointer *thestruct; thestruct = (struct structpointer *) malloc ((recordnumber+1) * sizeof(struct structpointer)); addressesagaintimes2 = ssp; int i; (i=1;i<recordnumber;i++){ memcpy(thestruct->name,addressesagaintimes2->name,50); memcpy(thestruct->firenumber,addressesagaintimes2->firenumber,10); memcpy(thestruct->street,addressesagaintimes2->street,25); memcpy(thestruct->city,addressesagaintimes2->city,25); memcpy(thestruct->state,addressesagaintimes2->state,25); if(i==recordnumber-1){ thestruct++;} else{ thestruct++; addressesagaintimes2++;} } printf("enter name of new record: \n"); scanf("%s",&entryname); memcpy(thestruct->name,&entryname,50); printf("enter fire number of new record: \n"); scanf("%s",&entryfirenumber); memcpy(thestruct->firenumber,&entryfirenumber,10); printf("enter street of new record: \n"); scanf("%s",&entrystreet); memcpy(thestruct->street,&entrystreet,25); printf("enter city of new record: \n"); scanf("%s",&entrycity); memcpy(thestruct->city,&entrycity,25); printf("enter state of new record: \n"); scanf("%s",&entrystate); memcpy(thestruct->state,&entrystate,25); addressesagaintimes2=thestruct; printf("record has been added."); homecoming 0; } int deleterecord(struct structpointer *addressesagaintimes3){ struct structpointer *anotherstruct; anotherstruct = (struct structpointer *) malloc ((recordnumber+1) * sizeof(struct structpointer)); int i; for(i=0;i<5;i++){ memcpy(anotherstruct->name,addressesagaintimes3->name,50); memcpy(anotherstruct->firenumber,addressesagaintimes3->firenumber,10); memcpy(anotherstruct->street,addressesagaintimes3->street,25); memcpy(anotherstruct->city,addressesagaintimes3->city,25); memcpy(anotherstruct->state,addressesagaintimes3->state,25); addressesagaintimes3++; } addressesagaintimes3=anotherstruct; recordnumber--; printf("record has been deleted."); homecoming 0; }

header file:

#include <stdio.h> #include <stdlib.h> struct structpointer{ char *name; char *firenumber; char *street; char *city; char *state; };

this programme supposed create chunk of memory can store struct , display menu can add/remove entries struct.

your structpointer fellow member fields pointers strings, never allocated memory. utilize memcpy() in effect copying undefined memory.

changing construction follows resolve specific issue:

struct structpointer{ char name[some_appropriate_name_length]; char firenumber[some_appropriate_number_length]; char street[some_appropriate_street_length]; char city[some_appropriate_city_length]; char state[2]; };

c pointers struct segmentation-fault coredump

php - mod_rewrite with subdirectory -



php - mod_rewrite with subdirectory -

i have page called category.php , within of have links articles , others categories.

to open article within of category, code is:

<a href='article/". $art_id ."'> article 1 </a>

to open other category within of category, code is:

<a href='category/". $cat_id ."'> category 2 </a>

i have code on .htaccess:

rewriteengine on rewriterule ^category/([a-z0-9]+)$ category.php?id=$1 rewriterule ^article/([a-z0-9]+)$ article.php?id=$1

category 1 open fine, when click in link within of category page open article or other category, link turns:

http://www.example.com/category/article/1 http://www.example.com/category/category/2

both urls results on page not found, best have organized?

something like:

http://www.example.com/category/1/article/1

you can add together relative uri base of operations header of pages:

<base href="/" />

php apache .htaccess mod-rewrite

angularjs - How do I maintain scope when delegating to service? -



angularjs - How do I maintain scope when delegating to service? -

i've built little service handle errormessages in application. publicly available on rootscope , able add together new messages page needed. need have clickable links in messages have arisen.

questions:

how dynamically add together javascript handled angular messages created? i've added onclicks work, ng-click seem not handled. the js run in controller created message in first place. how create sure end in right scope when clicking link in error message? if function adding message service, how solve that?

and service i'm playing around with: var myapp = angular.module('myapp', []);

function errorhandlingfactory() { this.messages = []; this.addmessage = function (messagetext, type) { var message = this.messages.push({messagetext: messagetext, type: type, closeable: false}); }; this.gethtmlcontent = function(messageid) { homecoming this.messages[messageid].messagetext; } this.removemessage = function (messageid) { this.messages.splice(messageid, 1); }; this.clearmessages = function() { this.messages = []; }; } myapp.service('errorhandling', function () { homecoming new errorhandlingfactory(); }); myapp.run(function($rootscope, errorhandling) { // attach global error handling object our rootscope $rootscope.errorfactory = errorhandling; }); // usage controller $rootscope.errorfactory.addmessage('the message added', 'warning');

to create bit easier understand, i've created jsfiddle at. http://jsfiddle.net/kxsml25h/7/

what when link in message clicked, function desiredcallback run on generictestcontroller.

angularjs angularjs-scope angular-services

php - Dynamic hosting on Apache with two differently constructed URLs -



php - Dynamic hosting on Apache with two differently constructed URLs -

i have created cms uses url directory name - this:

virtualdocumentroot /var/www/html/%0

so, www.somesite.com served from: /var/www/html/www.somesite.com

this works, but, need sandbox url because site url not available @ time site beingness created.

so, in add-on routing normal url, need route directory:

www.mycmsthingy.com/somesite

other cmss must have solved problem can’t seem find examples.

my understanding running both in same linux server machine

www.somesite.com - virtualdocumentroot @ /var/www/html/www.somesite.com

www.mycmsthingy.com - virtualdocumentroot @ /var/www/html/www.mycmsthingy.com

if true, can symlink virtualdocumentroot want:

cd /var/www/html ln -s www.somesite.com www.mycmsthingy.com/somesite

in browser, http://www.mycmsthingy.com/somesite/ have contents of www.somesite.com

php .htaccess mod-rewrite virtualhost

javascript - How to prevent redirect after hyperlink click? -



javascript - How to prevent redirect after hyperlink click? -

i have next html+ js code:

<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </head> <body> <a href="#" id=key onclick="func(0)">foo</a> </body> <script type="text/javascript"> function func(k){ alert(1); homecoming false; } </script> </html>

can explain how refactor next code after click on href code func executes # doesn't add together url , page shouldn't reload?

use javascript:void(0); instead of # follows:

<a href="javascript:void(0);" id=key onclick="func(0)">foo</a>

javascript html hyperlink onclick href

localhost - What's the equivalent of loalhost when developing on a virtual private server? -



localhost - What's the equivalent of loalhost when developing on a virtual private server? -

this seems obvious question reason couldn't find online explains this. when i'm developing locally on computer switch , forth between terminal write code , browser view resulting website localhost url , appropriate url.

what's equivalent of localhost when developing on vps digital ocean? don't want utilize vps production server, want able preview.

ok sense little silly figured out after reading other stuff , talking coworker it.

basically localhost kind of alias ip address specially set aside purpose (127.1.1 think). localhost easier remember bunch of numbers @ end of day that's is. if you're working on virtual private server digital ocean droplet, need navigate ipaddress in browser , that's cloud equivalent of localhost.

localhost cloud digital-ocean

emacs - confluence create a link of a page to another page name? -



emacs - confluence create a link of a page to another page name? -

i using confluence via emacs confluence-mode, , give pages meaningful name, give them short name create faster type when editing. can create page link page different name?

for example, create page called my meaningful name page , create link page called p1 pointer other page. when opening p1, opening other page.

essentially, want able open page:

http://my-confluence.mydomain.com/display/myspace/p1

and end with:

http://my-confluence.mydomain.com/display/myspace/my+meaningful+name+for+this+page

any ideas?

can describe use-case bit more? can accomplish using anchors (https://confluence.atlassian.com/display/doc/working+with+anchors) if you're linking same page. if need link new page, might help: https://confluence.atlassian.com/display/doc/configuring+shortcut+links

emacs confluence

iterator - Python: is iter(x) equivalent to for el in x: yield el? -



iterator - Python: is iter(x) equivalent to for el in x: yield el? -

suppose there collection:

list = [1,2,3]

is builtin method

it1 = iter(list)

equivalent to

def niter(x): el in x: yield el it2 = niter(list)

edit: to farther clarify, know iter() can except more arguments, in principal want know if same yield doing in niter

no. iter(lst) returns list_iterator object, sec illustration generic generator. both same, in different ways. xxx_iterator objects aware of construction iterating on, , utilize specific properties implement next method. generic generators don't know arguments (if any) , rely on them implement iterator protocol. iter(lst) returns real iterator, 1 fetches items list, , niter wrapper simply delegates job argument (which happens list_iterator 1 time again).

in other words iter(obj) says "dear obj, need knows how iterate you" , for z in obj "i don't care how iterate you, gimme values".

python iterator

mysql - Converting this DB Queries to php PDO -



mysql - Converting this DB Queries to php PDO -

need help 2 queries in pdo

php code:

if($who!="") { $sql = "select id, title, itemurl iwbf_vault uid='".$who."' order pudt desc limit $limit_start, $items_per_page"; }else{ $sql = "select id, title, itemurl, uid iwbf_vault order pudt desc limit $limit_start, $items_per_page"; }

i write way:

// may have set before $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); $values = array(); $sql = "select id, title, itemurl iwbf_vault true"; if ($who) { $sql .= " , uid = ?"; $values[] = $who; } $sql .= " order pudt desc limit ?, ?"; $values[] = $limit_start; $values[] = $items_per_page; $stmt = $pdo->prepare($sql); $stmt->execute($values);

php mysql pdo

javascript - How do I rename an - inside a using jQuery? -



javascript - How do I rename an <li> inside a <ul> using jQuery? -

i need help.

i couldn't find much reference material out there (if any) on web, turning help of gurus , experts around place.

how can create listbox, such when item highlighted, , click on rename button @ top, input box li's current value placed in same spot selected li value , user have alternative rename li item. changes saved if lisbox has lost focus. similar examples windows, when click "rename" list item becomes input box user rename file. i'd mock same functionality , apply ul li listbox.

for sake of keeping things plain , simple, jquery friendly.

here's fiddle: http://jsfiddle.net/a4kg2612/

html:

<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $('li').click(function(){ $('li.active').removeclass('active'); $(this).addclass('active'); }); }); </script> <style type="text/css"> .active { background-color: rgb(128,128,128); } #colors { border: 1px solid #000; width: 100px; list-style: none; margin: 0; padding: 2px; } </style> </head> <body> <input type="button" value="raname" onclick="renameli()"> <ul id="colors"> <li>red</li> <li>green</li> <li>blue</li> <li>yellow</li> <li>orange</li> <li>purple</li> </ul> </body> </html>

my solution temporarily makes li input , when done replaces li

http://jsfiddle.net/a4kg2612/1/

$('li').click(function(){ $('li.active').removeclass('active'); $(this).addclass('active'); $(this).replacewith('<input type="text" id="change_me">'); var val = $('#change_me').val(); if ( val ) { $('#change_me').replacewith('<li>' + val + '</li>'); } });

this incorporates rename button:

http://jsfiddle.net/a4kg2612/5/

this want:

http://jsfiddle.net/a4kg2612/6/

$('li').click(function(){ $('li.active').removeclass('active'); $(this).addclass('active'); var li = $(this); $("#rename").click(function() { $(li).replacewith('<input type="text" id="change_me">'); $("#change_me").focus(); setinterval(function(){ var val = $("#change_me").val(); if ( ! $("#change_me").is(":focus") ) { $('#change_me').replacewith('<li>' + val + '</li>'); } }, 100); }); });

javascript jquery html html-lists

ajax - DOM reloads when using Jquery drag and drop -



ajax - DOM reloads when using Jquery drag and drop -

we making interactive story our school project. problem, when stage have build lego-man. when drag 1 of body parts onto gray area, seems reset dom, or refresh it.

can see going on?

you can see "game" on link.

http://mikkellindblom.dk/tommy-lego/

------ sorry no code!!! ----- don't know part should post, , and not sure if dom resets.

i seeing dom element re-drawing, win7/chrome. code buried within ajax fragments, took awhile track things down, think what's happening when dropping item -- it's registering click event, , on page, have click event :

// level 2 handeler $("#level-2").click(function(){ if ( $( ).hasclass( "active" ) ) { $( "#level_holder" ).fadeout( "slow" ); $( "#loader" ).fadein(); $( "#content_holder" ).load('content/content-2.html'); $( "#content_holder" ).fadein(); $( "#loader" ).fadeout(); } else { swal({ title: "hov!", text: "du skal klare level 1 først!", type: "error", confirmbuttontext: "okay" }); } });

so might want try, in drag-droppable drop event, prevent event bubbling further. in part, add together code prevent click event go on on bubbling:

function handleitemdrop( event, ui ) { var slotnumber = $(this).data( 'number' ); var itemnumber = ui.draggable.data( 'number' ); // hvis delen er placeret den korrekte ramme. if ( slotnumber == itemnumber ) { ui.draggable.addclass( 'correct' ); ui.draggable.draggable( 'disable' ); $(this).droppable( 'disable' ); ui.draggable.position( { of: $(this), my: 'left top', at: 'left top' } ); ui.draggable.draggable( 'option', 'revert', false ); correctitems++; } // antallet af dele der er placeret korrekt = 3 (total = 3), load næste side. if ( correctitems == 3 ) { $( "#main" ).load('content/fragments-1/fragment-3.html'); } event.stoppropagation(); // <-- stops 'click' event firing, reloading "page". }

here's link jquery event handling: http://api.jquery.com/event.stoppropagation/

so - in short, think when drop object, it's firing page's click event ends redrawing fragment. essentially, add together event.stoppropagation() @ end of handleitemdrop function , see if doesn't stop refreshing of dom fragment (it's not much refreshing redoing fadeout , fadein again).

jquery ajax dom draggable droppable

titanium - How to enable button focus on touchStart? -



titanium - How to enable button focus on touchStart? -

i have created button, need response button like, on touch of button, button focus should enable alter in background color. how can that?

my code is, view:

<button class="button" id="proceedbutton" onclick="openquestionnaire">proceed</button>

style:

".button":{ width: '50%', top: '25dp', borderradius: 8, borderwidth: 1, bordercolor: '#808080', backgroundgradient: { type: "linear", startpoint: { x: "0%", y:"0%"}, endpoint: { x: "0%", y:"100%"}, colors: [ { color: "#4f94cd", offset: 0.0 }, { color: "#4f94cd", offset: 1.0 } ] } }

controller:

$.proceedbutton.addeventlistener('touchstart', function() { $.proceedbutton.isfocused = true; }); $.proceedbutton.addeventlistener('touchend', function() { $.proceedbutton.isfocused = false; });

the above code not working. need slight chage in background color while touch of button.

any solution!!

as @codeforfun mentioned can utilize backgroundselectedcolor property of button.

also next states can used button in titanium.

disabled : backgrounddisabledimage , backgrounddisabledcolor normal : backgroundimage , backgroundcolor focus : backgroundfocusedimage , backgroundfocusedcolor selected : backgroundselectedimage , backgroundselectedcolor

hope helpful.

edit : illustration of usage:

view :

<button class="button" >proceed</button>

tss :

".button":{ width: '50%', top: '25dp', backgroundselectedcolor : "#4f94cd" //usage }

titanium titanium-mobile titanium-alloy tss

c# - Excel interop adding slashes in my number formatting string -



c# - Excel interop adding slashes in my number formatting string -

i'm trying set number format (south african rand currency, no decimals) range so:

range.numberformat = "_ r * # ##0_;";

where range of type microsoft.office.interop.excel.range

however when open spreadsheet , check formatting string choosing custom format string looks this:

_ \r * #\ ##0_;

and these added slashes means first one thousand separator (a space) nowadays , rest left off.

i've tried this:

range.numberformat = @"_ r * # ##0_;";

i tried msdn paricular doc reads gibberish me: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.numberformat.aspx

but same thing. know how prevent happening?

setting numberformatlocal property seems have solved me:

range.numberformatlocal = "_ r * # ##0_;";

no thought why though... , happy take more finish reply explains why there problem , why fixes it.

c# excel number-formatting excel-interop custom-formatting