text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
the param, and outside the class is instantiated a concrete implementation which then is passed on to the constructor when creating a new instance of MyClass.
A DI Container, handles the dependency injection automatically. You just configure it, so that it knows what concrete classes to be returned when an abstraction... | [
0.05890354514122009,
-0.2640797197818756,
0.06193172186613083,
0.23680341243743896,
-0.27395930886268616,
-0.009095094166696072,
0.23242680728435516,
-0.24687929451465607,
-0.0860971137881279,
-0.3420898914337158,
-0.1939668357372284,
0.4733028709888458,
-0.35953471064567566,
-0.0007288822... | |
that instead of a higher level class depending on a lower level class (dependency) implementation, the control is inversed so the lower level class implementation depends on an abstraction required by the higher level class.
```
//abstraction defined for the use of higher level class
public interface IRepository {}
... | [
0.0342562273144722,
-0.21411266922950745,
0.041373513638973236,
0.43765100836753845,
-0.11983519047498703,
0.01997503638267517,
-0.3346560299396515,
-0.15737012028694153,
0.047210246324539185,
-0.7082868218421936,
-0.0591331347823143,
0.6120891571044922,
-0.30080366134643555,
0.02266420423... | |
In which circumstances is it safe respectively unsafe to `rm -rf ~/.m2/repository` provided that I'm working online and I have access to all needed artifacts via remote repositories.
When you retrieve all dependencies from remote repositories, then the local repo becomes nothing more than a cache.
Like all caches, th... | [
0.1747700721025467,
0.29415208101272583,
0.2106783241033554,
0.12144657224416733,
0.2906619906425476,
0.24526971578598022,
0.5719549059867859,
-0.14750109612941742,
-0.29138126969337463,
-0.47323277592658997,
-0.32310813665390015,
0.7024564743041992,
0.091307133436203,
0.2575514316558838,
... | |
I have a dataset and I want to test to see how close it is to a normal or gaussian distribution. I know there are a variety of algorithms for doing this, eg. the Jarque-Bera test, the Anderson–Darling test and many others.
I'm hoping to find an open source Java implementation of one of these tests so that I don't need... | [
0.08955030888319016,
-0.1584462970495224,
0.37055644392967224,
0.03355153650045395,
-0.39811304211616516,
-0.08510766178369522,
0.10801342129707336,
-0.2649015188217163,
-0.08361563831567764,
-0.6601576209068298,
0.08156798779964447,
0.17718537151813507,
-0.3352015018463135,
0.169493123888... | |
I can not run the andengine project due to this error:
[](https://i.stack.imgur.com/5FqN5.png)
Here's my code:
```
package a.a.a;
import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.ui.activity.BaseGameActivit... | [
0.020718971267342567,
-0.019830649718642235,
0.3868637979030609,
-0.2382485568523407,
-0.05007227510213852,
0.0802391842007637,
0.2848970890045166,
-0.6680140495300293,
0.0017748395912349224,
-0.5808784365653992,
-0.27195271849632263,
0.8352188467979431,
-0.5496320724487305,
0.062961548566... | |
{
}
}
```
The statistical library [SSJ](http://www.iro.umontreal.ca/~simardr/ssj/indexe.html):
1. Is licensed with GNU GPL
2. Is pure Java (no JNI)
3. Has [Anderson–Darling](http://www.iro.umontreal.ca/~simardr/ssj/doc/html/umontreal/iro/lecuyer/probdist/AndersonDarlingDist.html) | [
-0.2389172613620758,
-0.2688864469528198,
0.5329921841621399,
-0.12263013422489166,
-0.26261770725250244,
-0.10305540263652802,
0.15077228844165802,
-0.32795247435569763,
-0.20009440183639526,
-0.641262412071228,
-0.09966106712818146,
0.24963679909706116,
-0.44761914014816284,
0.1888316273... | |
I'm trying to acheive a collection containing the newest products on home page. This is my code so far:
```
$_productCollection = clone $this->getLoadedProductCollection();
$_productCollection->clear()
->setPageSize(40)
->setOrder('created_at', 'desc')
->load();
```
This is returning 40 products but not in the c... | [
0.576073408126831,
0.1966705471277237,
0.6729379296302795,
-0.25998252630233765,
0.09382499009370804,
0.27266398072242737,
0.03448381647467613,
-0.3551686704158783,
-0.2195986658334732,
-0.716358482837677,
-0.16367311775684357,
0.4988236129283905,
-0.1976470649242401,
0.5247958302497864,
... | |
subscription
if @product.save
redirect_to :back, :notice => "Successfully subscribed to #{@product.name}"
else
render :back, :notice => "Could Not Subscribe to Product correctly."
end
end
``` | [
0.3479195237159729,
-0.2346619814634323,
0.4856923520565033,
0.007161140441894531,
-0.1239185482263565,
0.004948127549141645,
-0.11212752759456635,
-0.18053992092609406,
-0.09759171307086945,
-0.31820201873779297,
-0.1592065840959549,
0.26006972789764404,
-0.17304593324661255,
0.3481941819... | |
I was wondering how can convert `CGcolorRef` to `UIColor` ? I have created a custom method for my own and I need it to use UIColor
EDITED method :
```
- (void)fontColor:(CGColorRef)colors setString(NSSTring *)blah blah blah {
coreTextLayer.foregroundColor = color;
}
[myClass fontColor:[UIColor redCol... | [
0.14663061499595642,
-0.15000562369823456,
0.7381644248962402,
-0.060978032648563385,
-0.014619659632444382,
-0.20036081969738007,
0.16415457427501678,
-0.40991896390914917,
-0.18888509273529053,
-0.7440091371536255,
-0.09454958885908127,
0.685012698173523,
-0.5148403644561768,
0.046349901... | |
to be more in line with Cocoa naming conventions, and to not use dot syntax. ;-) | [
0.22874435782432556,
0.07276556640863419,
0.33773374557495117,
-0.17641201615333557,
0.013293244875967503,
0.20804962515830994,
-0.018843136727809906,
0.28676342964172363,
-0.19358892738819122,
-0.6123186349868774,
-0.7834186553955078,
0.44356489181518555,
-0.4961205720901489,
-0.117481030... | |
I'm working on a piece of homework and I want to send a FILE \* into a function as an argument since I have to open 3 files in an identical manner with some "flavor text". I got it to work fine like this:
```
enum {IN, STAT, REPRINT} FNAMES;
#define FNAME_MAX 256
int main(void)
{
FILE *in, *stat, *reprint;
char ... | [
0.2939450144767761,
0.03427080065011978,
0.48720502853393555,
-0.2732348144054413,
0.03810793533921242,
0.24269060790538788,
0.2562306821346283,
-0.237406924366951,
-0.02197015844285488,
-0.4671964645385742,
-0.29947254061698914,
0.6861209273338318,
-0.13912121951580048,
-0.039122797548770... | |
Check necessity
buildFormat(format); // this translates FNAME_MAX into the string "%256s[^\n]"
// TODO: Find out why this cannot be put into a function!
// open the input file
while (in == NULL)
{
// get input file name
getFileName(format, fnames[IN]); // simply prompts for a file name/path
// ... | [
0.6165713667869568,
-0.2798177897930145,
0.39838525652885437,
-0.13551364839076996,
0.4795351028442383,
0.09394225478172302,
0.3891558349132538,
-0.49767422676086426,
0.07654599845409393,
-0.7099598050117493,
-0.1911230981349945,
1.0373615026474,
-0.3304009437561035,
-0.3362957835197449,
... | |
check spelling/path.\n\n", fnames[IN]);
else
printf("%s was opened successfully.\n\n", fnames[IN]);
}
return 0;
}
```
What will not work is this:
```
void openFile(FILE *in, char *format, char *fname, char *openFor)
{
// TODO: Find out why this cannot be put into a function!
// open the input file
... | [
0.2530193626880646,
-0.07810622453689575,
0.42323440313339233,
-0.2746351659297943,
0.21120001375675201,
0.025311969220638275,
0.775031328201294,
-0.27071642875671387,
0.28370487689971924,
-0.8973153829574585,
-0.34383174777030945,
0.6785414218902588,
-0.3263450562953949,
-0.14650259912014... | |
// make sure it opened
if (in == NULL)
printf("%s did not open, please check spelling/path.\n\n", fname);
else
printf("%s was opened successfully.\n\n", fname);
}
}
```
if I put file reading operations in the function it works fine, but if I go back to main and try to use the file pointer I sent... | [
-0.1230667307972908,
0.08093039691448212,
0.3092308044433594,
-0.28528061509132385,
0.026088904589414597,
0.17556770145893097,
0.5351566672325134,
-0.007602584082633257,
-0.10121483355760574,
-0.3641304671764374,
-0.27699145674705505,
0.8011595606803894,
-0.25844988226890564,
0.12445420771... | |
in openFile(FILE \*\*in... and call it with &in. Ugly, yes. The more common practice is as the other answers says, returning a pointer...
A humorous quote found while making sure my fallible memory circuits were using the right words, "All problems in computer science can be solved by another level of indirection" --D... | [
-0.004441850818693638,
0.47840800881385803,
0.12635928392410278,
-0.010096476413309574,
-0.15941107273101807,
-0.15231844782829285,
0.2764893174171448,
-0.0342973954975605,
-0.19877074658870697,
-0.4635159969329834,
-0.3097245991230011,
0.28083163499832153,
-0.4719233810901642,
0.005769704... | |
I've been stuck on this for quite a while and I've searched the Internet far and wide for a solution... The connections in IB are setup correctly and I can open up my NSWindow in awakeFromNib like so:
```
NSApp activateIgnoringOtherApps:YES];
[popUp makeKeyAndOrderFront:nil];
```
with no problems. I can also call a... | [
-0.27816063165664673,
0.03193386644124985,
0.47237274050712585,
-0.3716186583042145,
-0.07367197424173355,
-0.07697877287864685,
0.4981715977191925,
-0.13448773324489594,
-0.0842985138297081,
-0.8417559266090393,
-0.284794420003891,
0.6280794739723206,
-0.14005231857299805,
0.2588784396648... | |
[self.popUp makeKeyAndOrderFront:nil];
GeronimoAppDelegate *appDel = (GeronimoAppDelegate *)[NSApp delegate];
[appDel.popUp makeKeyAndOrderFront:nil];
//Run the timer method
[self runBackTimer];
return noErr;
}
```
As you can see, I've tried two approaches to opening the window by referring to ... | [
-0.08351168036460876,
0.02311236783862114,
0.40691083669662476,
-0.18746420741081238,
-0.2142317146062851,
0.2929576337337494,
0.7404515743255615,
-0.18840478360652924,
-0.2565588057041168,
-0.6778553128242493,
-0.14242015779018402,
0.6515569090843201,
-0.18130695819854736,
0.3119048178195... | |
being a C function rather than an Objective-C instance method, doesn't have a notion of a "self" object. You've tried to work around this by declaring a `self` local variable, but it doesn't point to any object of interest. Instead, you've created a new and different object for it to point to, one that isn't connected ... | [
-0.05704742297530174,
0.14762148261070251,
0.29727309942245483,
0.10451274365186691,
-0.04570590704679489,
0.007281111087650061,
0.16379119455814362,
0.13504502177238464,
-0.33995890617370605,
-0.3477095067501068,
-0.2096037119626999,
0.20452627539634705,
-0.6077448725700378,
0.31194609403... | |
to the app delegate object which is instantiated in the NIB? Could you be later disconnecting it or reconnecting it by calling `-setDelegate:` or assigning to its `.delegate` property?
Typically, to integrate a C-style callback with an object-oriented program, you need to arrange to pass an object pointer into the C f... | [
0.024216309189796448,
-0.048977673053741455,
0.2643110156059265,
0.04204697161912918,
0.13564108312129974,
0.023616472259163857,
-0.10519072413444519,
-0.26150280237197876,
-0.1705210953950882,
-0.5075266361236572,
-0.5755568742752075,
0.5923735499382019,
-0.6724971532821655,
0.02073299884... | |
the appropriate type and assign `userData` to it (under ARC this requires a \_\_bridge cast). | [
0.02030780352652073,
0.0567789301276207,
0.28495219349861145,
-0.01467918325215578,
0.07377060502767563,
-0.11976178735494614,
0.07833755761384964,
-0.15641941130161285,
0.12653201818466187,
-0.902865469455719,
-0.46610647439956665,
0.4607434570789337,
-0.34515851736068726,
-0.017713801935... | |
I making an application to view videos form youtube, and I think it is very easy to write a code to make the user be able download the videos and save it in the documents folder of the application, my questions are:
1) is it legal to do this, and is there any concern of the application being rejected?
2) is it possib... | [
0.8477920293807983,
0.1398286521434784,
0.5014151930809021,
0.051058392971754074,
0.09390755742788315,
-0.4316224157810211,
0.16416506469249725,
-0.1538286805152893,
-0.4462122619152069,
-0.21237759292125702,
0.22232873737812042,
0.4273086488246918,
-0.04964113235473633,
0.2687194049358368... | |
a grey area. In general, you are not allowed to download copyrighted videos without paying for them. The official YouTube stance is rather interesting. This link tells you <http://support.google.com/youtube/bin/answer.py?hl=en&answer=56100> that it is **not supported** except in *one* instance, that is, if you are down... | [
0.598800778388977,
-0.09224194288253784,
0.4083715081214905,
0.15555132925510406,
-0.034713272005319595,
-0.4385662078857422,
0.08957566320896149,
0.16770964860916138,
-0.4960131049156189,
-0.08277511596679688,
-0.06840043514966965,
0.29042384028434753,
-0.2666425406932831,
0.3952680528163... | |
in a grey area. Your application may or may not be rejected. Organizations are cracking down on copyrighted videos up on websites like YouTube. However, YouTube does not explicitly *debar* your application. A cursory Google search will reveal that there are many applications which allow you to download YouTube videos. ... | [
0.7946000695228577,
-0.05205777287483215,
0.24785305559635162,
0.5186242461204529,
-0.006388592068105936,
-0.554642915725708,
0.228194922208786,
0.18825216591358185,
-0.4461190104484558,
-0.19775596261024475,
0.14708657562732697,
0.38426822423934937,
-0.17340457439422607,
0.322921425104141... | |
stuff without resorting to downloading a whole bunch of videos in your application. | [
0.6527596712112427,
-0.01177404634654522,
0.2964257001876831,
0.7069059014320374,
0.3399463891983032,
-0.4057978093624115,
0.31480324268341064,
0.3976250886917114,
-0.38417038321495056,
-0.05655193328857422,
0.035647522658109665,
0.3539842963218689,
-0.0017809150740504265,
0.12903492152690... | |
I have a listview that is loaded with a list of objects that contain an attribute called `AssigneeView` which holds the date that the entry was opened. The `listview's` `ItemTemplate` has a label named "lblHeader". What I want to do is loop through the `ListView`.Items and check each element's `AssigneeView` attribute,... | [
0.21155746281147003,
-0.11160165071487427,
0.5330223441123962,
0.0771980956196785,
-0.0875154510140419,
-0.16150030493736267,
-0.10737387090921402,
-0.14658887684345245,
-0.07310687005519867,
-0.690759003162384,
0.07307258248329163,
0.3021138310432434,
-0.23716290295124054,
0.4463986158370... | |
return a `bool`. So it would look something like
```
ForEach item in listview.Items
if(IsUnread(item.datamember.ticketID)) then
item.lblHeader.MakeBold
else
item.lblHeader.MakeNotBold
```
I'm not 100% on how to dig into the telerik control to get what I need to do this. Any suggestions?
UPDATE:
h... | [
-0.16022080183029175,
-0.1499011367559433,
0.7441469430923462,
-0.07098763436079025,
0.14909788966178894,
-0.19584393501281738,
0.5113272666931152,
-0.3085450530052185,
-0.052231062203645706,
-0.7808899879455566,
-0.23155681788921356,
0.630062460899353,
-0.22615770995616913,
0.371705383062... | |
lsvResultTickets.DataSource = data;
lsvResultTickets.DataBind();
if (data.Count == 0)
{
lblStatus.Text = "No tickets found."; | [
-0.09516660869121552,
-0.4794035851955414,
0.3002428114414215,
0.13234663009643555,
0.5731691718101501,
-0.00677426066249609,
0.31670698523521423,
0.03543967753648758,
-0.23985281586647034,
-0.5115959644317627,
-0.418277382850647,
0.33655989170074463,
-0.6134148836135864,
0.162199631333351... | |
}
else
{
foreach (var item in lsvResultTickets.Items)
{ | [
-0.12211356312036514,
-0.20191554725170135,
0.19850337505340576,
-0.29872927069664,
0.3040744364261627,
0.3804740011692047,
0.20314225554466248,
-0.2288731038570404,
-0.03840912878513336,
-0.506755530834198,
-0.21381045877933502,
0.45873263478279114,
-0.20618145167827606,
0.119236409664154... | |
var obj = item.DataItem as QT.FullTicket;
if (TicketIsUnread(obj.OriginalTicket.TicketID))
{
//??? | [
-0.2895461320877075,
-0.7066012024879456,
0.4058118760585785,
0.19404146075248718,
0.22263909876346588,
0.5057485699653625,
0.39546820521354675,
-0.017879875376820564,
-0.2767457664012909,
-0.6050187349319458,
-0.17820954322814941,
0.043755143880844116,
-0.544482409954071,
0.38426190614700... | |
}
}
}
}
```
Since I found no evidence, that there is something wrong with my code, I have posted a [Boost bugreport](https://svn.boost.org/trac/boost/ticket/6903). It was reproduced by other boost users as well, therefore I think it is actually a bug within boost or the ... | [
0.2837999165058136,
0.10336518287658691,
-0.016154704615473747,
-0.12739776074886322,
-0.06629785150289536,
-0.38873738050460815,
0.22937484085559845,
0.4906356632709503,
-0.13307689130306244,
-0.12379021942615509,
-0.25356337428092957,
0.5353749990463257,
-0.42838019132614136,
0.075335949... | |
By now there was no response from the Boost maintainer. I'll update this post when there is one.
**Update**
It seems like the g++ linker-plugin is causing the problem (Still I have no idea why). Therefore a possible work around is to disable the linker-plugin by using `-fno-use-linker-plugin`. | [
0.13565535843372345,
0.21474029123783112,
0.3839973509311676,
0.12162399291992188,
-0.2981725037097931,
-0.3021712899208069,
0.49362242221832275,
0.35576537251472473,
-0.19206638634204865,
-0.39784491062164307,
-0.24648046493530273,
0.7187938690185547,
-0.324741393327713,
0.089205190539360... | |
I have two click-events, that are nearly similar, but not quite. I am wondering how to refactor them best:
```
$('.remove_fields.dynamic').live('click', function(e) {
var $this = $(this);
var after_removal_trigger_node = $this.closest(".nested-fields").parent();
trigger_removal_callback($this);
e.pre... | [
0.24968074262142181,
0.048304781317710876,
0.5200791358947754,
-0.4727771580219269,
0.29434624314308167,
-0.01696821302175522,
0.4679160714149475,
-0.15345370769500732,
-0.08842425048351288,
-0.6306915879249573,
-0.31943681836128235,
0.4997180700302124,
-0.4163975417613983,
0.3793298304080... | |
a fair bit of overlap. I am wondering what the best/nicest way would be to refactor this code.
Do a class check in the `.remove_fields` click function.
```
$('.remove_fields').click(function(e) {
var $this = $(this);
var after_removal_trigger_node = $this.closest(".nested-fields").parent();
trigger_removal... | [
0.14517302811145782,
-0.057613495737314224,
0.44620659947395325,
-0.26954975724220276,
0.4476913511753082,
-0.23355773091316223,
0.2755434513092041,
-0.3371991813182831,
-0.1989937722682953,
-0.4654148519039154,
-0.35483992099761963,
0.6281741261482239,
-0.35882002115249634,
0.553048789501... | |
I have a URL in this format `http://0.0.0.0:3000/#&ui-state=dialog`. I want to check for the existence of `ui-state` so I can render approprietly a page. I tried this
```
params.has_key?(:'ui-state')
```
But it did not work.
How can I check for the existence of ui-state?
---
Solution
I am using jQuery mobile. Wh... | [
0.15703555941581726,
0.32564619183540344,
0.8265041708946228,
0.05804571881890297,
-0.21657134592533112,
0.012946134433150291,
0.3683381676673889,
0.039095278829336166,
-0.23044028878211975,
-0.8551751971244812,
-0.08006588369607925,
0.21987436711788177,
-0.04591672867536545,
0.53746885061... | |
jQuery and not a real URL parameter, it won't appear in `params` in Rails. Instead you'll need to parse it out of the `request.url`:
```
ui_state = /&ui-state=([a-z]+)$/.match(request.url)
puts ui_state[1]
```
### Update2
Since the `&ui-state` follows the url hash `#`, it will not be available in the `request.url`.... | [
-0.12634067237377167,
0.03323844075202942,
0.7278147339820862,
0.12002474069595337,
-0.19256390631198883,
-0.23204496502876282,
0.042651738971471786,
0.22321127355098724,
-0.04672541469335556,
-0.7162162661552429,
-0.21648520231246948,
0.22696419060230255,
-0.23413094878196716,
0.041669934... | |
Basic question!
I have 2 tables
**PRODUCE**
```
+-----+--------------+
| id | fruit_name |
+--------------------+
| 1 | Apple |
| 2 | Banana |
| 3 | Carrot |
+-----+--------------+
```
**VARIETIES**
```
+-----+---------------+----------------+
| id | fk_f... | [
-0.4158501923084259,
0.26470518112182617,
0.21731440722942352,
0.18731722235679626,
-0.23173300921916962,
0.46517011523246765,
0.08746352046728134,
-0.5846123099327087,
-0.060343652963638306,
-0.5515005588531494,
-0.26243123412132263,
0.3593670427799225,
0.10996218025684357,
-0.24190591275... | |
1 | Cox |
| 2 | 1 | Braeburn |
| 3 | 2 | Chester |
| 4 | 3 | [
-0.48158538341522217,
0.2799937427043915,
0.29249271750450134,
-1.1729120016098022,
-0.3087770640850067,
0.12588022649288177,
0.28179657459259033,
-0.18205526471138,
-0.20112235844135284,
-0.4481930136680603,
0.13657231628894806,
-0.1728866696357727,
-0.3989808261394501,
0.3260948657989502... | |
| Kotaka |
| 5 | 3 | Imperial |
| 6 | 3 | Oneal |
+-----+---------------+----------------+
```
I'd like to output a list of varieties per fruit e.g.
```
APPLE - Cox, Braeburn
BANANA - Chester
CARROT - Kotaka, Imperial, Oneal
```
My current | [
-0.2707323431968689,
-0.027814384549856186,
0.09011964499950409,
-0.2527596056461334,
-0.14154401421546936,
1.036394476890564,
-0.33158063888549805,
0.4638265371322632,
-0.27552735805511475,
-0.6863794326782227,
-0.02368425577878952,
-0.05861987918615341,
-0.1930125653743744,
0.30699458718... | |
code is
```
$query = "SELECT * FROM produce, varieties WHERE produce.id = varieties.fk_fruit_id";
$result = mysql_query($query) or die('Error : ' . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$produce_fruit_code = $row['fruit_code'];
$variety_name = $row['variety_name']; ... | [
-0.01715165749192238,
-0.13384395837783813,
0.25115132331848145,
-0.004257545806467533,
0.064446359872818,
0.557099461555481,
-0.021181192249059677,
0.33730003237724304,
-0.21611052751541138,
-0.5106757283210754,
0.024784384295344353,
-0.16697154939174652,
-0.17590314149856567,
0.081281915... | |
= "SELECT * FROM produce, varieties WHERE produce.id = varieties.fk_fruit_id";
$result = mysql_query($query) or die('Error : ' . mysql_error());
$produce_fruit_code = "";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
if ($produce_fruit_code != $row['fruit_code'])
{
$produce_fruit_code = $row... | [
0.03505439683794975,
0.1338368058204651,
0.08240599185228348,
-0.5117636919021606,
-0.14808157086372375,
0.5860788226127625,
0.19056211411952972,
-0.18184687197208405,
-0.35701972246170044,
-0.2766662538051605,
-0.3588505685329437,
0.46324658393859863,
-0.40922310948371887,
0.2456641197204... | |
I am a student learning C++, and I am trying to understand how null-terminated character arrays work. Suppose I define a char array like so:
```
char* str1 = "hello world";
```
As expected, `strlen(str1)` is equal to 11, and it is null-terminated.
Where does C++ put the null terminator, if all 11 elements of the ab... | [
-0.18245744705200195,
0.14509789645671844,
0.06168993562459946,
-0.21745391190052032,
-0.12185710668563843,
0.1863529235124588,
0.3503340780735016,
0.13791564106941223,
-0.2617996335029602,
-0.273311585187912,
-0.2608925402164459,
0.33833056688308716,
-0.18796797096729279,
0.01042411942034... | |
do the following:
```
// Create a new char array
char* str2 = (char*) malloc( strlen(str1) );
// Copy the first one to the second one
strncpy( str2, str1, strlen(str1) );
// Output the second one
cout << "Str2: " << str2 << endl;
```
This outputs `Str2: hello worldatcomY╗°g♠↕`, which I assume is C++ reading the me... | [
-0.3578076660633087,
0.2607661783695221,
0.48148542642593384,
-0.44881105422973633,
0.13535380363464355,
0.1547938883304596,
0.4634145498275757,
-0.033348433673381805,
-0.12249153107404709,
-0.5454401969909668,
-0.4354274570941925,
0.40125060081481934,
-0.2722892761230469,
0.28055861592292... | |
expected.
But doesn't writing to `str2[11]` imply that we are writing outside of the allocated memory space of `str2`, since `str2[11]` is the 12th byte, but we only allocated 11 bytes?
Running this code does not seem to cause any compiler warnings or run-time errors. Is this safe to do in practice? Would it be bett... | [
-0.011341569945216179,
0.11206823587417603,
0.1882433444261551,
-0.1615421622991562,
0.03759118914604187,
0.07742428034543991,
0.521980345249176,
-0.2720000445842743,
-0.21239733695983887,
-0.42324116826057434,
-0.1800767481327057,
0.578244149684906,
-0.2638671398162842,
-0.500712811946868... | |
common mistake new C programmers make. When allocating the storage for a `char*` you need to allocate the number of characters + 1 more to store the `\0`. Not allocating the extra storage here means this line is also illegal
```
// Null-terminate the second one
str2[strlen(str1)] = '\0';
```
Here you're actually wri... | [
-0.00949089229106903,
0.26631513237953186,
0.20763908326625824,
-0.11712633818387985,
0.3537195920944214,
-0.00804219488054514,
0.4782487750053406,
-0.039634570479393005,
-0.29828014969825745,
-0.42352792620658875,
-0.1396208554506302,
0.407601535320282,
-0.23360462486743927,
0.06365959346... | |
this is as follows
```
size_t size = strlen(str1) + sizeof(char);
char* str2 = (char*) malloc(size);
strncpy( str2, str1, size);
// Output the second one
cout << "Str2: " << str2 << endl;
```
In this example the `str2[size - 1] = '\0'` isn't actually needed. The `strncpy` function will fill all extra spaces with th... | [
-0.30225613713264465,
-0.10808368027210236,
0.4659586548805237,
-0.4842529892921448,
0.06481178104877472,
0.11568208783864975,
0.2259005308151245,
-0.3228861093521118,
-0.20213517546653748,
-0.4185875654220581,
-0.429985910654068,
0.4136866629123688,
-0.30021438002586365,
0.048383280634880... | |
I am facing attachment error with Amazon SES service. Normal `pdf` or `jpg` files are attached properly. But when i attach a `.ics` file which is a calender file. I got this error.
```
554 Transaction failed: Illegal filename 'file_name.ics'
```
I am using `aws-ses` gem with `rails 3.2.2`
Is there any limitation fr... | [
0.27760422229766846,
0.2573429346084595,
0.16190899908542633,
0.0391213595867157,
-0.11366026103496552,
-0.15789437294006348,
0.3143104314804077,
-0.20047691464424133,
-0.05892767012119293,
-0.5631266236305237,
-0.08259376138448715,
0.5831916928291321,
-0.29848453402519226,
0.3007738292217... | |
in my case it was having `.ics` extension.
So i have to change the code from this.
```
attachments["file_name.ics"] = @model.to_ical
```
to this.
```
attachments["file_name.ics"] = {:mime_type => 'text/calendar',
:content => @model.to_ical}
```
and it solved my proble... | [
-0.04370921105146408,
0.04720962047576904,
0.4013504385948181,
-0.10179641097784042,
0.1390303522348404,
-0.18760083615779877,
-0.1529565155506134,
0.04098498821258545,
-0.38632550835609436,
-0.5628963708877563,
0.028697842732071877,
0.36659279465675354,
-0.42401039600372314,
0.46929213404... | |
I am using Android 2.3.1 project to get a current location using LocationManager.GPS\_PROVIDER.
This is my code
```
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager locManager = (LocationManager)this.getSystemS... | [
0.31838345527648926,
-0.05197902023792267,
0.7554372549057007,
-0.2701490521430969,
0.5707954168319702,
0.24166861176490784,
0.45581385493278503,
-0.3879576623439789,
0.08757999539375305,
-0.8828495144844055,
-0.21993346512317657,
0.331500768661499,
-0.39211976528167725,
0.2031986117362976... | |
double latitude = loc.getLatitude();
double longitude = loc.getLongitude();
String locationstr = "Latitude = " + latitude + " longitude = " +longitude;
Log.d("BTILocation", locationstr);
}
}
@Override
public void onProviderDisabled(String provider) {
... | [
0.3046168386936188,
0.033378515392541885,
0.5584917068481445,
-0.2023719847202301,
0.4868561923503876,
-0.012220602482557297,
0.6488311886787415,
-0.06530485302209854,
0.040526729077100754,
-0.4898890554904938,
-0.6419720649719238,
0.40097495913505554,
-0.21762174367904663,
0.3708962202072... | |
Log.w("BTILocation", "GPS is Disabled");
}
@Override
public void onProviderEnabled(String provider) {
Toast.makeText(getApplicationContext(), "GPS Enabled", Toast.LENGTH_SHORT).show();
Log.w("BTILocation", "GPS is Enabled");
}
@Override
public void onStatusChanged(String provid... | [
0.3957817554473877,
0.21910440921783447,
0.529813826084137,
-0.07801982760429382,
0.5375282168388367,
0.11352750658988953,
0.49528154730796814,
-0.33271855115890503,
-0.09534317255020142,
-0.9010546803474426,
-0.5048458576202393,
0.8242899179458618,
-0.37998056411743164,
0.2135123610496521... | |
logcat -
```
E/GpsLocationProvider( 75): native_start failed in startNavigating()
```
The location object returned in onLocationChanged(location loc) is always null on 2.3.1.
The same code works fine in Android 2.1 and 4.0. Please please help me solve this issue, I have tried google search but I couldn't find th... | [
-0.15434537827968597,
0.01687627099454403,
0.8939605355262756,
0.040960464626550674,
0.28235292434692383,
-0.18863573670387268,
0.6074483394622803,
-0.04014937952160835,
-0.0831444039940834,
-0.5716828107833862,
-0.2534075677394867,
0.9730449318885803,
-0.4765392541885376,
0.09967143833637... | |
$images = $_FILES["fileUpload"]["tmp_name"];
$new_images = "thumbnails_".$_FILES["fileUpload"]["name"];
copy($_FILES["fileUpload"]["tmp_name"],"Photos/".$_FILES["fileUpload"]["name"]);
$width=200; //*** Fix Width & Heigh (Autu caculate) ***//
$size=GetimageSize($images);
... | [
0.32194310426712036,
-0.03827137127518654,
0.7121615409851074,
-0.24643298983573914,
0.061389386653900146,
0.2607753872871399,
0.3508755564689636,
-0.5478752255439758,
-0.3061889410018921,
-0.5822880268096924,
-0.45627447962760925,
0.9406651854515076,
-0.44851452112197876,
-0.0690790861845... | |
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"Photos/".$new_images);
... | [
0.005914775189012289,
-0.3619006872177124,
0.7193410992622375,
-0.1456959843635559,
0.09383272379636765,
0.15980857610702515,
0.04922250658273697,
-0.23600883781909943,
-0.22085121273994446,
-0.7233619689941406,
-0.39889106154441833,
0.536210834980011,
-0.6274574398994446,
0.21645392477512... | |
print $data["foo"];
echo"$myvar";
mysql_query("UPDATE users SET userpictureaddress = 'http://www.litsdevelopment.com/litsapplication/userimages/MATEUS' WHERE username = 'Mateus' ");
}
}
```
But as @JohnConde points out, it looks like you really mean $\_SESSION if you are trying to r... | [
0.05374578386545181,
0.26058098673820496,
0.21087050437927246,
-0.44948217272758484,
0.07089970260858536,
-0.1484474241733551,
0.6771461367607117,
0.1122693121433258,
-0.21734866499900818,
-0.5195438861846924,
-0.2202935665845871,
0.7226138710975647,
-0.3127894103527069,
0.2916437983512878... | |
I have an **ajax navigation** similar like [here](http://www.queness.com/resources/html/ajax/index.php#page4).
now if a menu is clicked window.location.hash is added like this **#about**
**i want to REmove the hash (#) so that people can easily copy and share the link naturally.**
How this can be done in april 2012 ... | [
0.2501867115497589,
0.1663210242986679,
0.47613197565078735,
-0.020466094836592674,
-0.2252805531024933,
-0.3915453553199768,
0.3407422602176666,
0.151263028383255,
-0.4326496124267578,
-0.8611590266227722,
0.16098104417324066,
0.40818318724632263,
0.01011243462562561,
0.20236173272132874,... | |
a bit more of the issues involved, do look up the rule of 3, or as it's now known with C++11, the rule of 5. | [
0.2710675001144409,
0.0866655632853508,
0.1050482764840126,
-0.20476199686527252,
-0.10468732565641403,
-0.47749578952789307,
0.08353298902511597,
-0.14054560661315918,
-0.23935306072235107,
-0.12559331953525543,
-0.09467888623476028,
0.6764811277389526,
-0.26863300800323486,
-0.2577461600... | |
I have a webpage written in HTML. I have a dropdown list that is populated by a database utilizing a MySQL query:
```
<SELECT NAME = "Participant" STYLE = "WIDTH: 187" TITLE="Begin typing participant last name for fast searching." required>
<OPTION SELECTED VALUE = "">Select Participant...</OPTION>
<?PHP
$allParti... | [
0.15655317902565002,
-0.08752100169658661,
0.6752832531929016,
-0.12584280967712402,
-0.23440536856651306,
0.339860737323761,
0.19420695304870605,
-0.18470947444438934,
-0.0567174032330513,
-0.8963050246238708,
-0.16922737658023834,
0.2609356939792633,
-0.1987539529800415,
0.22483263909816... | |
echo $value->get_first_name()," ",$value->get_last_name();
echo "</OPTION>";
}
?>
</SELECT>
```
The getall\_participants() looks like:
```
function getall_participants () {
connect();
$query = "SELECT * FROM dbParticipants ORDER BY last_name";
$result = mysql_query ($query);
$theParticipant = array();
w... | [
-0.0779208093881607,
0.1249588206410408,
0.6128964424133301,
-0.30979272723197937,
-0.07764755934476852,
0.296147882938385,
0.3149643838405609,
-0.688899040222168,
-0.26843327283859253,
-0.36108678579330444,
-0.32318979501724243,
0.3662490248680115,
-0.3593735098838806,
0.06336351484060287... | |
= date('Y-m-d');
$participants = getall_dbParticipantEntry_byDate($dt);
foreach($participants as &$value) {
$a = $a.$value.", ";
}
echo "<INPUT TYPE='text' NAME='Participants' STYLE='WIDTH:50px;' TITLE='Participants' ";
echo "VALUE='[", $a.' ', "]'/>";
?>
```
That getall\_dbParticipantEnt... | [
-0.02479754202067852,
-0.16428396105766296,
0.6830614805221558,
-0.36082834005355835,
-0.05832817032933235,
0.18216504156589508,
0.3215779960155487,
-0.5625414252281189,
-0.4373350441455841,
-0.16810089349746704,
-0.45149698853492737,
0.34442880749702454,
-0.21647530794143677,
0.3691709041... | |
individually, when they're both on the same webpage (like I meant them to be), only the one that comes first runs. I tested this by switching them in and out. They both complete their designated tasks, but only when alone on the page.
How can I get them both to run and populate their respective fields?
Thanks so much.... | [
0.14846734702587128,
0.12556244432926178,
0.5356189608573914,
-0.05626850575208664,
-0.23336921632289886,
-0.022874681279063225,
0.15798978507518768,
-0.44248202443122864,
-0.286324679851532,
-0.7588637471199036,
-0.19184274971485138,
0.6998344659805298,
-0.24804151058197021,
0.00789390597... | |
// .. do some queries ..
mysql_query($sql, $res);
mysql_close($res )
}
function f2 ()
{
$res = mysql_connect(...);
// .. do some queries ..
mysql_query($sql, $res);
mysql_close($res )
}
```
Edit:
From php.net:
Be careful when using multiple links to connect to same database (with sam... | [
0.022328827530145645,
0.11342433840036392,
0.732036828994751,
-0.1672147810459137,
0.14647820591926575,
-0.176713228225708,
0.34441468119621277,
-0.23506823182106018,
-0.1850641816854477,
-0.6244243383407593,
-0.19877678155899048,
0.5228478312492371,
-0.3411136865615845,
0.4249066412448883... | |
the same.
Had lot of trouble figuring it out, since in <=4.3.6 there was a bug which didn't close the connection, but after the patch to >=4.3.7, all my application broke down because of a single script that did this. | [
0.10811606794595718,
0.13153226673603058,
0.31224125623703003,
0.02158442698419094,
-0.06892063468694687,
0.016374092549085617,
0.7118603587150574,
0.28830358386039734,
0.04344945773482323,
-0.4819043278694153,
0.14867669343948364,
0.5904471278190613,
-0.2408265322446823,
0.379560381174087... | |
Hello,
```
if ($_SESSION["selCurrency"] = "USD") { $_SESSION["currencyidx"] = 1; }
if ($_SESSION["selCurrency"] = "CAD") { $_SESSION["currencyidx"] = 2; }
if ($_SESSION["selCurrency"] = "EUR") { $_SESSION["currencyidx"] = 4; }
```
No matter what I do, my
$\_SESSION["currencyidx"]
is ALWAYS the last on... | [
0.04383433610200882,
0.3936246335506439,
0.6520372629165649,
-0.06554693728685379,
0.11329618841409683,
0.09042894840240479,
0.2926121652126312,
0.04821561276912689,
-0.2953281104564667,
-0.5763018727302551,
-0.2761429250240326,
0.897506833076477,
-0.22574591636657715,
0.372546911239624,
... | |
I'm trying to send mail via the PHP mail() function which as far as I have understood uses sendmail to deliver the goods. Now my problem is that mail() returns true but there is not even a trace of the mail in my mailbox (yea i checked spam too).
So i tried to send some mail manually from the terminal but the problem ... | [
0.5209733843803406,
0.45101842284202576,
0.24452359974384308,
-0.13835272192955017,
-0.5209212899208069,
0.1082400307059288,
0.7475243806838989,
-0.08689635246992111,
0.04031939432024956,
-0.6147270798683167,
-0.1035131886601448,
0.31639236211776733,
-0.17806781828403473,
0.139146298170089... | |
no error, sendmail logs that the mail was sent successfully in /var/log/mail.log:
```
Apr 7 01:16:21 Andreas-PC-Ubuntu sendmail[11759]: q36NGIfD011759: from=andreas, size=5, class=0, nrcpts=1, msgid=<201204062316.q36NGIfD011759@home.hagenz.com>, relay=andreas@localhost
Apr 7 01:16:21 Andreas-PC-Ubuntu sm-mta[11760]:... | [
-0.17942917346954346,
0.04178604483604431,
0.5742201209068298,
0.010911179706454277,
-0.14988429844379425,
0.40864214301109314,
0.6735085248947144,
-0.2600053548812866,
-0.48522740602493286,
-0.33898037672042847,
-0.43424099683761597,
0.1977493315935135,
-0.4195552468299866,
0.148221984505... | |
use an SMTP relay/smarthost? If not, what happens if you configure it to use your ISP's, employer's, or other hosting provider's server? | [
0.5204934477806091,
-0.3203587532043457,
0.01083059050142765,
0.32393211126327515,
0.2922676205635071,
-0.3756416440010071,
0.31978610157966614,
0.205902561545372,
-0.3125987946987152,
-0.41466224193573,
-0.23351334035396576,
-0.11358053237199783,
-0.5451847910881042,
-0.015162579715251923... | |
I created an APP on Facebook and using graph API explorer, I selected my app from app drop down box, requested access token with manage\_pages, offline\_access and publish\_stream permissions.
Using this access token, I was successfully able to post message on page using `restfb` APIs but when I log out, it starts thr... | [
0.047211904078722,
0.11255168169736862,
0.48281073570251465,
0.05419822409749031,
-0.0724778100848198,
0.26891180872917175,
0.5098480582237244,
-0.20528903603553772,
-0.33319228887557983,
-0.8369765877723694,
0.07467389851808548,
0.36654600501060486,
-0.2559016942977905,
0.3718802928924560... | |
and the user must login to facebook once the
> token has expired.
Otherwise, it is possible to request an access token with a longer expiration. Here are the directions: <https://developers.facebook.com/roadmap/offline-access-removal/#extend_token> | [
0.09280941635370255,
-0.19507569074630737,
0.797538161277771,
-0.025641703978180885,
0.44347649812698364,
-0.42422592639923096,
0.3097394108772278,
0.013350474648177624,
-0.40333297848701477,
-0.4592365026473999,
-0.43387365341186523,
0.1930481344461441,
0.05089643970131874,
0.088053762912... | |
why the next python line is not a syntax error? If it is really not then how can I use it and in which situation it will be useful?
```
a= range(10)[1:3]=[2,3]
```
Python supports multiple assignments on the same line:
```
>>> a = b = c = 2
>>> a
2
>>> b
2
>>> c
2
```
Since you are assigning a first to a list(a m... | [
-0.021246785297989845,
-0.12801599502563477,
0.077304407954216,
-0.13172490894794464,
-0.2609585225582123,
0.035308703780174255,
0.15618649125099182,
-0.3490263521671295,
-0.17094998061656952,
-0.5728826522827148,
-0.22867070138454437,
0.4709434509277344,
-0.4806508719921112,
-0.2169689983... | |
error.
```
>>> a = 'foo' = 'bar'
File "<input>", line 1
SyntaxError: can't assign to literal
>>> a = {}['foo'] = 'bar'
>>> a
'bar'
```
Interestingly, a line like this still throws an error, because you are attempting to assign the values 3 and 4 to the literal values 1 and 2.
```
>>> a = [1, 2] = [3, 4]
File "... | [
-0.013324004597961903,
0.08784184604883194,
0.10293587297201157,
-0.3424759805202484,
-0.22519592940807343,
0.1787402480840683,
0.5657861232757568,
-0.30347540974617004,
-0.01514327060431242,
-0.5547823905944824,
-0.3150322139263153,
0.633247435092926,
-0.5140533447265625,
-0.1815330088138... | |
literal values in the list.
Additionally, the lines
```
>>> a = [[], []] = [{}, {}]
>>> a
[{}, {}]
```
and
```
>>> a = [b, c] = 3, 4
>>> b
3
>>> c
4
```
Are valid, the first one because the inner lists and dicts are both mutable and iterable, and the second one because you are assigning 3, and 4 to the variables... | [
-0.044784460216760635,
0.23599492013454437,
0.5660570859909058,
-0.05577689781785011,
-0.11643968522548676,
0.28278470039367676,
0.2206868678331375,
-0.44380658864974976,
-0.04749228060245514,
-0.23800283670425415,
-0.23243297636508942,
0.5144035816192627,
-0.39815831184387207,
-0.01413965... | |
a, b = b, a = a, b = b, a
>>> a
'b'
>>> b
'a'
>>> a, b = b, a = b, a
>>> a
'a'
>>> b
'b'
```
It's confusing, but the way I interpret this is that a and b are not re-evaluated / assigned new values until the statement is finished, so the assignment that matters is the one farthest to the right. If the last statement i... | [
0.025750430300831795,
0.32677745819091797,
0.001060278620570898,
0.15360775589942932,
-0.1087459847331047,
0.22239191830158234,
0.1410847157239914,
-0.26475924253463745,
-0.12253575772047043,
-0.2511662542819977,
-0.4242575764656067,
0.3081406056880951,
-0.17851656675338745,
0.273380309343... | |
I want to force the Chrome debugger to break on a line *via code*, or else using some sort of comment tag such as something like `console.break()`.
You can use `debugger;` within your code. If the developer console is open, execution will break. It works in firebug as well. | [
0.41803017258644104,
0.2393123060464859,
-0.060249846428632736,
-0.12622423470020294,
-0.14826379716396332,
-0.18568211793899536,
0.42194023728370667,
-0.004876091144979,
0.05769389495253563,
-0.6096246242523193,
-0.38216909766197205,
0.7500619888305664,
-0.5759103894233704,
0.030314801260... | |
In my mind, this seemed straigtforward...right up to the point that I sat down and started typing.
Anyway, I've been tasked with writing a method that will find "tags" in a String, and replace them appropriately, outputting the resultant string. The function declaration would look something like:
```
public String do... | [
0.10729579627513885,
-0.025129025802016258,
0.4092234969139099,
-0.03668758273124695,
0.2487552911043167,
-0.003389374352991581,
0.030410390347242355,
-0.4072602689266205,
0.1916414052248001,
-0.6220129728317261,
-0.12221899628639221,
0.7707631587982178,
-0.3603813350200653,
0.155203148722... | |
via `replacementData.get(I)`
Anyway, I'd like to do this efficiently. I'm just not sure how to go about it. I took a look at Pattern and Matcher, and I don't think that that was the right route. I'd prefer not to use String.indexOf and stuff like that, because it is inefficient (isn't it?).
Thanks for the advice!
The... | [
0.17882509529590607,
-0.1784878820180893,
0.3189528286457062,
0.08859629929065704,
0.04003029689192772,
-0.07473037391901016,
0.1575596183538437,
-0.19519895315170288,
-0.08768133819103241,
-0.7794934511184692,
0.1472426801919937,
0.6835102438926697,
-0.5800119638442993,
0.0485139600932598... | |
need to do are described in the javadoc for [appendReplacement method](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Matcher.html#appendReplacement%28java.lang.StringBuffer,%20java.lang.String%29)
Example Code:
```
String str = "abc<<1>>def<<2>>ghi";
java.util.Map<Integer,String> replacementMap = new j... | [
0.31844744086265564,
0.11788399517536163,
0.3544931411743164,
-0.3689332902431488,
0.4549940526485443,
0.22028368711471558,
0.3707970678806305,
-1.03227961063385,
0.14333219826221466,
-0.5270560383796692,
-0.46843189001083374,
0.3573704659938812,
-0.6586665511131287,
-0.1630478799343109,
... | |
I'm creating a memoization class.
Each class memoizes a function type and has the following definition:
```
class MemoizedFunction1[-T1, +R](f: T1 => R) {
private[this] val cache = mutable.Map[T1, R]()
def apply(t: T1): R = cache.getOrElseUpdate(t,f(t))
}
```
This compiles nicely and works as expected.
H... | [
-0.2219102382659912,
-0.02356230467557907,
0.3197956383228302,
0.03922600671648979,
-0.023098329082131386,
0.1127614751458168,
0.43304216861724854,
-0.5965567827224731,
-0.03728318214416504,
-0.6961978077888489,
-0.27668529748916626,
0.6534661650657654,
-0.4508459270000458,
0.2628740668296... | |
all of it, but this is addressed in section 4.5 (Variance Annotations) of the [Scala Language Specification 2.9](http://www.scala-lang.org/docu/files/ScalaReference.pdf) on page 45
> *References to the type parameters in object-private or object-protected values, variables, or methods (§5.2) of the class are not check... | [
0.28935396671295166,
-0.10416579246520996,
0.5202161073684692,
-0.15875406563282013,
-0.035403791815042496,
-0.09491045773029327,
0.1548338383436203,
-0.39921581745147705,
-0.26436352729797363,
-0.11634333431720734,
-0.030496325343847275,
0.5258519649505615,
-0.5258810520172119,
0.18197578... | |
it makes sense since if it is not object private or protected the contravariant return type could leak outside the object and cause a runtime error. | [
-0.14944356679916382,
-0.0043646302074193954,
-0.06402833014726639,
0.017095981165766716,
0.1640748530626297,
-0.3278014063835144,
0.4629742205142975,
0.08133400231599808,
0.1456504613161087,
-0.1903539001941681,
-0.18608804047107697,
0.3622722923755646,
-0.23389434814453125,
0.36393910646... | |
I am trying to program a robot to move. The robot moves based on where currently is. There are four places where it can be:
```
LOCATION1 Motion Plan is like so,
5 6
3 4
1 2
Initial positon is (x1,y1)
This gets coded as (x1,y1)->(x1+dx,y1)->(x1,y1+dy)->(x1+dx,y1+dy) ... and so on
LOCATION2 Motion Plan is like so,
5 3... | [
-0.05809983238577843,
-0.008039271458983421,
0.9132406711578369,
-0.11321894079446793,
0.05075041204690933,
0.5493415594100952,
0.19884781539440155,
-0.38251644372940063,
-0.19943593442440033,
-0.7958842515945435,
-0.20691131055355072,
0.20196762681007385,
0.07930675894021988,
0.2146082669... | |
(x1,y1)->(x1,y1+dy)->(x1-dx,y1)->(x1-dx,y1+dy) ... and so on
```
I am struggling to come up with a good pythonic way to code this. I am thinking on the lines of defining 4 different next move rules and then having a bunch of if statements that choose the correct rules
Has someone done something similar... Is there a... | [
0.1257035732269287,
-0.08440400660037994,
0.3600553572177887,
-0.3043312132358551,
-0.030811693519353867,
0.06300932914018631,
0.3386285901069641,
-0.6572486758232117,
-0.2636748254299164,
-0.5129398703575134,
-0.09303944557905197,
0.5033747553825378,
-0.42683497071266174,
-0.1545458883047... | |
while True:
... repeater = itertools.repeat(counter.next(), steps)
... for item in repeater:
... yield item
...
>>> def motion_plan(x_plan, y_plan, steps=6):
... while steps > 0:
... yield (x_plan.next(), y_plan.next())
... steps -= 1
...
>>> for pos in moti... | [
0.07361463457345963,
-0.24920664727687836,
0.9244837760925293,
0.015722546726465225,
0.30251526832580566,
0.3960486650466919,
0.10992582142353058,
-0.7626782655715942,
-0.1807519793510437,
-0.3874340355396271,
-0.1280694305896759,
0.4419330954551697,
0.0013620902318507433,
-0.1575904935598... | |
print pos
...
('x1', 'y1')
('x1+dx', 'y1')
('x1', 'y1+dy')
('x1+dx', 'y1+dy')
('x1', 'y1+dy+dy')
('x1+dx', 'y1+dy+dy')
```
I was unsure how much flexibility you needed with this, you could reduce the complexity even further if you want to remove some flexibility. Additionally you almost certainly wouldn't be using s... | [
0.14072559773921967,
-0.09464240074157715,
0.4389801323413849,
-0.006938316859304905,
0.01665547303855419,
0.28887978196144104,
-0.14939314126968384,
-0.6301030516624451,
-0.4277486801147461,
-0.4059005081653595,
-0.24620817601680756,
0.29501524567604065,
-0.15366776287555695,
-0.461828559... | |
1)
3 (-1, 0)
4 (-1, 1)
5 (-2, 0)
6 (-2, 1)
```
Should correspond pretty clearly to this:
```
LOCATION4 Motion Plan is like so,
6 4 2
5 3 1
```
I believe that the motion plans would be as follows:
```
Location1 = motion_plan(alternator(0, 1), increasor(0, 1))
Location2 = motion_plan(increasor(0, -1), alternator(0,... | [
-0.099542036652565,
-0.07453057914972305,
0.9979385137557983,
-0.10503843426704407,
0.32959917187690735,
0.39491865038871765,
-0.4560992121696472,
-0.5816284418106079,
-0.2952156066894531,
-0.3028867840766907,
0.08644343912601471,
0.31165850162506104,
-0.1864926815032959,
-0.07885949313640... | |
I've written a script to generate some XML, im using a very basic method to save the results of the XML to a file:
```
<?php
// start the output buffer to cache the content
ob_start();
//SOME PHP CODE HERE TO GENERATE CONTENTS ON THE FILE
$cachefile = "results.xml";
// open the cache file for writing
$fp = fopen($ca... | [
0.3134925961494446,
0.3845456838607788,
0.7279770374298096,
-0.2597244381904602,
0.06358028948307037,
0.13606546819210052,
0.17793229222297668,
-0.13111358880996704,
-0.05288809537887573,
-0.8123148083686829,
-0.1400260180234909,
0.28262555599212646,
-0.19297760725021362,
-0.07953473925590... | |
and run it as a cron job the script runs and the output is generated by not saved to a file.
Any ideas why?
I know that this could be made more elegant(and the names for my methods are awful!), but maybe something like this?
```
>>> import itertools
>>> def alternator(*values):
... return itertools.cycle(values)
... | [
0.37605270743370056,
0.01812829077243805,
0.4999300539493561,
-0.1783590167760849,
0.010409890674054623,
0.2545057237148285,
0.3659347593784332,
-0.31079423427581787,
-0.16775313019752502,
-0.4647442400455475,
0.10410913825035095,
0.8723184466362,
-0.2777954638004303,
0.18393860757350922,
... | |
for item in repeater:
... yield item
...
>>> def motion_plan(x_plan, y_plan, steps=6):
... while steps > 0:
... yield (x_plan.next(), y_plan.next())
... steps -= 1
...
>>> for pos in motion_plan(alternator('x1', 'x1+dx'), increaser('y1', '+dy'): #Location 1 motion plan
... prin... | [
-0.061363816261291504,
-0.5028594136238098,
0.5798506140708923,
0.08642398566007614,
0.22330932319164276,
0.5262699127197266,
-0.09106317162513733,
-0.8055355548858643,
-0.4350079894065857,
-0.5702372193336487,
-0.15981517732143402,
0.31752803921699524,
-0.11737922579050064,
0.014140238054... | |
want to remove some flexibility. Additionally you almost certainly wouldn't be using strings for this, I just thought that it was the easiest way to demonstrate the idea. If you use numbers, then something like this:
```
>>> count = 0
>>> for pos in motion_plan(increaser(0, -1), alternator(0, 1)): #location 4 motion p... | [
0.22282296419143677,
-0.2279253602027893,
0.8746023774147034,
-0.0012854232918471098,
0.35223081707954407,
0.19670188426971436,
-0.3889380097389221,
-0.5118110179901123,
-0.4776468873023987,
-0.43085741996765137,
0.11165826767683029,
0.3573692739009857,
-0.08557382971048355,
-0.12928991019... | |
as follows:
```
Location1 = motion_plan(alternator(0, 1), increasor(0, 1))
Location2 = motion_plan(increasor(0, -1), alternator(0, -1))
Location3 = motion_plan(alternator(0, -1), increasor(0, 1))
Location4 = motion_plan(increasor(0, -1), alternator(0, 1))
``` | [
-0.1938263177871704,
0.009152554906904697,
0.8542999625205994,
-0.03878046199679375,
0.3133299648761749,
0.375299870967865,
-0.5541419386863708,
-0.6005289554595947,
-0.12883076071739197,
-0.25489938259124756,
0.12050239741802216,
0.2240622341632843,
-0.04497756063938141,
-0.14034263789653... | |
I need some Jenkins jobs to have shell command line access to some other machines via ssh.
How can I do this?
I do not have the password of the target server[s], but I have a 'key' file, but when I run a job with the following
```
ssh -i /path/to/key/file name@someserver some_command
```
as a shell command, I get... | [
0.1910851150751114,
0.21707463264465332,
0.1218564435839653,
0.08234304934740067,
0.16614459455013275,
-0.14027409255504608,
0.33957597613334656,
0.03036169894039631,
0.0075650764629244804,
-1.051485300064087,
-0.13780362904071808,
0.7636232972145081,
-0.15613481402397156,
0.27784383296966... | |
do?
Thanks.
Ssh is asking for password either because the key is not valid or the key is protected by a passphrase.
Try the key by running the same command yourself to find out which problem you need to solve.
If the key is protected by a passphrase, you should probably remove the passphrase because there is no good... | [
0.0740695521235466,
-0.06117147207260132,
0.08400873094797134,
0.07112064957618713,
0.2682216167449951,
-0.21807047724723816,
0.5186821222305298,
-0.19235217571258545,
-0.11012215912342072,
-0.7642737030982971,
-0.6131999492645264,
0.6319099068641663,
-0.26256853342056274,
-0.1196624562144... | |
to use `-o StrictHostKeyChecking=no`, unless you can do the first login interactively and accept the host key. | [
0.09806402772665024,
-0.027590934187173843,
0.12008465081453323,
-0.11327836662530899,
0.3951997756958008,
-0.6461158990859985,
0.7026430368423462,
0.1508556455373764,
-0.19978350400924683,
-0.3461994230747223,
-0.6842691898345947,
0.4452921152114868,
-0.2665996253490448,
0.288470476865768... | |
We've used the Ruby Rally API to create user stories, but these appear to by default be located at the top of the backlog. Is there a way to use the API / create and have it appear at the bottom of the backlog instead?
So I [gave it a shot](http://jsfiddle.net/edelman/muUU5/). Basically you just need to refactor your c... | [
0.8792253732681274,
0.23069722950458527,
-0.07080432772636414,
0.03185924142599106,
-0.25832119584083557,
-0.309836745262146,
0.4510492980480194,
0.2432967573404312,
-0.24900463223457336,
-0.156204491853714,
0.08261926472187042,
0.6999186277389526,
-0.16727112233638763,
0.07701857388019562... | |
just genericized it so that you don't have to write the same code twice. It may be able to be refactored further, this is just to give you an idea as to what you should be doing. | [
0.7444404363632202,
-0.05922715365886688,
-0.15227234363555908,
0.018352117389440536,
0.03144049644470215,
-0.29461538791656494,
0.3112003803253174,
0.2913011908531189,
-0.2253095805644989,
-0.3830052316188812,
0.5990440249443054,
0.40782666206359863,
-0.4954633414745331,
0.294986367225647... | |
I am trying to fetch data from internet, parse it and then show the data to the user. The action usually takes 3 seconds or so, and I would like to a spinner ProgressDialog show a message saying that I am loading data. The problem is that ProgressDialog only shows up when the loading is almost complete. This is my code... | [
0.3194858431816101,
-0.22978490591049194,
0.9851208329200745,
-0.1956339180469513,
0.14550277590751648,
0.17125508189201355,
0.3738981783390045,
-0.4033936560153961,
-0.2457241415977478,
-0.7865646481513977,
-0.0640043169260025,
0.4467627704143524,
-0.3191138803958893,
0.050549186766147614... | |
{
task_complete = false;
progressBar = new ProgressDialog(v.getContext());
progressBar.setCancelable(false);
progressBar.setMessage("Fetching routes data ...");
progressBar.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressBar.show();
... | [
-0.04939050227403641,
-0.38810646533966064,
0.4825707972049713,
-0.27180853486061096,
0.14120808243751526,
0.20632731914520264,
0.7796623706817627,
-0.3814905881881714,
-0.4176698625087738,
-0.5247864127159119,
-0.38803789019584656,
0.3245985805988312,
-0.5057932734489441,
0.18850822746753... | |
{
loading_routes_data(v);
}
else
{
progressBar.dismiss();
}
} | [
-0.0657816007733345,
-0.27710968255996704,
0.27405574917793274,
-0.2461346536874771,
0.1913716048002243,
0.1439235955476761,
0.30386123061180115,
0.006715612020343542,
-0.40696269273757935,
-0.5287892818450928,
-0.2345239669084549,
0.33699408173561096,
-0.3469780385494232,
0.40671965479850... | |
});
}
```
And this is my function that gets called onclick
```
private void loading_routes_data(View v)
{
try
{
new Thread(new Runnable()
{
public void run()
{
while(!task_complete)
{ | [
0.25615257024765015,
-0.35637351870536804,
0.5660735964775085,
-0.2986067533493042,
0.37208831310272217,
0.01068238727748394,
0.424294650554657,
0.11578680574893951,
-0.4117272198200226,
-0.4417405128479004,
-0.26111698150634766,
0.7155121564865112,
-0.4704784154891968,
0.4633244574069977,... | |
refresh_routes();
try
{
Thread.sleep(1000); | [
-0.016676710918545723,
-0.3858810067176819,
0.26678919792175293,
-0.3797686994075775,
0.5611037611961365,
0.19297251105308533,
0.525623083114624,
0.15002848207950592,
-0.17398370802402496,
-0.8177323341369629,
-0.2130478322505951,
0.5686623454093933,
-0.3414151668548584,
0.2696521878242492... | |
}
catch(InterruptedException e)
{
e.printStackTrace();
} | [
-0.007432263344526291,
-0.6659711599349976,
0.08701973408460617,
-0.18656028807163239,
0.5923563838005066,
0.007942253723740578,
0.2622414529323578,
0.032062217593193054,
-0.12781667709350586,
-0.29682305455207825,
-0.1660701334476471,
0.5595973134040833,
-0.4367409646511078,
0.08267266303... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.