Sunday, 15 February 2015

c# - Trying to create a dropdown list and textbox, setting list item as data and text box as value - asp.net mvc 4 -



c# - Trying to create a dropdown list and textbox, setting list item as data and text box as value - asp.net mvc 4 -

i trying create search form searches based on server name or printer name. here snippet controller:

list<selectlistitem> items = new list<selectlistitem>(); items.add(new selectlistitem { text = "server name", value = "servername" }); items.add(new selectlistitem { text = "printer name", value = "printername" }); viewdata["newlist"] = items;

here view (which know wrong because doesn't work):

@using (html.beginform("search", "printqueues", formmethod.get)) { <fieldset> <legend> search </legend> @html.dropdownlist("newlist",viewdata["newlist"] selectlist) @html.textbox("newlist") <p> <input type="submit" value="submit" /> </p> </fieldset> }

if pick "server name" , set in value (such "myservernaem" textbox, want url show:

/search?servername=myservername

i'm pretty sure both controller , view incorrect.

not huge fan of approach... http works sending value each input controller. values receive in controller, should able homecoming appropriate page , information.

so if re-named drop downwards list searchtype , textbox searchcriteria you'd have nice query string like: /search?searchtype=printer&searchcriteria=epson. in controller should able receive these , homecoming appropriate page (whether printer or server).

public actionresult search(string searchtype, string searchcriteria) { if(searchtype == "printername") { // search printers using searchcriteria , homecoming appropriate view } else if(searchtype == "servername") { // search servers using searchcriteria , homecoming appropriate view } }

if go approach create enum called searchtype , utilize instead of string, allow do: if(searchtype == searchtype.printer) ...

if want go approach, values inputs when seek search , append url:

@html.dropdownlist("searchtype",viewdata["newlist"] selectlist) @html.textbox("searchcriteria") <button type="button" onclick="gotosearch();">search</button> function search() { // assumption of jquery (use document.getelementbyid otherwise...) var type = $('#searchtype').val(); var searchcriteria = $('#searchcriteria').val(); window.location = '@url.action("search", "printqueues")' + '?' + type + '=' + searchcriteria; }

happy reply questions.

c# asp.net razor asp.net-mvc-4

MATLAB - Using fm demod to decode data -



MATLAB - Using fm demod to decode data -

i trying extract sinusoid has speed changes sinusiodially. form of approximately sin (a(sin(b*t))), a+b constant.

this i'm trying, doesnt give me nice sin graph hope for.

fs = 100; % sampling rate of signal fc = 2*pi; % carrier frequency t = [0:(20*(fs-1))]'/fs; % sampling times s1 = sin(11*sin(t)); % channel 1, generates signal x = [s1]; dev = 50; % frequency deviation in modulated signal z = fmdemod(x,fc,fs,fm); % demodulate both channels. plot(z);

thank help.

there bug in code, instead of:

z = fmdemod(x,fc,fs,fm);

you should have:

z = fmdemod(x,fc,fs,dev);

also see nice sine graph need plot s1.

it looks not creating fm signal modulated correctly, can not demodulate correctly using fmdemod. here illustration correctly:

fs = 8000; % sampling rate of signal fc = 3000; % carrier frequency t = [0:fs]'/fs; % sampling times s1 = sin(2*pi*300*t)+2*sin(2*pi*600*t); % channel 1 s2 = sin(2*pi*150*t)+2*sin(2*pi*900*t); % channel 2 x = [s1,s2]; % two-channel signal dev = 50; % frequency deviation in modulated signal y = fmmod(x,fc,fs,dev); % modulate both channels. z = fmdemod(y,fc,fs,dev); % demodulate both channels.

if find thr answers useful can both up-vote them , take them, thanks.

matlab

ios - How to edit the contents while http Post? -



ios - How to edit the contents while http Post? -

hi friends im getting info ie html contents next code..

-(void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { [receiveddata appenddata:data]; nsstring *htmlstr = [[nsstring alloc] initwithdata:self.receiveddata encoding:nsutf8stringencoding]; nslog(@"%@" , htmlstr); }

if want edit of contents in html page , want post it, how can that?

eg: if im using gmail account, , when html contents of gmail, want come in mail-id , password in html page (without using pre-defined ui) , want post contents.. when click on gmail in alternative should straight log-in without showing log-in page..

can , if yes how in objective c.?

- (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data

method gets called multiple times while web service returning response, improve alter info into:

- (void)connectiondidfinishloading:(nsurlconnection *)connection

you can following:

- (void)connectiondidfinishloading:(nsurlconnection *)connection { nsstring *htmlstr = [[nsstring alloc] initwithdata:self.receiveddata encoding:nsutf8stringencoding]; nsmutablestring *strtobechanged = [nsmutablestring stringwithstring:htmlstr]; // perform changes strtobechanged. }

hope makes sense you.

ios ios5 ios6 ios4 ios-simulator

javascript - Is there any QUnit assertion/function who test whether element in array or not -



javascript - Is there any QUnit assertion/function who test whether element in array or not -

i have array of expected output in qunit function.now want test result of function in array or not.

var =new array('abc','cde','efg','mgh');

now question is there qunit assertion/function can me ??

i know js coding create method check wanna spefic ounit !!!!

if have javascript 1.6 can utilize array.indexof

test("myfunction expected value", function() { var expectedvalues = ['abc','cde','efg','mgh']; ok(expectedvalues.indexof(myfunction()) !== -1, 'myfunction() should homecoming expected value'); });

if want can extend qunit back upwards these kind of assertions:

qunit.extend(qunit, { inarray: function (actual, expectedvalues, message) { ok(expectedvalues.indexof(actual) !== -1, message); } });

then can utilize custom inarray() method in tests:

test("myfunction expected value", function() { var expectedvalues = ['abc','cde','efg','mgh']; qunit.inarray(myfunction(), expectedvalues, 'myfunction() should homecoming expected value'); });

i created a jsfiddle show both options.

javascript unit-testing qunit

jquery - How do i limit the 'click' area? -



jquery - How do i limit the 'click' area? -

i've got construction accordion. got 'work' divs, did hide pictures inside, , want them work gallery.

so when click on 'work' div, div animates , height expands , gallery appears.

but wherever click closes 'work' div again. want is, limit click area , prevent close 'work' users can navigate through images.

i hope made myself clear.

here's image url, see, work images underneath open work, when click on image, closes up. arranged 'gallery' div's z-index 9999 still click called 'work'

http://cl.ly/image/2y3v052t0u43

thanks in advance, cheers, met.

create div.title within work div , bind click event .title. enclose gallery in div.gallery , hide default.

working fiddle

jquery html css interaction

Prevent PHP Interpreting New Lines in Strings in the Source Code -



Prevent PHP Interpreting New Lines in Strings in the Source Code -

i have assign big strings variables. in source code preferably want maintain lines within 80 characters.

ideally want able lay these literal strings out on multiple lines.

what want avoid using concatenation, or function calls (e.g. preg_replace()), bring together multiple strings in one. don't thought have invoke language features in order improve style of code.

example of like:

$text = <<<text line 1 line 2 line 3 text; echo($text);

this should output:

line1line2line3

is possible?

there few options:

just concatenate (preferred)

use array constructs

use sprintf()

just concatenate:

echo 'long long line1' . 'another long line 2' . 'the lastly long line 3';

what efficiency?

the above code compiles next opcodes (which what's run):

5 0 > concat ~0 'long+long+line1', 'another+long+line+2' 1 concat ~1 ~0, 'the+last+very+long+line+3' 2 echo ~1

as can see, builds string concatenating first 2 lines, followed lastly line; in end ~0 discarded. in terms of memory, difference negligible.

this single echo statement like:

3 0 > echo 'long+long+line1another+long+line+2the+last+very+long+line+3'

technically it's faster because there no intermediate steps, in reality won't sense difference @ all.

using array:

echo join('', array( 'line 1', 'line 2', 'line 3', ));

using sprintf():

echo sprintf('%s%s%s', 'line 1', 'line 2', 'line 3' );

php string coding-style string-formatting code-formatting

Kendo UI Mobile - CSS attribute resets on view transition when removed in JQuery -



Kendo UI Mobile - CSS attribute resets on view transition when removed in JQuery -

currently handling flicker of unstyled content of kendo mobile web app applying next css rule within css file:

[data-role="content"] { visibility: hidden; }

this hides of content within kendo views, in jquery "load" event, remove above css attribute:

$(window).bind("load", function () { // flicker of unstyled content $("[data-role=\"content\"]").css("visibility", "visible"); });

all has worked fine , haven't had issues this, except when using kendo's view transitions.

when utilize slide:left transition, original visibility: hidden; defined in css file re-applied, causing invisible.

is there reason why happening, specifically, kendo , how handles views , transitions? understand manually add together class visibility: hidden; each data-role="content" element, , remove class in jquery's "load" event handler, wanted solution bit less "hardcoded."

thank you.

the data-role=content attributes set when view initialised - load event handler won't impact views (unless have data-role=content set manually).

you may consider hiding application container instead.

jquery css kendo-ui

How to access hosted WCF webservice with jquery in html -



How to access hosted WCF webservice with jquery in html -

1.i have simple wcf webservice , hello method homecoming string "hello". have hosted on server. can access http://demo.test.com/myservice/service.svc?wsdl.

2.i want access through simple html page jquery call.

the problem html page not beingness able access service. haven't added on service except whatever comes in default visual studio 2010. need add together on server side service access them jquery call? how can able access them?

is service running on same domain page javascript code?

if not need enable cors http://en.wikipedia.org/wiki/cross-origin_resource_sharing create ajax requests other domain

jquery wcf web-services

c++ - Check a string is convertable to the n-th element of a std::tuple -



c++ - Check a string is convertable to the n-th element of a std::tuple -

i have std::tuple type , need check if string can de-serialized 1 of elements. index of element , string known @ run time.

my solution (below) works creates compiler errors when using std::tuple_element, giving:

error: invalid utilize of incomplete type ‘struct std::tuple_element<0ul, std::tuple&>

#include <sstream> #include <tuple> template<class tuple, std::size_t n> struct isdeserializable { static void check(std::size_t idx, std::stringstream& in) { isdeserializable<tuple, n-1>::check(idx, in); if (idx == n-1) { typename std::tuple_element<n-1,tuple>::type tmp; in >> tmp; } } }; template<class tuple> struct isdeserializable<tuple, 1> { static void check(std::size_t idx, std::stringstream& in) { if (idx == 0) { typename std::tuple_element<0,tuple>::type tmp; in >> tmp; } } }; template<class tuple> bool is_deserializable(std::size_t idx, const std::string& val) { std::stringstream in; in << val; seek { isdeserializable<tuple, std::tuple_size<tuple>::value>::check(idx, in); homecoming true; } catch(...) {return false;} } // illustration usage std::tuple<int,double,char> mytuple; assert(is_deserializable<mytuple>(0,"4")); assert(is_deserializable<mytuple>(1,"56.5")); assert(is_deserializable<mytuple>(2,"h")); assert(!is_deserializable<mytuple>(0,"4.3")); assert(!is_deserializable<mytuple>(1,"hello")); assert(!is_deserializable<mytuple>(2,"42"));

c++ templates c++11 tuples

java - Build javamail-android -



java - Build javamail-android -

im trying build library http://code.google.com/p/javamail-android/ myself. there files missing. illustration bootstrap/ant-common.xml did manage build it? thanks!

build failed java.io.filenotfoundexception: /users/downloads/javamail-android-read- only/bootstrap/ant-common.xml (no such file or directory) @ java.io.fileinputstream.open(native method) @ java.io.fileinputstream.<init>(fileinputstream.java:120) @ java.io.fileinputstream.<init>(fileinputstream.java:79) @ sun.net.www.protocol.file.fileurlconnection.connect(fileurlconnection.java:70) @ sun.net.www.protocol.file.fileurlconnection.getinputstream(fileurlconnection.java:161) @ com.sun.org.apache.xerces.internal.impl.xmlentitymanager.setupcurrententity(xmlentitymanager.java:651) @ com.sun.org.apache.xerces.internal.impl.xmlentitymanager.startentity(xmlentitymanager.java:1313) @ com.sun.org.apache.xerces.internal.impl.xmlentitymanager.startentity(xmlentitymanager.java:1250) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl.scanentityreference(xmldocumentfragmentscannerimpl.java:1906) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl$fragmentcontentdriver.next(xmldocumentfragmentscannerimpl.java:3033) @ com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl.next(xmldocumentscannerimpl.java:647) @ com.sun.org.apache.xerces.internal.impl.xmlnsdocumentscannerimpl.next(xmlnsdocumentscannerimpl.java:140) @ com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl.scandocument(xmldocumentfragmentscannerimpl.java:511) @ com.sun.org.apache.xerces.internal.parsers.xml11configuration.parse(xml11configuration.java:808) @ com.sun.org.apache.xerces.internal.parsers.xml11configuration.parse(xml11configuration.java:737) @ com.sun.org.apache.xerces.internal.parsers.xmlparser.parse(xmlparser.java:119) @ com.sun.org.apache.xerces.internal.parsers.abstractsaxparser.parse(abstractsaxparser.java:1205) @ com.sun.org.apache.xerces.internal.jaxp.saxparserimpl$jaxpsaxparser.parse(saxparserimpl.java:522) @ org.apache.tools.ant.helper.projecthelper2.parse(projecthelper2.java:307) @ org.apache.tools.ant.helper.projecthelper2.parse(projecthelper2.java:178) @ org.apache.tools.ant.projecthelper.configureproject(projecthelper.java:82) @ org.apache.tools.ant.main.runbuild(main.java:793) @ org.apache.tools.ant.main.startant(main.java:217) @ org.apache.tools.ant.launch.launcher.run(launcher.java:280) @ org.apache.tools.ant.launch.launcher.main(launcher.java:109)

i found brilliant project, android library project. ready utilize out of box:

https://github.com/lucabelluccini/javamail_android

i not compile:

http://code.google.com/p/javamail-android/

all files not checked in , author unwilling help.

java android maven glassfish javamail

java - Margin/Padding of the stars in a RatingBar (or position and size)? -



java - Margin/Padding of the stars in a RatingBar (or position and size)? -

i seek create custom ratingbar application has different image each of 4 stars. next ondraw method works quite on mobile.

public class mybar extends ratingbar { private int[] stararraycolor = { r.drawable.star_1_color, r.drawable.star_2_color, r.drawable.star_3_color, r.drawable.star_4_color }; private int[] stararraygrey = { r.drawable.star_1_grey, r.drawable.star_2_grey, r.drawable.star_3_grey, r.drawable.star_4_grey }; (...) @override protected synchronized void ondraw(canvas canvas) { int stars = getnumstars(); float rating = getrating(); float x = 10; (int i=0;i<stars;i++) { bitmap bitmap; resources res = getresources(); paint paint = new paint(); paint.setantialias(true); paint.setfilterbitmap(true); paint.setdither(true); if ((int) rating-1 == i) { paint.setalpha(255); bitmap = bitmapfactory.decoderesource(res, stararraycolor[i]); } else { paint.setalpha(70); bitmap = bitmapfactory.decoderesource(res, stararraygrey[i]); } bitmap scaled = bitmap.createscaledbitmap(bitmap, 75, 75, true); canvas.drawbitmap(scaled, x, 12, paint); x += 96; } } }

but "calculation" of x/y position , size of images suc*s! trial , error right coordinates...

how can calculate position/size etc. working on every device?

in sources of absseekbar/progressbar have found variables called mpaddingtop, mpaddingbottom etc. there way values?

bitmap has getwidth , getheight function. can utilize calculate size of bitmap. can place them based on (with whatever padding wish use).

java android

c# - Pass Array to a WCF function -



c# - Pass Array to a WCF function -

so, have c# project in which, loading xml document (contains name of students , id) using linq xml , have associated info (their due date, amount , stuff ) wcf service. added service right click , add together service reference , need pass arrays getdata function, initialized null obviously. cant able convert array service type , function returns array too. how assign array studentarray ?

servicereference1.serviceclient client = new servicereference1.rycorserviceclient(); application.servicereference1.student[] studentarray = new servicereference1.student[9]; student[] array = studentlist.toarray(); //for (int = 0; <= array.count(); i++) // studentarray[i] = (rycorapplication.servicereference1.student)array[i]; //this gives me error says cannot convert type 'application.student' 'application.servicereference1.student'. var info = client.getdata(studentarray);

after getting data, how save info xml file ?

you pretty much have this:

list<servicereference1.student> wcfstudentlist = new system.collections.generic.list<servicereference1.student>(); foreach (var pupil in studentlist) { wcfstudentlist.add(new servicereference1.student() { id = student.id, name = student.name, ..etc.. }); } var info = client.getstudentdata(wcfstudentlist.toarray());

i have question why don't alter wcf phone call if can take list of pupil ids instead of passing entire object though?

c# .net xml wcf

c - pthreads and concurrency -



c - pthreads and concurrency -

i have next code:

#include <pthread.h> #include <stdio.h> #include <stdlib.h> #define loops 10000 void *run(void *arg) { int id = strtol(arg,null,0); int i; for(i=0; i<loops; i++) { printf("in %d.\n",id); } } int main() { pthread_t p1,p2; void *res; pthread_create(&p1,null,run,"1"); pthread_create(&p2,null,run,"2"); pthread_join(p1,&res); pthread_join(p2,&res); homecoming 0; }

when run this, either string "in 1" displays 10000 times consecutively "in 2" displays 10000 times consecutively or vice versa. shouldn't strings alternating , not displaying consecutively here?

the order in threads interleaved scheduler not deterministic (...well scheduler's/kernel's point of view). should not create assumptions order.

in this situation experience either 1 of threads allowed finish whole work before scheduler ->preempts , allows other thread run.

c multithreading concurrency pthreads

c - traversing through the linked list and returning the char* values -



c - traversing through the linked list and returning the char* values -

i having problem returning char* values linked list can please please help how can homecoming char* values within while loop? when seek run programme single value linked list looping forever next code:

char * list_next(list *l) { list *currentposition = null; currentposition = l->next; //skipping dummy value in singly linked list while (currentposition != null) { currentposition = currentposition->next; homecoming currentposition->charvalue; } homecoming null; }

this how calling function:

char * item; while(item = list_next(list)) printf("%s ",item);

it easier

list* current = list->next; //skip dummy while(current) { printf("%s ", current->charvalue); current = current->next; }

but since have function , in format you've got you'd following:

char* list_next(list **l) { if (*l != null) { char* value = (*l)->charvalue; *l = (*l)->next; homecoming value; } homecoming null; }

and phone call so

list* temp_list = my_list->next; //skip dummy char * item; while(item = list_next(&temp_list)) printf("%s ",item);

you can homecoming 1 value function. create recurring calls function had in while loop move through entire list have modify input parameter next phone call in while loop operates on next element in list. notice ** in function parameters.

c

r - Skellam Distribution -



r - Skellam Distribution -

as u guys know skellam bundle removed cran (dont inquire why). after time of net research, couldnt find skellam pmf function, wrote myself.

skellam <- function(k,mu1,mu2){ return(exp(-mu1-mu2)*((mu1/mu2)^(k/2))*besseli(2*sqrt(mu1*mu2),k)) }

r statistics

Application in android related to camera -



Application in android related to camera -

in photographic camera application have image-button,image-view , 2 button confirm , save.on first display image-button visible , others invisible, done coding how photographic camera on click of image button , got image in image-view , on click of confirm button save appear, in save on-click want save image captured in image-view in particular file on sd-card serial naming loop done in digital cam ".png" extension.please help me .and in advance

first have homecoming bitmap image captured , utilize method on button click i'm using tho.

void save() { if (null != view.getdrawable()) { view.setdrawingcacheenabled(true); view.builddrawingcache(); save = view.getdrawingcache(); final file mydir = new file(folder); mydir.mkdirs(); final random generator = new random(); int n = 10000; n = generator.nextint(n); final string fname = "styleme-" + n + ".png"; file = new file(mydir, fname); if (file.exists()) file.delete(); seek { final fileoutputstream out = new fileoutputstream(file); save.compress(bitmap.compressformat.png, 100, out); out.flush(); out.close(); sendbroadcast(new intent(intent.action_media_mounted, uri.parse("file://" + environment.getexternalstoragedirectory()))); toast.maketext(getapplication(), "image saved", toast.length_short).show(); } grab (final exception e) { toast.maketext(getapplication(), "something went wrong check if have plenty memory", toast.length_long).show(); } } else { final toast tst = toast.maketext(getapplication(), "please select image first", toast.length_long); tst.setgravity(gravity.center, 0, 0); tst.show(); } view.setdrawingcacheenabled(false); }

here i'm getting image view cashes , save png have delete if statement , alter save bitmap name save.compress(bitmap.compressformat.png, 100, out);` ,

void save() { final file mydir = new file(folder); mydir.mkdirs(); final random generator = new random(); int n = 10000; n = generator.nextint(n); final string fname = "styleme-" + n + ".png"; file = new file(mydir, fname); if (file.exists()) file.delete(); seek { final fileoutputstream out = new fileoutputstream(file); save.compress(bitmap.compressformat.png, 100, out); \\ alter save bitmap name out.flush(); out.close(); sendbroadcast(new intent(intent.action_media_mounted, uri.parse("file://" + environment.getexternalstoragedirectory()))); toast.maketext(getapplication(), "image saved", toast.length_short).show(); } grab (final exception e) { toast.maketext(getapplication(), "something went wrong check if have plenty memory", toast.length_long).show(); } }

` , here folder string

string folder = "/sdcard/pictures/styleme";

and static file file; , p.s method automatically tell gallery scan new files , without restarting phone or doing manually . take reply if seek , vote sure. edit: add together in manifest <uses-permission android:name="android.permission.write_external_storage" />

android

android - Activity with fragments crashes like if it were nested fragments -



android - Activity with fragments crashes like if it were nested fragments -

i guess knows project created when take "master detail flow" when creating project in eclipse.

theres layouts left side, right side , two_pane layout fragment , framelayout fragment container. works fine.

now have 'main' activity viewpager, fragments etc., , phone call activity fragment callback. activity start new activity b. activity b set illustration activity eclipse talked about.

now have problem app crashes

error/androidruntime(8105): caused by: java.lang.illegalargumentexception: binary xml file line #57: duplicate id 0x7f080024, tag null, or parent id 0x0 fragment fragmentnumber3

when replace fragment in two_pane layout framelayout, doesn't crash. problem typical nested fragments, don't have nested fragments here, right? have activity b that, @ point, doesn't have activity a.

what's problem here?

edit: activity b:

public class sucheactivity extends fragmentactivity implements searchboxfragment.searchboxlistener {

private boolean mtwopane; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.searchbox); getactionbar().setdisplayhomeasupenabled(true); if (findviewbyid(r.id.searchresult_container) != null) { mtwopane = true; } } }

and thats two_pane layout activity, searchbox should left, searchresults right:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginleft="16dp" android:layout_marginright="16dp" android:baselinealigned="false" android:divider="?android:attr/dividerhorizontal" android:orientation="horizontal" android:showdividers="middle" > <fragment android:id="@+id/searchbox_fragment" android:name="com.example.layouttest.searchboxfragment" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"/> <framelayout android:id="@+id/searchresult_container" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" /> </linearlayout>

heres searchboxfragment class:

public class searchboxfragment extends fragment { searchboxlistener mcallback; view v; public interface searchboxlistener { public void onsearchstarted(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { v = inflater.inflate(r.layout.searchbox, container, false); homecoming v; } }

the searchresultfragment:

public class searchresultfragment extends fragment { public searchresultfragment() { } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { homecoming inflater.inflate(r.layout.searchresult, container, false); } @override public void onviewcreated(view view, bundle savedinstancestate) { super.onviewcreated(view, savedinstancestate); } }

and refs.xml in res/values-large:

<resources> <item name="searchbox" type="layout">@layout/haussuche_twopane</item> </resources>

okay, found out:

i cant set layout of activity searchbox.xml (and have alias'd in refs.xml two_pane.xml) , set layout of searchboxfragment searchbox.xml.

i thought searchbox.xml never shown activity in two-pane-mode, safely set elsewhere, that's wrong.

what did re-create layout , utilize searchbox_onepane.xml , searchbox_twopane.xml.

android android-fragments

excel vba - Is there a VBA command that causes a debug to start at that point? -



excel vba - Is there a VBA command that causes a debug to start at that point? -

the context of question using message boxes tool help me familiar quite big amount of vba macros running on collection of excel workbooks.

i inserting message boxes within code pop , tell/remind me in code. have button in these boxes take me debug of code @ point.

at moment solution perform division-by-zero if `yes' button chosen. here illustration snippet:

dim myerror double ... if msgbox("just entered function xyz(). want debug?", vbyesno + vbdefaultbutton2) = vbyes myerror = 1# / 0

it works, not elegant.

i hoping there command start vba debug mode @ point command called.

the stop command you:

if msgbox("just entered function xyz(). want debug?", vbyesno + vbdefaultbutton2) = vbyes stop

vba excel-vba

c++ - Abnormal unresolved external symbol error -



c++ - Abnormal unresolved external symbol error -

i have project used compile fine, using freetype library.

since os has been reinstalled , hence has visual studio 2010.

i have re-included , reinstalled of .lib .dll , header files. reason if run programme release configuration runs fine. if switch on debug config, gives me unresolved external symbol errors linker, on freetype library functions.

now i'm sure c++ directories both configurations identical re-set them using all-configurations tab in solution settings. this, both configurations "additional directories/additional dependancies settings", set identically in same way.

the difference find between release , debug folders in project folder, presence of file in debug folder called "vc100.idb", minimum rebuild dependancy file. looked promising, removing yielded no results, set back.

do have ideas of causing difference between configurations compiling?

worst come worst, can go on programming on release config, i'd rather not go on downwards road i'd know root of problem.

thanks in advance,

guy

the errors:

1>freetype.obj : error lnk2019: unresolved external symbol _ft_glyph_to_bitmap referenced in function "void __cdecl freetype::make_dlist(struct ft_facerec_ *,char,unsigned int,unsigned int *)" (?make_dlist@freetype@@yaxpauft_facerec_@@dipai@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_get_glyph referenced in function "void __cdecl freetype::make_dlist(struct ft_facerec_ *,char,unsigned int,unsigned int *)" (?make_dlist@freetype@@yaxpauft_facerec_@@dipai@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_load_glyph referenced in function "void __cdecl freetype::make_dlist(struct ft_facerec_ *,char,unsigned int,unsigned int *)" (?make_dlist@freetype@@yaxpauft_facerec_@@dipai@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_get_char_index referenced in function "void __cdecl freetype::make_dlist(struct ft_facerec_ *,char,unsigned int,unsigned int *)" (?make_dlist@freetype@@yaxpauft_facerec_@@dipai@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_done_freetype referenced in function "public: void __thiscall freetype::font_data::init(char const *,unsigned int)" (?init@font_data@freetype@@qaexpbdi@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_done_face referenced in function "public: void __thiscall freetype::font_data::init(char const *,unsigned int)" (?init@font_data@freetype@@qaexpbdi@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_set_char_size referenced in function "public: void __thiscall freetype::font_data::init(char const *,unsigned int)" (?init@font_data@freetype@@qaexpbdi@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_new_face referenced in function "public: void __thiscall freetype::font_data::init(char const *,unsigned int)" (?init@font_data@freetype@@qaexpbdi@z) 1>freetype.obj : error lnk2019: unresolved external symbol _ft_init_freetype referenced in function "public: void __thiscall freetype::font_data::init(char const *,unsigned int)" (?init@font_data@freetype@@qaexpbdi@z)

edit: ok strange. i've removed all of freetype directory info rom include , library directory setting in release config, additional dependancies. , released config version still works!

this leading me believe there missing (vs config-wise) moving files over.

i had same problem.

i solved compiling freetype( freetype-2.5.2\builds\windows\vc2010\freetype.sln ) solution x64 platform (or win32 if utilize it).

you .libs platform.

c++ visual-studio-2010 dll linker

ios6 - NSURLCache crashes under iOS 6.1 -



ios6 - NSURLCache crashes under iOS 6.1 -

using ios 6.1 app crashes regulary, straight after startup, when attempts create several http-requests, works fine on os < 6.1.

i'm experiencing exc_bad_access crashes in strlen function called queue : com.apple.cfurlcache_work_queue, everytime app started, except first time.

i resolve issue clearing nsurlcache, straight after app started:

[[nsurlcache sharedurlcache] removeallcachedresponses];

does else experience these crashes? there issue in application code causing these crashes? or should bug filed apple?

experiencing similar crash since ios 6.1 newly installed application. difference crash occurs when tapping text cell in table view. no web requests beingness made @ time.

this bt:

thread #4: tid = 0x2903, 0x3ae7ad74 libsystem_c.dylib`strlen + 28, stop reason = exc_bad_access (code=1, address=0x0) frame #0: 0x3ae7ad74 libsystem_c.dylib`strlen + 28 frame #1: 0x3ac6be24 libsqlite3.dylib`___lldb_unnamed_function282$$libsqlite3.dylib + 1232 frame #2: 0x3ac74a5e libsqlite3.dylib`sqlite3_file_control + 174 frame #3: 0x328493fe cfnetwork`__cfurlcache::recreateemptypersistentstoreondiskandopen_nolock() + 30 frame #4: 0x32849000 cfnetwork`__cfurlcache::recreateemptypersistentstoreondiskandopen() + 44 frame #5: 0x327f9488 cfnetwork`__cfurlcache::opendatabase() + 192 frame #6: 0x32846a72 cfnetwork`__cfurlcache::processcachetasks0(bool) + 358 frame #7: 0x32846900 cfnetwork`__cfurlcache::processcachetasks(bool) + 36 frame #8: 0x3284681e cfnetwork`__cfurlcache::_cfurlcachetimercallback0() + 358 frame #9: 0x328466ac cfnetwork`__cfurlcache::_cfurlcachetimercallback(void*) + 32 frame #10: 0x328490fc cfnetwork`__signalworkertasktoperformwork_block_invoke_0 + 12 frame #11: 0x3ae4611e libdispatch.dylib`_dispatch_call_block_and_release + 10 frame #12: 0x3ae49ece libdispatch.dylib`_dispatch_queue_drain$variant$mp + 142 frame #13: 0x3ae49dc0 libdispatch.dylib`_dispatch_queue_invoke$variant$mp + 40 frame #14: 0x3ae4a91c libdispatch.dylib`_dispatch_root_queue_drain + 184 frame #15: 0x3ae4aac0 libdispatch.dylib`_dispatch_worker_thread2 + 84 frame #16: 0x3ae7aa10 libsystem_c.dylib`_pthread_wqthread + 360 frame #17: 0x3ae7a8a4 libsystem_c.dylib`start_wqthread + 8

reported tsi apple, reviewed , requests log bug, still need this.

interestingly plenty solution found helped me, clearing cache @ launch solved problem.

ios ios6 nsurlcache

linux - Correlation between malloc_stats and /proc/pid/stat -



linux - Correlation between malloc_stats and /proc/pid/stat -

i working on embedded linux system. understand info malloc_stats , /proc/pid/stats provide. want know how info printed malloc_stats related memory usage info provided /proc/stats. background want instrument each thread in app check memory leaks.malloc_stats prints useful info cant used programatically./proc//task/ has useful info unable correlate heap memory used current thread.

have overlooked mallinfo() library function? it's malloc_stats() gets info from.

to reply question directly: info in /proc reflect total memory usage of process, including slack space between memory allocations , free memory, memory that's beingness used wasn't allocated through malloc() @ (e.g, stack, global/static variables, etc). malloc_stats() break downwards what's allocated , isn't.

linux memory-leaks embedded malloc

Get argument names in String Interpolation in Scala 2.10 -



Get argument names in String Interpolation in Scala 2.10 -

as of scala 2.10, next interpolation possible.

val name = "somename" val interpolated = s"hello world, name $name"

now possible defining custom string interpolations, can see in scala documentation in "advanced usage" section here http://docs.scala-lang.org/overviews/core/string-interpolation.html#advanced_usage

now then, question is... there way obtain original string, before interpolation, including interpolated variable names, within implicit class defining new interpolation strings?

in other words, want able define interpolation x, in such way when call

x"my interpolated string has $name"

i can obtain string seen above, without replacing $name part, within interpolation.

edit: on quick note, reason want because want obtain original string , replace string, internationalized string, , replace variable values. main reason want original string no interpolation performed on it.

thanks in advance.

since scala's string interpolation can handle arbitrary expressions within ${} has evaluate arguments before passing them formatting function. thus, direct access variable names not possible design. pointed out eugene, possible name of plain variable using macros. don't think scalable solution, though. after all, you'll lose possibility evaluate arbitrary expressions. what, instance, happen in case:

x"my interpolated string has ${"mr. " + name}"

you might able extract variable name using macros might complicated arbitrary expressions. suggestions be: if name of variable should meaningful within string interpolation, create part of info structure. example, can following:

case class namedvalue(variablename: string, value: any) val name = namedvalue("name", "some name") x"my interpolated string has $name"

the objects passed any* x. thus, can match namedvalue within x , can specific things depending on "variable name", part of info structure. instead of storing variable name explicitly exploit type hierarchy, instance:

sealed trait interpolationtype case class interpolationtypename(name: string) extends interpolationtype case class interpolationtypedate(date: string) extends interpolationtype val name = interpolationtypename("someone") val date = interpolationtypedate("2013-02-13") x"$name born on $date"

again, within x can match interpolationtype subtype , handle things according type.

string scala scala-2.10 string-interpolation

internet explorer - Text-shadow issues with ie -



internet explorer - Text-shadow issues with ie -

i using next css rules add together text-shadow.

.aaactive { text-shadow: 1px 1px #990000; }

i 've searched quite web find solution ie version < 10 (unfortunately many people utilize ie8-9 still) , found have add together 1 of next filter rules unfortunately nil seems happen.

filter: progid:dximagetransform.microsoft.dropshadow(offx=1, offy=1, color=990000); filter: progid:dximagetransform.microsoft.shadow(direction=135,strength=2,color=990000);

is there improve solution or sth missing here?

internet-explorer css3

Facebook PHP SDK Issues -



Facebook PHP SDK Issues -

i've been searching days solution. fist allow me paint out how methodology works process. below works great, unless, user doesn't authorize app origin when directed facebook. understand there cancel_url paramater can use, directing them logout.php page below doesn't if don't authorize app.

this public kiosk, logging user in , out critical. help appreciated. realize long post, wanted show doing during process.

user hits index.php code @ top.

require 'facebook-sdk/src/facebook.php'; // create our application instance (replace appid , secret). $facebook = new facebook(array( 'appid' => 'xxx', 'secret' => 'xxx', )); $user = $facebook->getuser(); if ($user) { seek { // proceed knowing have logged in user who's authenticated. $user_profile = $facebook->api('/me'); } grab (facebookapiexception $e) { error_log($e); $user = null; } } // login or logout url needed depending on current user state. if ($user) { $logouturl = $facebook->getlogouturl(array( 'next' => ($fbconfig['baseurl'].'logout.php') )); } else { $loginurl = $facebook->getloginurl(array('scope' => 'publish_stream, email')); }

clicking on facebook share icon (i'm directing them $loginurl page):

$("#facebook_service").click(function () { window.location = "<?php echo $loginurl; ?>"; });

when login facebook , redirected prompted modal box type , post wall. doing following.

<script> function sendfb(datastr){ $.ajax({ type: "get", url: "post.php", data: datastr, success: function(html){ alert("thank you, post published."); window.location = "<?php echo $logouturl; ?>" } }); } </script>

and here, post.php page looks this:

require 'facebook-sdk/src/facebook.php'; $facebook = new facebook(array( 'appid' => 'xxx', 'secret' => 'xxx', )); if (isset($_get['post'])){ seek { $publishstream = $facebook->api("/$user/feed", 'post', array( 'message' => $_get['message'], 'link' => 'http://myurl.com', 'picture' => 'http://mypicture.jpg', 'name' => 'facebook text' ) ); } grab (facebookapiexception $e) { error_log($e); } }

you can see after ajax success call, user redirected logout url provided facebook, , clear session data, redirect them logout.php has following...

require 'facebook-sdk/src/facebook.php'; // create our application instance (replace appid , secret). $facebook = new facebook(array( 'appid' => 'xxx', 'secret' => 'xxx', )); $facebook->destroysession(); setcookie('fbs_'.$facebook->getappid(), '', time()-100, '/', 'domain.com'); session_destroy(); header("location: index.php");

php facebook

python - Entering special characters in database -



python - Entering special characters in database -

i scanning scheme , entering file names sqlite3 database using python.

one of files happens have special character in name , produces error while inserting record. file name.

a¿.mp3

this query

self.cursor.execute("insert tracks values (?)", i)

also due special character, unable encode in utf-8.

is there other encoding can utilize add together info database?

you can seek utf-16 encoding, or adding '' around special character.

python sqlite3 special-characters

javascript - Long code into function? -



javascript - Long code into function? -

this code has no errors in page, i'm not looking help there. i'm curious if there shorter way this, there's lot of code beingness repeated class names beingness changed each time. create shorter in function or loop of sort? thanks

//menu $('.aboutone').click(function(){ $.scrollto('.basicsrow', 1000, {axis:'yx'}); $.scrollto('.basicsrow', 1000, {axis:'xy'}); }) $('.abouttwo').click(function(){ $.scrollto('.storyrow', 1000, {axis:'yx'}); $.scrollto('.storyrow', 1000, {axis:'xy'}); }) $('.aboutthree').click(function(){ $.scrollto('.teamrow', 1000, {axis:'yx'}); $.scrollto('.teamrow', 1000, {axis:'xy'}); }) $('.aboutone').click(function(){ $.scrollto('.basicsrow', 1000, {axis:'yx'}); $.scrollto('.basicsrow', 1000, {axis:'xy'}); }) $('.abouttwo').click(function(){ $.scrollto('.storyrow', 1000, {axis:'yx'}); $.scrollto('.storyrow', 1000, {axis:'xy'}); }) $('.aboutthree').click(function(){ $.scrollto('.teamrow', 1000, {axis:'yx'}); $.scrollto('.teamrow', 1000, {axis:'xy'}); }) $('.titleone').click(function(){ $.scrollto('.homerow', 1000, {axis:'yx'}); $.scrollto('.homerow', 1000, {axis:'xy'}); }) $('.docsone').click(function(){ $.scrollto('.startrow', 1000, {axis:'yx'}); $.scrollto('.startrow', 1000, {axis:'xy'}); }) $('.docstwo').click(function(){ $.scrollto('.pinpointrow', 1000, {axis:'yx'}); $.scrollto('.pinpointrow', 1000, {axis:'xy'}); }) $('.docsthree').click(function(){ $.scrollto('.swiperow', 1000, {axis:'yx'}); $.scrollto('.swiperow', 1000, {axis:'xy'}); }) $('.docsfour').click(function(){ $.scrollto('.restrow', 1000, {axis:'yx'}); $.scrollto('.restrow', 1000, {axis:'xy'}); }) $('.docsfive').click(function(){ $.scrollto('.actionrow', 1000, {axis:'yx'}); $.scrollto('.actionrow', 1000, {axis:'xy'}); }) $('.contactone').click(function(){ $.scrollto('.contactrow', 1000, {axis:'yx'}); $.scrollto('.contactrow', 1000, {axis:'xy'}); }) $('.downloadone').click(function(){ $.scrollto('.downloadrow', 1000, {axis:'yx'}); $.scrollto('.downloadrow', 1000, {axis:'xy'}); })

perhaps set object, pass function:

var els = { '.abouttwo':'.teamrow', '.aboutthree':'.homerow', ... }; function menu(els){ $.each(els, function(a,b){ $(a).click(function(){ $.scrollto(b, 1000, {axis: "yx"}); $.scrollto(b, 1000, {axis: "yx"}); }); }); } // phone call menu(els);

should give manageability - if changes modify els object.

note: take chance point out it's suggested utilize jquery's .on() (docs) binding events.

javascript jquery css loops scrollto

cordova - how to create two labels side by side using javascript -



cordova - how to create two labels side by side using javascript -

my requirement create 2 labels side side using javascript. used code 1 label, need label right of first label.

my code here var label = document.createelement('label'); label.innerhtml = "hi"; document.body.appendchild(document.createelement("br")); document.body.appendchild(document.createelement("br")); label.addeventlistener("click", onclick); document.body.appendchild(label); want create label right of above one. help me

i think looking for.

var label = document.createelement('label'); var label2 = document.createelement('label'); label.innerhtml = "hi"; label2.innerhtml = "how you?"; document.body.appendchild(document.createelement("br")); document.body.appendchild(document.createelement("br")); document.body.appendchild(label); document.body.appendchild(label2);

update1:

function f1(){ var label = document.createelement('label'); label.innerhtml = "hi"; document.body.appendchild(document.createelement("br")); document.body.appendchild(document.createelement("br")); document.body.appendchild(label); } function f2(){ var label2 = document.createelement('label'); label2.innerhtml = "how you???"; document.body.appendchild(label2); }

update2

function f1(){ var = new array ( "hi", "how you?", "i fine?"); var label = document.createelement('label'); label.innerhtml = a; document.body.appendchild(document.createelement("br")); document.body.appendchild(document.createelement("br")); document.body.appendchild(label); } function f2(){ var label2 = document.createelement('label'); label2.innerhtml = "how you???"; document.body.appendchild(label2); }

javascript cordova

ruby - Sequel: Why isn't the save method saving? -



ruby - Sequel: Why isn't the save method saving? -

i must missing super simple here. in rspec code below, sec assertion failing, 1 code should have been set true:

describe "#redeem!" "marks code redeemed" existing_code = lotterycode[promo_code: "a5"] existing_code.is_redeemed.should == false existing_code.redeem! changed_code = lotterycode[promo_code: "a5"] changed_code.is_redeemed.should == true end end

here model code:

require 'sequel' class lotterycode < sequel::model many_to_one :campus def redeem! is_redeemed = true save end end

what doing wrong?

you want self.is_redeemed = true, current code creates local variable.

ruby sequel

jquery - Set tag css property, before appending the tag to the DOM -



jquery - Set tag css property, before appending the tag to the DOM -

i set dom div tag, using jquery append() method

i want before putting, set div tag css property, illustration visibility: "hidden"

this doesn't work:

$(document).ready( function () { $(".child").css({ visibility: "hidden" }); $("body").append('<div class="child"></div>'); });

http://jsfiddle.net/sbafk/

how solve problem ?

your code cannot work since not create new css rule searches matching elements - , new element cannot found yet. easiest way create element, set css properties , add together dom:

var div = $('<div class="child"></div>').css('visibility', 'hidden'); $('body').append(div);

another alternative creating new css rule matching selector.

jquery html css

html - Jsp Page Shows some unwanted Charater in browser? -



html - Jsp Page Shows some unwanted Charater in browser? -

i have problem while using custom portlet in liferay dont know how when deploy war file other machines liferay server shows me 1 page unwated charater while there no character in jsp page.i have tried everythng..but there no error of javascript or html tag used in jsp page..can help me out should problem here.

here image of jsp page.

my code of jsp page follows

<%@ include file="/init.jsp"%> <%@page import="com.liferay.portal.kernel.util.propsutil"%> <%@page import="com.liferay.util.portlet.portletprops"%> <%@page import="emenu.advertise.emailnotification.emailnotification"%> <%@page import="com.liferay.portal.model.role"%> <%@page import="com.liferay.portal.model.organization"%> <%@page import="com.liferay.portal.util.portalutil"%> <%@page import="emenu.advertise.portlet.restaurantportlet"%> <%@page import="com.liferay.portal.kernel.util.getterutil"%> <%@page import="com.liferay.util.portlet.portletprops"%>; <%@ page import="javax.portlet.portletconfig"%> <%@ page import="com.liferay.util.mail.mailengine"%> <portlet:renderurl var="editadvertiseurl"> <portlet:param name="jsppage" value="/jsps/advertise/editadvertise.jsp" /> </portlet:renderurl> <portlet:renderurl var="addadvertiseurl"> <portlet:param name="jsppage" value="/jsps/advertise/newadvertise.jsp" /> </portlet:renderurl> <portlet:renderurl var="advertiselisturl"> <portlet:param name="jsppage" value="/jsps/advertise/advertiselist.jsp" /> </portlet:renderurl> <% if(!themedisplay.issignedin()) { %> <script type="text/javascript"> window.location="<%=themedisplay.geturlsignin()%>"; </script> <%} %> <% string loading_img_path = request.getcontextpath() + "/img/ajax_loader.gif"; %> <script src="<%=request.getcontextpath()%>/js/jquery.min.js"></script> <script src="<%=request.getcontextpath()%>/lib/datatables/jquery.datatables.min.js"></script> <script src="<%=request.getcontextpath()%>/lib/datatables/jquery.datatables.sorting.js"></script> <script src="<%=request.getcontextpath()%>/js/gebo_tables.js"></script> <% string srolename=null; boolean isreseller= common.checkisreseller(themedisplay); if(isreseller){ srolename="reseller"; } else{ srolename="advertiser"; } %> <nav> <div id="jcrumbs" class="breadcrumb module"> <ul> <li><a href="#"><i class="icon-home"></i></a></li> <li><a href="#"><%=srolename%></a></li> <li>ads</li> </ul> </div> </nav>

now problem comes somewhere before tag of

<nav> <div id="jcrumbs" class="breadcrumb module">

let me give u image of mozila firebug

i dont know problem..i have searched evrything did not find anythng.can please help me.. in machine server worked perfectly.but dont know happens when seek export war or seek deploy eclipse..its showing unwanted character in jsp page

replace

<%@page import="com.liferay.util.portlet.portletprops"%>;

with

<%@page import="com.liferay.util.portlet.portletprops"%>

html jsp liferay portlet liferay-6

mongodb - Compare additional fields only if multiple matches? -



mongodb - Compare additional fields only if multiple matches? -

i have unique documents indexed non-unique keys. makes document unique, combination of multiple keys within document. example:

{ first: 'john', last: 'foo' } { first: 'henry', last: 'bar' } { first: 'frank', last: 'foo' } { first: 'john', last: 'bar' }

so, based on illustration above: if wanted query first name of frank, 1 result. ideally, since have 1 result, wouldn't need compare lastly name our query. however, if query name john, 2 results, would need compare secondary argument.

how style of query achieved in mongo? goal save needless compares if there single match begin with.

note aware style of query doesn't guarantee right document. assumes primary, , each subsequent field match, "good enough" verify identity of document, if 1 document matched. though if there other less obvious reasons why method should not used, means discuss :)

i wouldn't worry @ all, if have index on this. compound index on first, lastly scan index elements start "first". if that's 1 document, stops. if needs match "last", scan parts of index.

mongodb

Bitbucket :Git on Cygwin - Cannot push to remote repository -



Bitbucket :Git on Cygwin - Cannot push to remote repository -

updatedx3 (see below) using git bitbucket repo months until 11/29/12. did not seek , create commit until other day (01/24/13) no avail. reinstalled ssh server in cygwin assured had proper connection. able access server workstation, okay. able clone repo no issue bitbucket using ssh tunnel. however, when tried force changes (after adding, committing, etc.) following:

$ git force origin master come in passphrase key '/home/[user]/.ssh/id_rsa': conq: invalid command syntax. fatal: remote end hung unexpectedly

i have searched forums, faqs, etc. no avail. here output ssh:

$ ssh -t git@bitbucket.org come in passphrase key '/home/[user]/.ssh/id_rsa': conq: logged in [username].

you can utilize git or hg connect bitbucket. shell access disabled.

and also, ssh -v:

$ ssh -v openssh_5.8p1, openssl 0.9.8r 8 feb 2011 usage: ssh [-1246aacfgkkmnnqsttvvxxyy] [-b bind_address] [-c cipher_spec] [-d [bind_address:]port] [-e escape_char] [-f configfile] [-i pkcs11] [-i identity_file] [-l [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] [-o ctl_cmd] [-o option] [-p port] [-r [bind_address:]port:host:hostport] [-s ctl_path] [-w host:port] [-w local_tun[:remote_tun]] [user@]hostname [command]

and git --version:

$ git --version git version 1.7.5.1

as said, ssh seems working, looks else.

--update-- here output ssh -v -t git@bitbucket.org

$ ssh -v -t git@bitbucket.org openssh_5.8p1, openssl 0.9.8r 8 feb 2011 debug1: reading configuration info /etc/ssh_config debug1: connecting bitbucket.org [207.223.240.181] port 22. debug1: connection established. debug1: identity file /home/[user]/.ssh/id_rsa type 1 debug1: identity file /home/[user]/.ssh/id_rsa-cert type -1 debug1: identity file /home/[user]/.ssh/id_dsa type -1 debug1: identity file /home/[user]/.ssh/id_dsa-cert type -1 debug1: identity file /home/[user]/.ssh/id_ecdsa type -1 debug1: identity file /home/[user]/.ssh/id_ecdsa-cert type -1 debug1: remote protocol version 2.0, remote software version openssh_5.3 debug1: match: openssh_5.3 pat openssh* debug1: enabling compatibility mode protocol 2.0 debug1: local version string ssh-2.0-openssh_5.8 debug1: ssh2_msg_kexinit sent debug1: ssh2_msg_kexinit received debug1: kex: server->client aes128-ctr hmac-md5 none debug1: kex: client->server aes128-ctr hmac-md5 none debug1: ssh2_msg_kex_dh_gex_request(1024<1024<8192) sent debug1: expecting ssh2_msg_kex_dh_gex_group debug1: ssh2_msg_kex_dh_gex_init sent debug1: expecting ssh2_msg_kex_dh_gex_reply debug1: server host key: rsa 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40 debug1: host 'bitbucket.org' known , matches rsa host key. debug1: found key in /home/[user]/.ssh/known_hosts:1 debug1: ssh_rsa_verify: signature right debug1: ssh2_msg_newkeys sent debug1: expecting ssh2_msg_newkeys debug1: ssh2_msg_newkeys received debug1: roaming not allowed server debug1: ssh2_msg_service_request sent debug1: ssh2_msg_service_accept received debug1: authentications can continue: publickey debug1: next authentication method: publickey debug1: offering rsa public key: /home/[user]/.ssh/id_rsa debug1: remote: forced command: conq username:[username] debug1: remote: port forwarding disabled. debug1: remote: x11 forwarding disabled. debug1: remote: agent forwarding disabled. debug1: remote: pty allocation disabled. debug1: server accepts key: pkalg ssh-rsa blen 279 debug1: key_parse_private_pem: pem_read_privatekey failed debug1: read pem private key done: type <unknown> come in passphrase key '/home/[user]/.ssh/id_rsa': debug1: read pem private key done: type rsa debug1: remote: forced command: conq username:[username] debug1: remote: port forwarding disabled. debug1: remote: x11 forwarding disabled. debug1: remote: agent forwarding disabled. debug1: remote: pty allocation disabled. debug1: authentication succeeded (publickey). authenticated bitbucket.org ([207.223.240.181]:22). debug1: channel 0: new [client-session] debug1: requesting no-more-sessions@openssh.com debug1: entering interactive session. conq: logged in [username]. can utilize git or hg connect bitbucket. shell access disabled. debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0 debug1: channel 0: free: client-session, nchannels 1 transferred: sent 2576, received 2984 bytes, in 0.3 seconds bytes per second: sent 7759.0, received 8988.0 debug1: exit status 0

update (02/17/13): searched through back upwards page on bitbucket's site, detail how set bitbucket gitbash on windows , not cygwin. saw others had had same problem on faq, referred atlassian support.

i started speaking straight atlassian back upwards , guy told me check post on stack overflow (git ssh on windows). solution posted did not work, back upwards rep instructed me install gitbash see if there other problem besides cygwin. installed gitbash , able working , force , clone 1 time again using ssh or https. told rep , said far help since issue own software. believe have narrowed problem mechanism within cygwin not seem ssh related, perhaps git.

update (02/18/13): today, confirmed able pull cygwin. now, have issue push. considering mapping alias mysysgit within of cygwin in errors cloning git project using cygwin, msysgit bash shell works , may take more time have seek right now. still looking solution git working natively in cygwin.

update (02/20/13): have exact same error pushing gitbash. see garbage @ back upwards page: https://bitbucket.org/site/master/issue/4406/invalid-command-synthax

it seems recurring problem back upwards not straight address. looks of it, has been going on since june of 2012 no published resolution. if reads , can give me direction, appreciate it. now, have switched gitbash using https.

please check {project_folder}/.git/config file. if have remote repository url ssh://. remove , seek force operation.

git force -u origin --all

valid remote repository url

url = git@bitbucket.org:{username}/{project-name}.git

git cygwin bitbucket git-push

mongodb - Why does sending files from GridFS via MVC4 take so much time? -



mongodb - Why does sending files from GridFS via MVC4 take so much time? -

i want send images stored in mongodb using gridfs via mvc4 web app browser via lan environment, take ~500ms until image sent browser.

google chrome network inspector says of time spent during "waiting" while actual "receiving" takes ~1ms.

the mongodb server in local network, can take long send 10kb image? utilize windows 8 visual studio 2012 , official mongo-csharp-driver via nuget.

here code of "files" controller takes object id , sends info id:

public filecontentresult files(string id) { var database = new mongoclient(myconnection).getserver().getdatabase("mydb"); var gridfs = new mongogridfs(database); var bsonid = new bsonobjectid(id); var gridinfo = gridfs.findonebyid(bsonid); var bytes = gridinfotoarray(gridinfo); homecoming new filecontentresult(bytes, "image/jpeg") { filedownloadname = gridinfo.name }; } private byte[] gridinfotoarray(mongogridfsfileinfo file) { using (var stream = file.openread()) { var bytes = new byte[stream.length]; stream.read(bytes, 0, (int)stream.length); homecoming bytes; } }

code display image in view:

<img src="@url.action("files", new { id = objectidofmyimage) })"/>

how different results if cache database , mongogridfs instances?

// create static fields _database & _gridfs var database = _database ?? (_database = new mongoclient(myconnection).getserver().getdatabase("mydb")); var gridfs = _gridfs ?? (_gridfs = new mongogridfs(database));

i'm not sure how much overhead incurs when instantiate these, wouldn't wound move outside of method you're trying optimize.

mongodb asp.net-mvc-4 mongodb-csharp iis-8 gridfs

c++ - How to capture character without consuming it in boost::spirit::qi -



c++ - How to capture character without consuming it in boost::spirit::qi -

i'm using boost::spirit::qi parse "template" format looks this:

/path/to/:somewhere:/nifty.json

where :somewhere: represents string identified name somewhere (the name can series of characters between 2 : characters). have working parser this, want create 1 additional improvement.

i know character follows :somewhere: placeholder (in case /). rest of parser still needs know / , consume part of next section.

how can "read" / after :somewhere: without consuming rest of parser see , consume it.

as sehe mentioned can done using lookahead parser operator &, if want emit character you'll need boost.phoenix, qi::locals , qi::attr.

for example:

#include <boost/fusion/include/std_pair.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/spirit/include/qi.hpp> #include <iostream> #include <string> namespace qi = boost::spirit::qi; int main(int argc, char** argv) { std::string input("foo:/bar"); std::pair<char, std::string> output; std::string::const_iterator begin = input.begin(), end = input.end(); qi::rule<std::string::const_iterator, qi::locals<char>, std::pair<char, std::string>()> duplicate = "foo" >> qi::omit[ &(":" >> qi::char_[qi::_a = qi::_1]) ] >> qi::attr(qi::_a) >> ":" >> *qi::char_; bool r = qi::parse(begin, end, duplicate, output); std::cout << std::boolalpha << r << " " << (begin == end) << " '" << output.first << "' \"" << output.second << "\"" << std::endl; homecoming 0; }

this outputs:

true true '/' "/bar"

c++ boost boost-spirit boost-spirit-qi

ios - How can I allow https connection using AFNetworking? -



ios - How can I allow https connection using AFNetworking? -

i have afnetworking set not take https urls. how can afnetworking connect via ssl.

i have next code:

nsmutableurlrequest *apirequest = [self multipartformrequestwithmethod:@"post" path: pathstr parameters: params constructingbodywithblock: ^(id <afmultipartformdata>formdata) { //todo: attach file if needed }]; afjsonrequestoperation* operation = [[afjsonrequestoperation alloc] initwithrequest: apirequest]; [operation setcompletionblockwithsuccess:^(afhttprequestoperation *operation, id responseobject) { //success! completionblock(responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) { //failure :( nslog(@"%@", error); completionblock([nsdictionary dictionarywithobject:[error localizeddescription] forkey:@"error"]); }]; [operation start];

operation.securitypolicy.allowinvalidcertificates = yes;

this code important. if dont add together error.

ios objective-c ios4 afnetworking

data structures - Which is the most efficient way to persist a string for retrieving spans of text? -



data structures - Which is the most efficient way to persist a string for retrieving spans of text? -

i need way store 1 big text on disk without loading exclusively in memory.

my queries in form of spans of text, such as: give me text between position x , position x + n, nil more, nil less. don't have frequent changes text.

probably need "persistent" b-tree.

it need dbms features like:

a client / server architecture a cache system

thanks

it need dbms features like: ...

so, why don't utilize dbms? or nosql solution query capabilities, orientdb?

i think this.

split text in chunks (chapters? paragraphs? fixed size?) save text in table (at least) 3 fields: text (the chunk of text) begin (the offset of chunk origin of total text) end (the end offset of chunk origin of total text)

now can write query extract text between position x , position x+n.

select text, begin end text_table end >= x , begin <= (x+n) order begin

finaly have extract text doing like: - first row: substring(text, (x-begin)) - "inner" rows: text - lastly row: substring(text, 0, (x+n-begin))

obviously, should take care of "edge cases" (result 1 or 2 rows, requested span out of range, ...). think approach should solve problem without much effort.

hope helps. bye, raf

text data-structures nosql bigdata storage-engines

html - Why asp.net control is accessed by '' format in client side -



html - Why asp.net control is accessed by '<%=controlid.ClientID%>' format in client side -

why asp.net command accessed '<%=controlid.clientid%>' format in client side.

whereas html command accessed straight id.

because default, asp.net web control's clientid dynamically generated. if want access same way html controls, can set clientidmode static.

http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode.aspx

asp.net html rendering

javascript - Trying to display a value when the select list option changes with onchange -



javascript - Trying to display a value when the select list option changes with onchange -

what i'm trying this: when job selected drop-down list, want populate hourlyrate field in totals table amount. dropdown list:

<fieldset> <legend>what position?</legend> <select name="job" id="job"> <option value="job0">please select position:</option> <option value="job1">server/bartender</option> <option value="job2">greeter/busser</option> <option value="job3">kitchen support</option> </select> </fieldset>

this totals table:

<div id="totals"> <table width="408"> <tr> <td width="214">hourly rate:</td><td width="57" id="hourlyrate"></td></tr> </table> </div>

this javascript:

var $ = function (id) { homecoming document.getelementbyid(id); } function ratechange () { var rate=""; if ($('job').value == 'job0') { rate = '0'; } if ($('job').value == 'job1') { rate = '12'; } if ($('job').value == 'job2') { rate = '10'; } if ($('job').value == 'job3') { rate = '11'; } $('hourlyrate').innerhtml = "$ " + rate; } window.onload = function () { $('job').onchange = ratechange(); }

so if selects server/bartender dropdown list, want hourlyrate field in totals table display $12. cannot figure out doing wrong!

it looks you're calling function straight away, instead of telling called on onchange event:

$('job').onchange = ratechange();

so homecoming value of ratechange (nothing) assigned onchange event.

try this:

$('job').onchange = ratechange;

now ratechange function function run when onchange event fires.

javascript onchange

tuples - How to use priority queues in Scala? -



tuples - How to use priority queues in Scala? -

i trying implement a* search in scala (version 2.10), i've ran brick wall - can't figure out how utilize scala's priority queue. seems simple task, searching on google didn't turn (except single code sample stopped working in version 2.8)

i have set of squares, represented (int, int)s, , need insert them priorities represented ints. in python it's pretty simple, since have list of key, value pairs , utilize heapq functions sort it. appears scala's tuples aren't comparable.

so how do this? i'm surprised finish lack of online information, given how simple should be.

there pre-defined lexicographical order tuples -- but need import it:

import scala.math.ordering.implicits._

moreover, can define own ordering. suppose want arrange tuples, based on difference between first , sec members of tuple:

scala> import scala.collection.mutable.priorityqueue // import scala.collection.mutable.priorityqueue scala> def diff(t2: (int,int)) = math.abs(t2._1 - t2._2) // diff: (t2: (int, int))int scala> val x = new priorityqueue[(int, int)]()(ordering.by(diff)) // x: scala.collection.mutable.priorityqueue[(int, int)] = priorityqueue() scala> x.enqueue(1 -> 1) scala> x.enqueue(1 -> 2) scala> x.enqueue(1 -> 3) scala> x.enqueue(1 -> 4) scala> x.enqueue(1 -> 0) scala> x // res5: scala.collection.mutable.priorityqueue[(int, int)] = priorityqueue((1,4), (1,3), (1,2), (1,1), (1,0))

scala tuples priority-queue scala-collections

C# MVC String Format Zero Values -



C# MVC String Format Zero Values -

i utilize format numbers.

@string.format("£{0:#,###,###.##}", 1000) outputs £1,000

however when come in 0 value this:

@string.format("£{0:#,###,###.##}", 0.0) outputs £

how create output when come in 0 values? e.g £0.0

thanks

the # character means "only utilize digit when need to".

i suspect want:

@string.format("£{0:#,###,##0.##}", value)

however, generally improve thought use:

@string.format("{0:c}", value)

... , allow .net framework right thing.

c# string format

javascript - Performance Warning Processing.js -



javascript - Performance Warning Processing.js -

when write processing.js in javascript-flavor performance warning didn't when used processing.js parse processing-code. i've create simple sketch 3d back upwards , console flooded warning:

performance warning: attribute 0 disabled. has signficant performance penalty

what mean? , more importantly: how prepare it?

that's sketch. (watch/edit on codepen.io)

var can = document.createelement("canvas"); var sketch = function(p){ p.setup = function(){ p.size(800, 600, p.opengl); p.fill(170); }; p.draw = function(){ p.pushmatrix(); p.translate(p.width/2, p.height/2); p.box(50); p.popmatrix(); }; }; document.body.appendchild(can); new processing(can, sketch);

this issue in processing.js

for detailed explanation: opengl , opengl es have attributes. attributes can either fetch values buffers or provide constant value. except, in opengl attribute 0 special. can not provide constant value. must values buffer. webgl though based on opengl es 2.0 doesn't have limitation.

so, when webgl running on top of opengl , user not utilize attribute 0 (it's set utilize constant value), webgl has create temporary buffer, fill constant value, , give opengl. slow. hence warning.

the issue in processing have single shader handles multiple utilize cases. has attributes normals, positions, colors, , texture coordinates. depending on inquire processing draw might not utilize of these attributes. illustration commonly might not utilize normals. normals needed in processing back upwards lights if have no lights there no normals (i'm guessing). in case turn off normals. unfortunately if normals happens on attribute 0, in order webgl render has create temp buffer, fill constant value, , render.

the way around utilize attribute 0. in case of processing utilize position data. before linking shaders should phone call bindattriblocation

// "avertex" name of attribute used position info in // processing.js gl.bindattriblocation(program, 0, "avertex");

this create attribute 'avertex' utilize attrib 0 , since every utilize case utilize 'avertex' they'll never warning.

ideally should bind locations. way don't have query them after linking.

javascript google-chrome canvas webgl processing.js

zend framework2 - I need help about Input Filter -



zend framework2 - I need help about Input Filter -

i have method in model taikhoan

public function getinputfilter() { if (!$this->inputfilter) { $inputfilter = new inputfilter(); $factory = new inputfactory(); $inputfilter->add($factory->createinput(array( 'name' => 'tentaikhoan', 'required' => true, 'filters' => array( array('name' => 'striptags'), array('name' => 'stringtrim'), ), ))); $inputfilter->add($factory->createinput(array( 'name' => 'matkhau', 'required' => true, 'filters' => array( array('name' => 'striptags'), array('name' => 'stringtrim'), ), ))); } homecoming $this->$inputfilter; }

then used in controller like

$taikhoan = new taikhoan();

$form->setinputfilter($taikhoan->getinputfilter());

when run, show me error

catchable fatal error: object of class zend\inputfilter\inputfilter not converted string in c:\wamp\www\zf\module\cpanel\src\cpanel\model\taikhoan.php on line 59

the problem typo in statement:

return $this->$inputfilter;

php interpreting line dynamic property name, , converting string. right version is:

return $this->inputfilter;

also need assign input filter:

public function getinputfilter() { if (!$this->inputfilter) { // ... $this->inputfilter = $inputfilter; } homecoming $this->inputfilter; }

zend-framework2 zend-inputfilter

ASP.NET server side control not fired in a JQuery popup -



ASP.NET server side control not fired in a JQuery popup -

i've aspx page 2 jquery popup. each of popup has pairs of server side buttons. problem these button not fire if press. know issue jquery popup .. how can solve ?

edit: follow code

<asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <script type="text/javascript"> $(document).ready(function () { var dlgsuggestsol = $('div#dlgsuggestsolution').dialog({ autoopen: false, modal:true, width:640, height:480 }) $('#btnopensuggestsolution').click(function () { $('div#dlgsuggestsolution').dialog('open'); }); var dlgwaitsol = $('div#dlgwaitingsolution').dialog({ autoopen: false, modal: true, width: 640, height: 480 }) $('#btnreadsolutionawaiting').click(function () { $('div#dlgwaitingsolution').dialog('open'); }); }) </script>

... ...

<div id="dlgsuggestsolution"> <h3>proponi la tua soluzione</h3> <br /> <asp:textbox runat="server" id="txtnewsolution" textmode="multiline" width="480px" height="300px"></asp:textbox> <br /> <asp:button runat="server" id="btnsavesolution" text="salva soluzione" /> <asp:button runat="server" id="abutton" text="jjkkj" /> <asp:label runat="server" id="lblmsg"> </asp:label> </div>

set usesubmitbehavior="false" on buttons in popup. reason popup shown out of form , usual submitting won't pass target command id server. usesubmitbehavior="false" button uses asp.net postback mechanism (__dopostback function actually)

jquery asp.net

jquery image gallery expend cliking on any li -



jquery image gallery expend cliking on any li -

please help. have image gallery , want expend every thumbnail show total length image , clicking goes original size. please advice of give jquery code. give thanks you.

<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <script type="text/javascript" src="js/jquery-1.9.0.min.js"></script> <script> $(document).ready(function(e) { $('#wrapper ul li').bind('click', function () { $(this).removeclass(); $(this).fadein(500).addclass("applyclass");}); }); </script> <style> html, body{margin:0; padding:0; width:100%; height:100%} #wrapper{background:#0cc; margin:0 auto 0 auto} #wrapper ul{list-style:none; margin:0 auto 0 auto; padding:0; width:960px;} #wrapper ul li{display:inline-block; width:227px; height:180px; background:#fc3; margin:5px;} #wrapper ul li.applyclass{display:block; width:960px; height:300px} #wrapper ul li.removeclass{display:inline-block; width:227px; height:180px} </style> </head> <body> <div id="wrapper"> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> </ul> </div> </body> </html>

try script,

$(document).ready(function() { $('#wrapper ul li').click(function () { if($(this).hasclass("applyclass")) $(this).removeclass("applyclass"); else $(this).fadein(500).addclass("applyclass"); }); });

demo: http://jsfiddle.net/8tcht/1/

update code cut down size of li clickin on other li's

$(document).ready(function() { $('#wrapper ul li').click(function () { $('#wrapper ul li').removeclass("applyclass"); $(this).fadein(500).addclass("applyclass"); }); });

demo: http://jsfiddle.net/8tcht/3/

jquery gallery bind

javascript - push multiple elements to array -



javascript - push multiple elements to array -

i'm trying force multiple elements 1 array, getting error

> = [] [] > a.push.apply(null, [1,2]) typeerror: array.prototype.push called on null or undefined

i'm trying similar stuff i'd in ruby, thinking apply *.

>> = [] => [] >> a.push(*[1,2]) => [1, 2]

when using functions of objects apply or call, context parameter must object working on.

in case, need a.push.apply(a, [1,2]) (or more correctly array.prototype.push.apply(a, [1,2]))

javascript

python - Issues ith loop is django -



python - Issues ith loop is django -

i fetching info many users db , array in info collected having 2 rows each user , lastly column value different rest of values same like

r1 --> , b , c , d , 1 (user1) r2 -- > , b , c , d , 2 (user1) r3 --> z , x , v , n , 3 (user2) r4 -- > z , x , v , n , 4 (user2)

now want create array include 1 row corresponding each user consist of every value like

r1 --> , b , c , d , 1 , 2 (user1) r2 -- >z , x , v , n , 3 , 4 (user2)

i have tried loop , resulted array consist of lastly record , wanted array consist of records users.

e.g.

cursor.execute("some query ") numrows = int(cursor.rowcount)

let num rows returns value 4.

then

for in range(numrows):

pass

will loop 4 times , consist values 2 users.

but when returns resulted array consist value of lastly user only.

so please suggest me way when for in range(numrows): array returns consist of records not lastly user record

edited:

i have tried while loop as

arr=[] while arr in row: arr= row[0][1]

but when homecoming arr , empty if homecoming row[0][1] shows value of column.

thanks in advance.

assuming info sorted first 4 entries (which can in sql), can transform info using next code:

from itertools import groupby operator import itemgetter rows=[ ('a' , 'b' , 'c' , 'd' , 1), ('a' , 'b' , 'c' , 'd' , 2), ('z' , 'x' , 'v' , 'n' , 3), ('z' , 'x' , 'v' , 'n' , 4)] out = [] key,group in groupby(rows, itemgetter(0,1,2,3)): new_row = list(key) v in group: new_row.append(v[4]) out.append(new_row) print out

which prints

[['a', 'b', 'c', 'd', 1, 2], ['z', 'x', 'v', 'n', 3, 4]]

here thought you: utilize first 4 entries keys in dictionary.

from collections import defaultdict rows=[ ('a' , 'b' , 'c' , 'd' , 1), ('a' , 'b' , 'c' , 'd' , 2), ('z' , 'x' , 'v' , 'n' , 3), ('z' , 'x' , 'v' , 'n' , 4)] d = defaultdict(list) r in rows: d[tuple(r[0:4])].append(r[4]) print d[('a' , 'b' , 'c' , 'd')] print d[('z' , 'x' , 'v' , 'n')]

prints

[1, 2] [3, 4]

with approach not matter if rows sorted first 4 columns

python django loops

sql - MySQL BEFORE UPDATE trigger - change value -



sql - MySQL BEFORE UPDATE trigger - change value -

so, i've got mysql table, named employees.

id name meta 0 jack ok 1 anne del

i want write trigger prevents row meta='del' update meta field. so, if do:

update employees set meta = 'busy' id = 0

the row should updated , meta 'busy'

but when do:

update employees set meta = 'busy' id = 1

the meta field should still 'del'

i tried:

delimiter $$ create trigger updateemployees before update on employees each row begin if old.meta = 'del' new.meta = 'del' end if; end$$ delimiter ;

but mysql returns syntax error. ideas?

you forgot add together set clause. way doesn't alter value.

delimiter $$ create trigger updateemployees before update on employees each row begin if old.meta = 'del' set new.meta = 'del'; end if; end$$ delimiter ;

mysql sql triggers

Why is this global variable not recognised in javascript function? -



Why is this global variable not recognised in javascript function? -

despite excessive googling don't why function dosomething nil in situation below. thought why doesn't work?

many thanks, gordon

var arrattend=new object(); arrattend["blob"]='hello'; function dosomething() { alert (arrattend["blob"]); }

it's typo, should utilize new object (capital o). or utilize object literal:

var arrattend = {blob: 'hello'}; function dosomething() { alert (arrattend.blob); }

javascript variables global

Haskell Invert Pair -



Haskell Invert Pair -

wondering if help writing function. trying create function inverts each "pair" in list.

module invert invert :: [(a,b)] -> [(b,a)] invert [(a,b)] = [(b,a)]

when come in invert [(3,1) (4,1) (5,1)]... supposed give me [(1,3) (1,4) (1,5)... gives me...

*invert> [(3,1) (4,1) (5,1)] <interactive>:2:2: function `(3, 1)' applied 2 arguments, type `(t0, t1)' has none in expression: (3, 1) (4, 1) (5, 1) in expression: [(3, 1) (4, 1) (5, 1)] in equation `it': = [(3, 1) (4, 1) (5, 1)]

since lists recursive info structures, have process list recursively in order swap elements, or utilize higher order function processing you. if define

invert [(a,b)] = [(b,a)]

it convert single-element lists, other inputs fail error!

try think input invert gets: it's either empty list, or non-empty lists. in case of non-empty list, can swap first element , convert rest recursively.

(if don't want invert invert yourself, use

invert = map swap

where swap data.tuple.)

haskell

java - Hours and seconds are lost when storing a date in the database -



java - Hours and seconds are lost when storing a date in the database -

i'm storing date (java.util.date) in mysql database, before storage have

mon feb 11 18:17:41 cet 2013

after storage :

2013-02-11 00:00:00.0

the database field declared way :

`date_creation` date default null,

and i'm using innodb engine

what can avoid loosing time? thanks.

http://dev.mysql.com/doc/refman/5.1/en/datetime.html - alter info type in mysql datetime.

java mysql sql date jdbc

sql server - data migration old DB to new DB -- triggers? output clause? what? -



sql server - data migration old DB to new DB -- triggers? output clause? what? -

i migrate info parent , kid tables in old db similar tables in new db. old , new schemas different.

in old db parent entry has (id, ...) , kid entries each have (id, pid, ...), pid id of corresponding parent row.

the question is, how them connected in destination db? i'm stuck. had thought way create table maps oldid newid each element; however, cannot figure out how either triggers, output clause or else i've looked at.

there other tables i'd migrate well, oldid newid mapping table handy. unless there's improve solution.

to explain further... there foreign key relationships in old db need preserved in new db. when row gets copied new db gets new pk. rows in kid tables have fk old pk of parent row. in order re-create kid rows old db new 1 have select them old db parent's old pk insert them new db parent's new pk. that's part can't figure out how sql.

thanks, eric

here's approach:

simply add together idmap column target database table, insert related tables based on bring together idmap.

e.g. tables

create table db1.dbo.parent ( id int identity, description varchar(max), primary key(id) ) create table db1.dbo.child ( id int identity, parentid int not null, somechar char(1), primary key(id), foreign key(parentid) references db1.dbo.parent(id) ) create table db2.dbo.parent ( id int identity, description varchar(max), primary key(id) ) create table db2.dbo.child ( id int identity, parentid int not null, somechar char(1), primary key(id), foreign key(parentid) references db2.dbo.parent(id) )

your import script be:

alter table db2.dbo.parent add together idmap int --might consider adding index performance, might help, might hurt. go insert db2.dbo.parent (description, idmap) select description, id db1.dbo.parent insert db2.dbo.child (parentid, somechar) select db2.dbo.parent.id, db1.dbo.child.somechar db1.dbo.child inner bring together db2.dbo.parent on db2.dbo.parent.idmap = db1.dbo.child.parentid

here's sql fiddle demonstrating above (not strictly speaking cross database because of sql fiddle limitations, should give idea.)

you can drop idmap column, or maintain if want around posterity.

sql-server

jquery - Disable div inside a draggable container element -



jquery - Disable div inside a draggable container element -

jsfiddle:

http://jsfiddle.net/sagtw/8/

okay. want #drag-box drag, done easily. don't want #element-1 drag along still want element-1 within #drag-box div.

<div id="drag-box"> <div id="element-1">heck ya!</div> <div id="element-2">heck no!</div> </div> $('#drag-box').draggable();

is possible? can done? sorry if sounds complicated.

why want element-1 within draggable box if dont want div move? if define div draggable logical elements within div move. why dont set element-1 div outside draggable div, , element-2 inside?

jquery jquery-ui

javascript - Why does Array.prototype.reduce not have a thisObject parameter? -



javascript - Why does Array.prototype.reduce not have a thisObject parameter? -

javascript array methods such foreach have thisarg parameter, used context invoking callback:

array.foreach(callback[, thisarg])

as every, some, filter , map. however, reduce , reduceright have no such parameter. there particular reason this, or reason not necessary?

for instance, consider next implementation of functional composition using reduceright:

function compose () { var fns = [].slice.call(arguments,0); homecoming function result() { homecoming fns.reduceright( function (prev,cur){ homecoming [cur.apply(this,prev)]; }, arguments )[0]; }; }

i create "this-aware", functions beingness composed called in context in function returned compose invoked. appear invoked in context of global object. old var self=this; @ top of function result, , utilize first argument cur.apply call, have this, unnecessary if reduce took thisarg argument.

am missing here, , there reduce makes unnecessary or unuseful?

update

@kangax yes, occurred me. far me criticize design of api, signature reduce seems bit unusual me. sec optional argument functions differently normal optional arguments, typically have default value; instead presence or absence changes behavior, overloading function based on signature (argument count). when sec parameter absent, first element of array becomes starting value , first phone call callback against sec value. seems me behavior emulated calling

array.slice(1).reduce(fn,array[0])

instead of building in special rules case sec argument omitted, in turn, if presumption correct, made impossible figure out specify thisarg argument. again, sure such issues debated while spec beingness hashed out, , there may reasons such approach.

it becomes messy 2 optional arguments, since reduce(right) covers 2 functionalities (see wikipedia), distinguished in pure languages (e.g. named foldl , foldl1 in haskell). cite brendan eich:

so mean cut down takes 1 callback argument , 2 optional arguments: thisobject , init. 1 should come first? more mutual 1 init, separate callback arg "thisobject" arg, maybe okay. multiple optional arguments kinda messy way...

alternatively, eliminate "thisobject" argument, since people can [use binding].

i don't think it's big issue, since these functional higher-order-functions used lamdba-function-expressions anyway (like in example). of course of study there's little inconsistency, can live that. image alternative:

array.reduce(callback[, initialvalue[, thisarg]])

can't used, cannot determine "if initialvalue provided" since means arguments.length < 2 - pass undefined literally well. means

array.reduce(callback[, thisarg[, initialvalue]])

which ugly since needed pass null or thisarg if wanted initial value.

you noticed in comment kangax ("the sec optional argument functions differently normal optional arguments, […] presence or absence changes behavior"), can't back upwards statement

this behavior emulated calling array.slice(1).reduce(fn,array[0])

as a) not work complex (chained) look instead of array variable , b) cumbersome.

javascript ecmascript-5