text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
newAd(request):
newAdFormSet = modelformset_factory(Ad, extra=1)
if request.method == 'POST':
formset = newAdFormSet(request.POST, request.FILES)
if formset.is_valid():
formset.save()
return render_to_response('conf.html',
{'state':'Yo... | [
0.2598930597305298,
-0.19910474121570587,
0.9980753660202026,
-0.3478037118911743,
-0.11771536618471146,
0.34958434104919434,
0.25264790654182434,
-0.5178980827331543,
-0.21301043033599854,
-0.898768424987793,
-0.3663063049316406,
-0.07439571619033813,
-0.31923016905784607,
0.2641482353210... | |
successfull created.'},
context_instance = RequestContext(request),)
else:
formset = newAdFormSet(queryset=Ad.objects.all())
return render_to_response('ad_form.html',
{'form':formset}, | [
-0.07511689513921738,
-0.08029775321483612,
1.0025599002838135,
-0.2997889816761017,
-0.02138371579349041,
0.16516990959644318,
0.7058204412460327,
-0.47937896847724915,
-0.10135475546121597,
-0.7860725522041321,
-0.535942018032074,
0.2878350615501404,
-0.38886114954948425,
-0.016399081796... | |
context_instance=RequestContext(request),)
```
Note the `extra=1` in modelformset\_factory line, it ensures there is only one extra blank form. And `queryset=Ad.objects.all()` in the second newAdFormSet inside else statement, it pre-fills forms for Ad objects from DB and correctly set PK in, mostly hidden, field for ... | [
-0.1603684276342392,
0.09916973859071732,
0.6147712469100952,
-0.2914395034313202,
-0.21557307243347168,
0.35325121879577637,
0.1659678816795349,
-0.5215318202972412,
-0.24031618237495422,
-0.9134591817855835,
-0.059043094515800476,
0.2758099436759949,
-0.3614661395549774,
0.21682660281658... | |
i can set uicolor with RGB values:
```
[UIColor colorWithRed:0.53 green:0.37 blue:0.11 alpha:1.00];
```
i can set uicolor with hsb values:
```
[UIColor colorWithHue:0.10 saturation:0.16 brightness:0.13 alpha:1.00];
```
i also could convert it back to RGB:
```
CGFloat* colors = CGColorGetComponents(Color1.CGColor... | [
-0.1801413595676422,
0.0454336516559124,
0.725031852722168,
-0.24191603064537048,
0.019885743036866188,
0.04872554540634155,
0.4759805202484131,
-0.32405027747154236,
-0.003328552469611168,
-0.8821505904197693,
-0.3727327287197113,
0.57662034034729,
-0.1929493099451065,
-0.0276800841093063... | |
success: 1 hue: 0.10, saturation: 0.79, brightness: 0.53, alpha: 1.00
Here is a corrected version of the method provided by @WhiteTiger:
```
// Test values
CGFloat red = 0.53;
CGFloat green = 0.37;
CGFloat blue = 0.11;
CGFloat hue = 0;
CGFloat saturation = 0;
CGFloat brightness = 0;
CGFloat minRGB = MIN(red, MIN(g... | [
-0.23477083444595337,
0.02335066720843315,
0.6424378752708435,
-0.10479167848825455,
0.17944610118865967,
-0.015652956441044807,
0.6988385915756226,
-0.7735998630523682,
-0.1883399486541748,
-0.42590340971946716,
-0.4380493760108948,
0.6561077237129211,
-0.2030990719795227,
-0.221976399421... | |
5);
hue = (h - d/(maxRGB - minRGB)) / 6.0;
saturation = (maxRGB - minRGB)/maxRGB;
brightness = maxRGB;
}
NSLog(@"hue: %0.2f, saturation: %0.2f, value: %0.2f", hue, saturation, brightness);
```
NSLog output:
> hue: 0.10, saturation: 0.79, value: 0.53 | [
-0.22203651070594788,
-0.06395135819911957,
0.6064707040786743,
-0.38938307762145996,
0.2420942336320877,
0.17338189482688904,
0.5245999693870544,
-0.21754340827465057,
-0.14647464454174042,
-0.6690899133682251,
-0.5895363092422485,
0.4452688992023468,
0.06902479380369186,
0.26388972997665... | |
This is my code following,I am changing some iamges dynamically in my image view.
public class LoadingScreen extends Activity{
```
public static Integer[] imageList={R.drawable.food_pics1,R.drawable.food_pics2,R.drawable.food_pics3,
R.drawable.food_pics4,R.drawable.food_pics5,R.drawable.food_pics6,R.drawable.food... | [
0.23124830424785614,
-0.12168823927640915,
0.8164339661598206,
-0.3438011407852173,
0.23294061422348022,
0.2594718039035797,
0.36419618129730225,
-0.47813546657562256,
-0.1429111659526825,
-0.7094861268997192,
-0.364127516746521,
0.6710408926010132,
-0.43255528807640076,
0.1897480338811874... | |
public void run() {
// TODO Auto-generated method stub
animateImages();
}
};
final int delay=500;
final long period=1000;
Timer timer=new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() | [
0.39778798818588257,
-0.5699232220649719,
0.12137984484434128,
-0.23179380595684052,
0.41502511501312256,
0.1697539985179901,
0.33188915252685547,
-0.1871596872806549,
-0.07559025287628174,
-0.3197641372680664,
-0.15070873498916626,
0.5744321346282959,
-0.3726271092891693,
0.34229239821434... | |
{
// TODO Auto-generated method stub
myHandler.post(runnable);
}
}, delay, period);
}
private void animateImages() {
// TODO Auto-generated method stub
foodImageView.setImageResource(imageList[currentImageIndex%imageList.length]);
currentImageIndex++;
foo... | [
0.4494938850402832,
-0.18756620585918427,
0.5120487213134766,
-0.45163610577583313,
0.2703149914741516,
0.19070592522621155,
0.5923738479614258,
-0.19687138497829437,
-0.0896163284778595,
-0.5528020858764648,
-0.21103845536708832,
0.8082455992698669,
-0.26705506443977356,
0.128861472010612... | |
View(this);
v.postDelayed(new Runnable(){
public void run() {
// TODO Auto-generated method stub
//cancel your animation and finish the Activity here.
finish();
} | [
0.3723236322402954,
-0.31618309020996094,
0.5043351650238037,
-0.19603300094604492,
0.2245182991027832,
0.03648241236805916,
0.4860824942588806,
0.12370162457227707,
-0.20168253779411316,
-0.4591298997402191,
-0.3991601765155792,
0.6638320088386536,
-0.4872453808784485,
0.2124786376953125,... | |
}, (long) 20000.0);
``` | [
0.0006348712486214936,
0.2601168751716614,
0.38400816917419434,
-0.46859630942344666,
0.4222217798233032,
-0.0885167345404625,
0.1884620040655136,
-0.04096780717372894,
0.10031023621559143,
-0.18919149041175842,
-0.25669369101524353,
0.7407134771347046,
-0.2980045676231384,
0.2816849052906... | |
I am learning C from ' programming in C' by Stephen Kochan. I am working on exercise no 4 of chapter 6 , writing a code that acts as a simple accumulator calculator. code is following. it works fine as long as inputs are provided in the right manner order.
```
#include<stdio.h>
int main(void)
{
float... | [
0.2029513269662857,
0.06863199174404144,
0.3336486220359802,
-0.19745691120624542,
0.3121577203273773,
-0.1859278678894043,
0.24363760650157928,
-0.05188993364572525,
0.07246164232492447,
-0.5532153248786926,
-0.03907114267349243,
0.5338795781135559,
-0.03833906725049019,
-0.02247519977390... | |
printf("Enter the number and the operator ");
scanf("%f %c",&num, &operator);
if (operator == 'E') break;
switch (operator){
case 'S':
accum = num;
printf("= %g\n",accum);
break;
case | [
-0.13868124783039093,
-0.2835877537727356,
0.12401552498340607,
-0.35138416290283203,
0.47185418009757996,
0.092316634953022,
0.05642978847026825,
-0.29293593764305115,
-0.04878103733062744,
-0.2410995215177536,
-0.8332575559616089,
0.6982790231704712,
-0.4111437201499939,
-0.0907318443059... | |
'+':
accum = accum + num;
printf("= %g\n",accum);
break;
case '-':
accum = accum - num;
printf("= %g\n",accum);
break;
case '*':
accum | [
-0.5898407101631165,
0.015797842293977737,
0.16305407881736755,
-0.16690589487552643,
0.05895649269223213,
0.4537326693534851,
0.04155692085623741,
-0.11221782863140106,
-0.10617775470018387,
-0.060828544199466705,
-0.89694744348526,
0.34092316031455994,
-0.32451456785202026,
0.01411161199... | |
= accum * num;
printf("= %g\n",accum);
break;
case '/':
accum = accum / num;
printf("= %g\n",accum);
break;
}
} | [
-0.5142756700515747,
0.0006992186536081135,
0.019639400765299797,
-0.3157271444797516,
0.24792054295539856,
0.3023163676261902,
0.17971110343933105,
-0.06369884312152863,
-0.120234914124012,
-0.13225862383842468,
-0.805595338344574,
0.47630012035369873,
-0.3270108699798584,
0.0707309693098... | |
printf("= %g\n",accum);
printf("End of Calculation\n");
return 0;
}
```
but it hangs on the wrong inputs. what can be done to check such behaviour?
The short version is "don't use `scanf()`."
The problem is that `scanf()` provides only a limited indication of error, and leaves the erroneous data ... | [
0.4182906448841095,
-0.22032123804092407,
0.43677693605422974,
-0.2774542272090912,
-0.06042898818850517,
-0.2556094825267792,
0.43888556957244873,
-0.13091589510440826,
-0.1559762805700302,
-0.2036876082420349,
-0.22704562544822693,
0.748729407787323,
-0.6105879545211792,
-0.2417601943016... | |
If you're doing line oriented input, use `fgets()` or similar to read an entire line, and `sscanf()` to parse from the line.
3. Do something sensible if the input isn't what you expected, instead of just barreling on through. (Your existing code just assumes it's always valid.) | [
-0.10686600208282471,
-0.2347264438867569,
-0.05885125696659088,
-0.06636063009500504,
-0.3222452402114868,
-0.1526130735874176,
0.31807318329811096,
-0.0015629250556230545,
0.021628499031066895,
-0.4493213891983032,
-0.41441401839256287,
0.4860855042934418,
-0.3375200629234314,
-0.4578421... | |
How to set up logger in cakePhp?
i want to print the parameters which is passed to the controller? how can i do that in cakePhp?
If you want to write to log file:
```
$this->log($this->params, 'debug');
```
For more info: <http://book.cakephp.org/2.0/en/core-libraries/logging.html> | [
0.37206050753593445,
-0.2857940196990967,
0.2552568018436432,
0.16503262519836426,
0.007773952558636665,
-0.07513701915740967,
0.06343835592269897,
-0.36172157526016235,
-0.44647321105003357,
-0.5595070123672485,
-0.10135842859745026,
0.32488471269607544,
-0.30563971400260925,
-0.113806709... | |
I have a TextView (width: fill\_parent) in a RelativeLayout that I want to ensure is under the the two Views above it that are side by side, with dynamic widths and height. That means, that sometimes the Left view is taller and sometimes the Right View is taller.
I tried to have two "below" parameters set, but that is... | [
0.3274174630641937,
-0.039150312542915344,
0.8576914072036743,
-0.3444502353668213,
-0.0463506244122982,
0.14620859920978546,
-0.03453116491436958,
-0.3583240211009979,
-0.10986372083425522,
-0.6500580310821533,
0.02173173613846302,
0.7503767609596252,
-0.0019909271504729986,
-0.0743666440... | |
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
params.addRule(RelativeLayout.BELOW, R.id.image);
... | [
-0.3485487699508667,
-0.2962521016597748,
1.080498218536377,
-0.2964726388454437,
0.11568950116634369,
0.567469596862793,
0.06612494587898254,
-0.4398203194141388,
-0.30137085914611816,
-0.6337431073188782,
-0.2561298906803131,
0.586902379989624,
-0.21776477992534637,
0.30416566133499146,
... | |
I want below both views).
When that didn't work (nothing changed), I put txtDetails in its own RelativeLayout below the RelativeLayout that housed both views and that worked. However, I feel that RL should be able to handle this situation, without creating a new RL. Is it possible? Or what is the best way to position ... | [
0.08817590028047562,
-0.2711908221244812,
0.8742961883544922,
-0.11731043457984924,
-0.013544962741434574,
-0.00835840217769146,
0.38562697172164917,
-0.018703261390328407,
-0.1744808554649353,
-0.7255535125732422,
0.16927284002304077,
0.8351410627365112,
-0.20714981853961945,
0.4037226736... | |
public void onGlobalLayout() {
// your code here...
txt.requestLayout(); // Add this to ensure your changes are applied.
}
}
```
PS. you can just call `txt.getBottom()` instead of `txt.getHeight() + txt.getTop()` | [
0.6785902380943298,
-0.3204924166202545,
0.6082969307899475,
0.11578173190355301,
0.4884564280509949,
-0.14761362969875336,
0.37351882457733154,
0.15352921187877655,
-0.3141184151172638,
-0.6143597364425659,
-0.4354533553123474,
0.6480547189712524,
-0.5960145592689514,
0.2770984470844269,
... | |
Okay, this is going to be hard to explain but here goes nothing:
Lately I've been working a lot with POST and GET requests, but now I want to send a POST/GET request to this site called: <http://www.mangareader.net/>
The main problem I'm facing is that I want to use the search function of this site. Normally I woul... | [
0.371895432472229,
-0.20821568369865417,
0.47281065583229065,
0.31991878151893616,
-0.4475567638874054,
-0.2711031138896942,
0.38784563541412354,
0.20865921676158905,
-0.014843958429992199,
-0.5423086881637573,
0.13227927684783936,
0.7158209681510925,
-0.12348513305187225,
0.52135056257247... | |
get a drop down list of all the mangas (Japanese comics) with the word "Elf" in them. I want to know how this process is called, and how I can implement it into a Java program. For instance:
Login into a website
- > Send an HTTP post request. Get HTML data back. Process the HTML data. Get the information I need from ... | [
0.3288140594959259,
-0.15590594708919525,
0.46692273020744324,
0.31164559721946716,
-0.36689165234565735,
-0.17606250941753387,
0.13928678631782532,
0.09258538484573364,
-0.050279401242733,
-0.4762846529483795,
-0.18992076814174652,
0.7767185568809509,
-0.10358695685863495,
-0.181173965334... | |
function on mangareader.net
- > ??????????
How would I achieve this? A theoretic explanation is enough, but a practical example would be great as well.
If you analyse the javascript that runs when search you get the following:
GET <http://www.mangareader.net/actions/search/?q=test&limit=100> [HTTP/1.1 200 OK 113ms]
... | [
-0.057806890457868576,
-0.052370890974998474,
0.565278172492981,
0.2078578770160675,
-0.5010536313056946,
0.11744173616170883,
0.5190808773040771,
-0.4657840430736542,
0.11564872413873672,
-0.29125484824180603,
0.032076165080070496,
0.5891920924186707,
-0.19386504590511322,
0.1694446802139... | |
I am creating a shipping module for a custom webshop (in PHP) that is turning out to be a bit complex (for me anyway);
in the desired shipping procedure, there are (currently) two outer 'shipping boxes/containers' that can each contain a different combination of items/products. There is a big one and a small one, and ... | [
0.3822082579135895,
0.04388061538338661,
0.16395017504692078,
0.1851775050163269,
0.2496807873249054,
0.24157169461250305,
-0.29663291573524475,
-0.025840507820248604,
-0.3562334179878235,
-0.5949697494506836,
0.025534613057971,
0.058376941829919815,
0.011294306255877018,
0.266408383846282... | |
shipped. The optimal combination of outer boxes and its contents/packing order should then be calculated, such that the smallest amount of boxes is needed.
Needless to say, I expect the number of outer boxes, inner boxes and their dimensions are probably very likely to change in the future.
Does this even exist?
You ... | [
0.1555768847465515,
-0.19631777703762054,
0.715885579586029,
0.1480197012424469,
0.13781686127185822,
-0.22272266447544098,
-0.12449275702238083,
-0.07929610460996628,
-0.468104749917984,
-0.5385153889656067,
-0.23018905520439148,
0.5649598240852356,
-0.3237142562866211,
-0.055990662425756... | |
I have a model with the following fields:
```
user = models.ForeignKey(User)
impact = models.IntegerField(default = value)
```
Where I want `value` to be `User.get_profile().someIntField` with User being the same User object that was passed to the first field. How can I do this?
```
def __init__(self, *args, **kwarg... | [
-0.0068131061270833015,
0.05495838820934296,
0.5535465478897095,
-0.11619109660387039,
-0.06031954288482666,
0.20664383471012115,
0.11345988512039185,
-0.22931665182113647,
-0.22190308570861816,
-0.7645902037620544,
0.08218546211719513,
0.5205774903297424,
-0.3021533191204071,
0.2590521872... | |
is it possible to create crosstab representation of data in data grid. as it is working fine with crystal reports but my requirements are to show crosstab in data grid of windows control.
```
def __init__(self, *args, **kwargs):
super(YourModel, self).__init__(*args, **kwargs)
self.impact = self.user.get_profil... | [
0.06573443859815598,
-0.10798148810863495,
0.6349007487297058,
0.02233804389834404,
-0.11068213731050491,
0.06507974863052368,
0.273311972618103,
-0.19197048246860504,
-0.24006067216396332,
-0.854789674282074,
0.13523928821086884,
0.4452982544898987,
-0.4085969030857086,
-0.021273277699947... | |
Is it possible to display line numbers in a `JTextArea`? Please advise me how to write code in JApplet.
[This may be useful for you](http://www.javaprogrammingforums.com/java-swing-tutorials/915-how-add-line-numbers-your-jtextarea.html) and [This stackoverflow question also](https://stackoverflow.com/questions/4618136... | [
0.16447225213050842,
-0.15492118895053864,
0.24115800857543945,
0.08874072134494781,
-0.16095589101314545,
-0.11763474345207214,
0.2834140956401825,
-0.1643916666507721,
-0.22649751603603363,
-0.3082987368106842,
-0.2380944788455963,
0.4318879246711731,
-0.18213018774986267,
-0.49189484119... | |
Is it possible to create a nested select statement something like this in mysql?
`SELECT * from myTable WHERE id = (SELECT id from data where dataId = 1);`
If this is not the correct way to formulate such a statement could anyone point me in the right direction for the way in which it should be formulated.
Thanks
T... | [
0.17722560465335846,
-0.03939546272158623,
0.04803991690278053,
-0.11435253918170929,
-0.3440465033054352,
0.009181257337331772,
0.11479713022708893,
-0.25890401005744934,
-0.012519177980720997,
-0.570767879486084,
0.14714094996452332,
0.4028831422328949,
-0.36739370226860046,
-0.112306915... | |
id from data where dataId = 1);
``` | [
0.1906878501176834,
-0.003349720034748316,
0.17483943700790405,
-0.06349102407693863,
0.08837951719760895,
0.022966882213950157,
-0.035683661699295044,
-0.3715188503265381,
0.1398676484823227,
-0.41497930884361267,
-0.3983921408653259,
0.5245698690414429,
-0.4150301516056061,
0.16088917851... | |
I try to make a sql query which returns the ID of customers, their account's currencies and the end of year amounts of their accounts by multiplying the current amount with **the minimum interest rates of all acount**
Tables are like
```
**customer** **account**
id id
name cust... | [
0.2162877470254898,
0.3855588436126709,
0.4768644869327545,
0.013062394224107265,
0.11961930990219116,
0.24547937512397766,
-0.3194204866886139,
0.2448546141386032,
-0.20640598237514496,
-0.3287281095981598,
0.19284750521183014,
0.5074374675750732,
0.15480969846248627,
0.4179830253124237,
... | |
cur_Amount
interest_rate
```
I made a query like below but it only returns the one row which has the minimum interest rate.
`SELECT customer.id, account.currency, account.cur_amount, MIN(account.interest_rate)*cur_amount AS End_Year_Balance
FROM customer, account LEFT JOIN account on customer.i... | [
0.27602291107177734,
0.4132951498031616,
0.6099377870559692,
-0.0087444968521595,
-0.06948661059141159,
0.2666650116443634,
-0.46319520473480225,
0.1410142332315445,
-0.2803293466567993,
-0.4284197986125946,
0.26983535289764404,
0.6557341814041138,
0.14308477938175201,
0.5309563279151917,
... | |
Note though that this will only work if there is one data with dataId 1.
If there is likely to be multiple ids returned by the inner select then it is better to use:
```
SELECT * from myTable WHERE id IN (SELECT id from data where dataId = 1);
``` | [
-0.06717540323734283,
-0.3005674183368683,
0.15440945327281952,
-0.040812864899635315,
-0.018920421600341797,
-0.015873776748776436,
-0.08134418725967407,
-0.31522583961486816,
0.10351409763097763,
-0.6923761367797852,
-0.01964491605758667,
0.4685385227203369,
-0.17374320328235626,
0.05459... | |
i have a input field that is accepting url from user and i need to check for trailing slash like so:
* www.example.com (add slash)
* www.exaple.com/ (ignore)
* www.example.com/index.php (ignore)
How could i achieve this in javaScript?
PS .htaccess and php are not the options
Try this -
```
function URLFormat() {
... | [
0.13486266136169434,
-0.07881633192300797,
0.7591644525527954,
0.035991813987493515,
-0.15088175237178802,
0.008619937114417553,
0.4171268343925476,
-0.5697874426841736,
-0.010689307935535908,
-0.6295549869537354,
-0.14403246343135834,
0.4019811451435089,
-0.11501436680555344,
0.1079953014... | |
if (urlParts[i].indexOf('.') > -1) {
// trailing slash not required
result = url;
}
else {
if (urlParts[i].indexOf('#') > -1) { | [
-0.2570681571960449,
-0.23081594705581665,
0.5982400178909302,
-0.052251990884542465,
0.07830629497766495,
0.03248143196105957,
0.15575140714645386,
-0.1650669127702713,
0.05861762538552284,
-0.17287716269493103,
-0.46828410029411316,
0.31599345803260803,
-0.07662838697433472,
0.1436233669... | |
// trailing slash not required
result = url;
}
else {
//Assume this is a folder and add a slash | [
0.10723688453435898,
-0.43184399604797363,
0.4983696937561035,
-0.14134669303894043,
0.14937083423137665,
-0.09210552275180817,
0.030062051489949226,
0.33165979385375977,
-0.2688817083835602,
-0.25428488850593567,
-0.2760586738586426,
0.09131544083356857,
-0.14144326746463776,
0.2204331904... | |
result = url + '/';
}
}
}
}
alert(result);
}
``` | [
0.17235320806503296,
-0.19439414143562317,
0.6804463267326355,
-0.21582336723804474,
0.09231413155794144,
-0.35011279582977295,
0.22597505152225494,
-0.12104831635951996,
-0.10857853293418884,
-0.1849241703748703,
-0.6273577809333801,
0.5771166682243347,
-0.21728721261024475,
0.20093834400... | |
I noticed `PDO::FETCH_INTO` fetch mode doesn't work inside `PDOStatement::fetch()` but in the [manual](http://www.php.net/manual/en/pdostatement.fetch.php) it says you can use `PDO::FETCH_INTO` with `PDOStatement::fetch()`.
I was trying to do:
$query->fetch( PDO::FETCH\_INTO, $user );
This returns: `PDOStatement::fet... | [
-0.02042545937001705,
-0.33715757727622986,
0.7182761430740356,
-0.2535344660282135,
0.2167653739452362,
-0.1393054723739624,
0.014422019012272358,
-0.3698049783706665,
-0.1395539492368698,
-0.8223409652709961,
-0.3755052387714386,
0.7839826345443726,
-0.28360193967819214,
-0.0553966648876... | |
$this->username = $username;
}
...
}
...
$stmt->setFetchMode(PDO::FETCH_CLASS, 'User');
$user = $stmt->fetch();
```
UPDATE 2:
Using PDO::FETCH\_CLASS, you don't even need the setter (EDIT: don't need the setter for PDO, which is good for id fields):
```
class User {
protected $username;
...
}
...
$stmt->set... | [
-0.23224350810050964,
-0.12507140636444092,
0.8534875512123108,
-0.3557446599006653,
0.189931258559227,
-0.23318153619766235,
0.03951090946793556,
-0.2648580074310303,
-0.21157841384410858,
-0.6658482551574707,
-0.35477158427238464,
0.6716423034667969,
-0.46517521142959595,
0.0088190501555... | |
My maze generator seems to have a problem.
I am trying to generate [something like this maze](http://mazeworks.com/mazegen/mazetut/index.htm)
My program displays this:

and the error
```
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsEx... | [
0.019598079845309258,
-0.015443496406078339,
0.3377060294151306,
-0.07989551872015,
-0.16180536150932312,
0.3054440915584564,
0.7756757140159607,
-0.5478312373161316,
-0.2573603689670563,
-0.9854051470756531,
0.1514989286661148,
0.457951158285141,
-0.7651185393333435,
0.21857038140296936,
... | |
size, int h, int w) {
this.size = size;
maze = new Cell[size][size];
for(int i = 0; i<size; i++){
for(int a =0; a<size; a++){
maze[i][a] = new Cell();
}
}
setPreferredSize(new Dimension(h, | [
-0.10713503509759903,
-0.4582656919956207,
0.5698305368423462,
-0.19292043149471283,
0.25534334778785706,
0.17082218825817108,
0.5116317868232727,
-0.6471073031425476,
-0.4004773497581482,
-0.7346587181091309,
-0.2277078628540039,
0.34867727756500244,
-0.5111953616142273,
0.387967199087142... | |
w));
}
public static void main(String[] args) {
JFrame y = new JFrame();
y.setLayout(new BorderLayout());
Grid f = new Grid(25, 400, 400);
y.add(f, BorderLayout.CENTER);
y.setSize(450, 450);
y.setVisible(true);
y.setDefaultCloseOperation(y.EXIT_ON_CLOSE);... | [
-0.03351159393787384,
-0.4491060674190521,
0.8329087495803833,
-0.2976260483264923,
0.37288811802864075,
0.5002886652946472,
0.35589006543159485,
-0.3725323975086212,
-0.0844159796833992,
-0.6672961115837097,
-0.5987695455551147,
0.439638614654541,
-0.2951211929321289,
0.6297170519828796,
... | |
}
public void push(int[] xy)
{
coordinates.add(xy);
int i = coordinates.size();
coordinates.ensureCapacity(i++);
}
public int[] pop() {
int[] x = coordinates.get((coordinates.size())-1);
coordinates.remove((coordinates.size())-1);
return x;
}
public int[] top() {
return ... | [
0.19840183854103088,
-0.4022921323776245,
0.7207843065261841,
-0.11469461768865585,
0.5913230776786804,
0.11206207424402237,
-0.06893370300531387,
-0.287066787481308,
-0.35587838292121887,
-0.633860170841217,
-0.3146495819091797,
0.3211858868598938,
-0.5295581221580505,
0.23463480174541473... | |
of cells in grid
int TotalCells = size*size;
// choose a cell at random and call it CurrentCell
int m = randomInt(size);
int n = randomInt(size);
Cell curCel = maze[m][n];
// set VisitedCells = 1
int visCel = 1,d=0;
int[] q;
int h,o = 0,p = 0;
// while VisitedCells < TotalCe... | [
-0.3122492730617523,
-0.6910742521286011,
0.5519465208053589,
-0.09470898658037186,
0.2281222641468048,
0.23496520519256592,
-0.0036295505706220865,
-0.20804166793823242,
-0.374115914106369,
-0.6459934115409851,
0.0008805441902950406,
0.0693550705909729,
-0.5093358159065247,
0.292930930852... | |
all neighbors of CurrentCell with all walls intact
if(maze[m-1][n].countWalls() == 4){d++;}
if(maze[m+1][n].countWalls() == 4){d++;}
if(maze[m][n-1].countWalls() == 4){d++;}
if(maze[m][n+1].countWalls() == 4){d++;}
// if one or more found
if(d!=0){
Point[] ls = new Point[4];
ls[0] = new... | [
-0.5056706666946411,
-0.5072232484817505,
1.0058273077011108,
-0.2633439302444458,
-0.007460996974259615,
-0.09592904150485992,
0.367713987827301,
-0.6242565512657166,
-0.19139930605888367,
-0.4044494032859802,
-0.3620639443397522,
0.17040807008743286,
-0.4148019552230835,
0.36154302954673... | |
switch(h){
case 0: o = (int)(ls[0].getX());
p = (int)(ls[0].getY());
curCel.destroyWall(2);
maze[o][p].destroyWall(1);
break;
case 1: o = (int)(ls[1].getX()); | [
0.0763472393155098,
-0.24330730736255646,
0.26277396082878113,
-0.22962702810764313,
0.4948832094669342,
0.07191062718629837,
0.4547169506549835,
-0.43022775650024414,
-0.13104993104934692,
-0.4788314402103424,
-0.5874106287956238,
0.4804094433784485,
-0.602196455001831,
0.2573553621768951... | |
p = (int)(ls[1].getY());
curCel.destroyWall(1);
maze[o][p].destroyWall(2);
break;
case 2: o = (int)(ls[2].getX());
p = (int)(ls[2].getY());
curCel.destroyWall(3); | [
-0.2572813630104065,
-0.11780468374490738,
0.43631842732429504,
-0.3131054639816284,
0.26354774832725525,
0.2040637582540512,
0.6262843012809753,
-0.5913962721824646,
-0.17731061577796936,
-0.37257105112075806,
-0.8021917343139648,
0.5121750831604004,
-0.6710797548294067,
0.044948536902666... | |
maze[o][p].destroyWall(0);
break;
case 3: o = (int)(ls[3].getX());
p = (int)(ls[3].getY());
curCel.destroyWall(0);
maze[o][p].destroyWall(3);
break; | [
-0.3314453065395355,
-0.0555235929787159,
0.4749392867088318,
-0.28032633662223816,
0.3112928867340088,
0.3269754648208618,
0.7211735844612122,
-0.44029757380485535,
-0.17399317026138306,
-0.3987919092178345,
-0.7520135641098022,
0.5022873282432556,
-0.7466103434562683,
0.30942511558532715... | |
}
// push CurrentCell location on the CellStack
push(new int[] {m,n});
// make the new cell CurrentCell
m = o; n = p;
curCel = maze[m][n];
// add 1 to VisitedCells
visCel++;
}
// else
else{
// pop the most recent cell entry off the CellStack
q = pop();
m = q[0]; | [
-0.46971994638442993,
-0.43149998784065247,
1.247158408164978,
-0.25295913219451904,
0.4856965243816376,
-0.06187118589878082,
0.2733853757381439,
-0.03400223329663277,
-0.23281408846378326,
-0.5207343697547913,
-0.3313140869140625,
0.15080362558364868,
-0.5316795110702515,
0.4596419930458... | |
n = q[1];
curCel = maze[m][n];
// make it CurrentCell
// endIf
}
// endWhile
}
}
public int randomInt(int s) { return (int)(s* Math.random());}
public void paint(Graphics g) {
int k, j;
width = getSize().width;
height = getSize().height; | [
0.056177787482738495,
-0.6110826134681702,
0.5495703816413879,
-0.32366397976875305,
-0.15068629384040833,
0.3919958770275116,
0.2866578698158264,
-0.23620420694351196,
-0.1964876353740692,
-0.8023734092712402,
0.04343819618225098,
0.5169512033462524,
-0.19796933233737946,
0.17543621361255... | |
double htOfRow = height / (size);
double wdOfRow = width / (size);
//checks verticals - destroys east border of cell
for (k = 0; k < size; k++) {
for (j = 0; j < size; j++) {
if(maze[k][j].checkWall(2)){
g.drawLine((int) (k * wdOfRow), (int) (j * | [
-0.06119207292795181,
-0.2536098062992096,
0.6484112739562988,
-0.2880866825580597,
0.3410603106021881,
0.13179367780685425,
0.7502856850624084,
-0.7770693302154541,
-0.22390532493591309,
-0.5280896425247192,
-0.391042560338974,
0.39721524715423584,
-0.38859066367149353,
0.3621160387992859... | |
htOfRow), (int) (k * wdOfRow), (int) ((j+1) * htOfRow));
}}
}
//checks horizontal - destroys north border of cell
for (k = 0; k < size; k++) {
for (j = 0; j < size; j++) {
if(maze[k][j].checkWall(3)){ | [
-0.13368980586528778,
-0.05475696176290512,
0.6775669455528259,
-0.17129555344581604,
0.5239459276199341,
-0.052716393023729324,
1.0931692123413086,
-0.6545851230621338,
-0.2938576340675354,
-0.7521073818206787,
-0.3059905767440796,
-0.0047389185056090355,
-0.41090551018714905,
0.572563886... | |
g.drawLine((int) (k * wdOfRow), (int) (j * htOfRow), (int) ((k+1) * wdOfRow), (int) (j * htOfRow));
}}
}
}
}
class Cell {
private final static int NORTH = 0;
private final static int EAST = 1;
private final static int WEST = 2;
private final static int SOUTH = 3;
private fi... | [
-0.6794517040252686,
-0.24798241257667542,
0.7309625744819641,
-0.35635676980018616,
0.11013395339250565,
0.32702142000198364,
0.123967245221138,
-0.31284239888191223,
0.022291282191872597,
-0.47919225692749023,
-0.7290894389152527,
0.16597849130630493,
-0.17720189690589905,
0.575923025608... | |
static int START = 1;
private final static int END = 2;
boolean[] wall = new boolean[4];
boolean[] border = new boolean[4];
boolean[] backtrack = new boolean[4];
boolean[] solution = new boolean[4];
private boolean isVisited = false;
private int Key = 0;
public Cell(){
for(int i=0;i... | [
0.03326286002993584,
-0.22672784328460693,
0.7919027209281921,
-0.533450186252594,
0.13137619197368622,
0.0433313250541687,
0.5206176042556763,
-0.7873302102088928,
-0.3328104317188263,
-0.3258325159549713,
-0.5390772819519043,
0.5029825568199158,
-0.3811838924884796,
0.18076246976852417,
... | |
if (wall[i] == true)
{k++;}
}
return k;}
public boolean checkWall(int x){
switch(x){
case 0: return wall[0];
case 1: return wall[1];
case 2: return wall[2];
case 3: return wall[3];
}
return true;
}
public void destroyWall(int x){
switch(x){ | [
0.43222150206565857,
-0.03981879726052284,
0.1872558891773224,
-0.44101467728614807,
0.06288085877895355,
-0.22114057838916779,
0.6670252680778503,
-0.6385313868522644,
0.23800374567508698,
-0.595157265663147,
-0.2768844962120056,
0.5507703423500061,
-0.39918872714042664,
0.377586096525192... | |
case 0: wall[0] = false; break;
case 1: wall[1] = false; break;
case 2: wall[2] = false; break;
case 3: wall[3] = false; break;
}
}
public void setStart(int i){Key = i;}
public int getKey(){return Key;}
public boolean checkVisit(){return isVisited;}
public void vis... | [
0.005254658404737711,
-0.3942311406135559,
0.5674782991409302,
-0.2532554566860199,
0.3842901587486267,
-0.34053274989128113,
0.47590944170951843,
-0.5381210446357727,
-0.13203215599060059,
-0.5863021016120911,
-0.6777973175048828,
0.6669555306434631,
-0.3227793276309967,
0.037946723401546... | |
users.*,
SUM(overtime_list.shift_length) AS overtime_total,
(SELECT GROUP_CONCAT(users_roles.role_ID) FROM users_roles WHERE users.user_ID = users_roles.user_ID) AS roles
FROM availability_list
INNER JOIN users
ON users.user_ID = availability_list.user_ID
INNER JOIN `stations`
ON `users`.`station_ID` = ... | [
0.20261281728744507,
0.08158176392316818,
0.6090885400772095,
-0.10196296870708466,
0.3119645118713379,
0.5473179221153259,
0.007048500701785088,
0.044473856687545776,
-0.4958376884460449,
-0.8764366507530212,
-0.16711772978305817,
0.45713871717453003,
-0.3554379642009735,
0.45758062601089... | |
```
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class Map2Activity extends MapActivity {
/** Called when the activity is first created. */
MapView map;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInst... | [
0.14921678602695465,
-0.2110988348722458,
0.8191353678703308,
-0.10272791981697083,
0.045560941100120544,
0.02509552240371704,
0.20940551161766052,
-0.7644973397254944,
-0.17967332899570465,
-0.7785347700119019,
-0.45382940769195557,
0.5953262448310852,
-0.42990607023239136,
-0.07361922413... | |
android:layout_height="fill_parent"
android:apiKey="01VR0PIBfyfgbR5DlOlcEBPG9F5WfE7ZBPg"
android:tag="@+id/mvMain"
android:enabled="true"
android:clickable="true" />
</LinearLayout>
```
i am not getting the map with these two statements (forcebly closing the app)
... | [
-0.15705479681491852,
-0.08433794230222702,
1.003771185874939,
-0.1430351585149765,
0.20305132865905762,
0.37004584074020386,
0.29341059923171997,
-0.7357377409934998,
-0.11472206562757492,
-0.6738207340240479,
-0.15799419581890106,
0.6922961473464966,
-0.2834204435348511,
-0.0922518372535... | |
I have the following scenario in mySql, is it possible to update the values with an update statement?
I'd like to set the value table 1.A to the value of 2.B when 1.A matches 2.C
```
Table1
columnA
Table2
columnB
columnC
```
I'm thinking of running the following - will it work?
```
Update Table1 SET Table1.col... | [
-0.21539868414402008,
0.06532561779022217,
0.6971602439880371,
0.01678844541311264,
-0.031127681955695152,
-0.07518292963504791,
0.28369852900505066,
0.07804779708385468,
-0.01609332673251629,
-0.9506424069404602,
-0.027848711237311363,
0.6769781112670898,
-0.2045464664697647,
-0.039959236... | |
I need to create a activity which should look like as a dialog box with a rounded corners.
For this requirement I set
```
android:theme="@android:style/Theme.Dialog"
```
Now my activity looks like a dialog box but I need its corners to be rounded.
Then I created xml with attribute and set this drawable as my ac... | [
0.27741140127182007,
-0.09960895031690598,
0.6119621992111206,
-0.2135721892118454,
-0.03739317134022713,
-0.019517214968800545,
0.089792899787426,
-0.23696933686733246,
-0.2416543960571289,
-0.5304052233695984,
-0.11973977833986282,
0.5630822777748108,
-0.33146926760673523,
-0.23994246125... | |
>
<corners android:radius="15dp" />
<solid android:color="#565656" />
<stroke
android:width="3dp"
android:color="#ffffff" />
<padding
android:bottom="6dp"
android:left="6dp"
android:right="6dp"
android:top="3dp" />
</shape>
```
Next make your own th... | [
-0.11126943677663803,
-0.058459095656871796,
0.9712438583374023,
0.008113495074212551,
-0.12039167433977127,
0.23048515617847443,
-0.07635969668626785,
-0.5118212103843689,
-0.2981798052787781,
-0.7103077173233032,
-0.13018843531608582,
0.13360083103179932,
0.005695073399692774,
0.26881641... | |
</style>
</resources>
```
This will be in a file named `styles.xml` in the `res/values` folder. Use this theme in the android manifest for the `Activity` you want:
```
//...
<activity
android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@style/ThemeWithCor... | [
0.3665059208869934,
-0.06428512930870056,
0.8500632047653198,
-0.03218638896942139,
0.06675656139850616,
-0.10964685678482056,
-0.1558222472667694,
-0.0874975323677063,
-0.3461250960826874,
-0.5663638114929199,
-0.3440329134464264,
0.42171767354011536,
-0.2025880366563797,
-0.0742546170949... | |
In one class there is a list with all friends and their IDs. Now when you click on the item in the UITableView the Chat appears (`[self performSegueWithIdentifier: @"showChat" sender: self];`). But in the ChatViewController Class I need to access the variable userID from FirstViewController. I tried everything I found ... | [
-0.2937765419483185,
-0.25811856985092163,
0.3236587643623352,
0.04927842691540718,
-0.28241148591041565,
-0.029733264818787575,
0.25549566745758057,
-0.17991629242897034,
0.07344529777765274,
-0.89532071352005,
0.023803509771823883,
0.47480228543281555,
-0.2307865172624588,
0.205393716692... | |
[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
userID = fvc.userID;
```
just gives an empty String..
Thanks for help!
You need to have `prepareForSegue:` method to pass the variable.
Implement the method as follows:
```
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(i... | [
0.01816491223871708,
-0.43981412053108215,
0.8382061123847961,
0.1596873253583908,
-0.08181682229042053,
-0.23972007632255554,
0.12294910103082657,
-0.1818605661392212,
-0.10595256090164185,
-0.7826570868492126,
-0.326725035905838,
0.5092681646347046,
-0.10425254702568054,
0.19364027678966... | |
like...
cvc.userID = self.userID;
}
}
```
You can find the [tutorial here](http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2) on passing the value through segue.
**Update**
Similar question is already asked [here](https://stackoverflow.com/questions/7864371/ios5-how-to-pass-prepare... | [
0.12732039391994476,
0.03678371384739876,
0.6286303400993347,
0.05405253916978836,
0.1325199455022812,
-0.250969797372818,
0.4685796797275543,
-0.2316758930683136,
-0.11703643947839737,
-0.3482964336872101,
-0.47689318656921387,
0.6078588962554932,
0.1367855668067932,
-0.09338905662298203,... | |
I am converting a UIImage to NSData. Now I need to encrypt that NSData using a public key and I need to decrypt using a private key. Please provide a step by step procedure. Which algorithm do I need to use? Is there any good library for encryption and decryption? Also provide some code snippet for encryption and decry... | [
0.07013091444969177,
-0.18422186374664307,
0.6182826161384583,
0.05437960848212242,
-0.3103336989879608,
-0.21201486885547638,
0.4163461923599243,
-0.29736828804016113,
-0.08704612404108047,
-1.208497166633606,
-0.3962180018424988,
0.35716578364372253,
-0.3246382474899292,
0.07265775650739... | |
NSData *privateTag;
}
- (void)encryptWithPublicKey:(uint8_t *)plainBuffer cipherBuffer:(uint8_t *)cipherBuffer;
- (void)decryptWithPrivateKey:(uint8_t *)cipherBuffer plainBuffer:(uint8_t *)plainBuffer;
- (SecKeyRef)getPublicKeyRef;
- (SecKeyRef)getPrivateKeyRef;
- (void)testAsymmetricEncryptionAndDecryption;
- (void)ge... | [
-0.3988761007785797,
-0.13532893359661102,
0.4397121071815491,
-0.08188723027706146,
0.229300394654274,
0.2356189638376236,
0.6304417848587036,
-0.24227802455425262,
-0.20649167895317078,
-0.5816396474838257,
-0.5082691311836243,
0.7346968650817871,
-0.32949087023735046,
0.0190041288733482... | |
alloc] init];
// Set the public key query dictionary.
[queryPublicKey setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass];
[queryPublicKey setObject:publicTag forKey:(__bridge id)kSecAttrApplicationTag];
[queryPublicKey setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__... | [
-0.5710591673851013,
-0.0691966712474823,
0.5652176141738892,
0.11834831535816193,
-0.0930885374546051,
0.23891212046146393,
0.31919458508491516,
-0.3605046272277832,
-0.13634060323238373,
-0.4352630078792572,
-0.28895244002342224,
0.6468558311462402,
-0.2725108563899994,
0.108147107064723... | |
{
publicKeyReference = NULL;
}
// [queryPublicKey release];
} else { publicKeyReference = publicKey; }
return publicKeyReference; }
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)tes... | [
0.12444768846035004,
-0.12165559828281403,
0.18786346912384033,
-0.0677880272269249,
0.14776812493801117,
-0.18549123406410217,
0.6150173544883728,
-0.13567501306533813,
-0.015814142301678658,
-0.38393375277519226,
-0.5443181395530701,
0.46365728974342346,
-0.40500977635383606,
0.140420809... | |
data with public key and Decrypt data with private key";
int len = strlen(inputString);
// TODO: this is a hack since i know inputString length will be less than BUFFER_SIZE
if (len > BUFFER_SIZE) len = BUFFER_SIZE-1;
plainBuffer = (uint8_t *)calloc(BUFFER_SIZE, sizeof(uint8_t));
cipherBuffer = (ui... | [
-0.28253281116485596,
-0.24087178707122803,
0.4372761845588684,
-0.17786139249801636,
-0.03154337406158447,
0.06060538813471794,
0.5796500444412231,
-0.37562888860702515,
-0.1846776008605957,
-0.4004051387310028,
-0.30316242575645447,
0.7553269863128662,
-0.19084861874580383,
0.10284766554... | |
NSLog(@"encrypted data: %s", cipherBuffer);
//NSLog(@"init(): sizeof(cipherBuffer): %d", sizeof(cipherBuffer));
[self decryptWithPrivateKey:cipherBuffer plainBuffer:decryptedBuffer];
NSLog(@"decrypted data: %s", decryptedBuffer);
//NSLog(@"init(): sizeof(decryptedBuffer): %d", sizeof(decryptedBuffer));
... | [
-0.2539668083190918,
0.0727396234869957,
0.5429734587669373,
-0.24871061742305756,
-0.16565190255641937,
0.050627756863832474,
0.5700021982192993,
-0.4234007000923157,
-0.3439924418926239,
-0.42914748191833496,
-0.8426560163497925,
0.4124241769313812,
-0.3753246068954468,
-0.11647611856460... | |
NSLog(@"SecKeyGetBlockSize() public = %lu", SecKeyGetBlockSize([self getPublicKeyRef]));
// Error handling
// Encrypt using the public.
status = SecKeyEncrypt([self getPublicKeyRef],
PADDING,
plainBuffer, | [
-0.5039761066436768,
-0.10317771881818771,
-0.03160279244184494,
-0.1837129145860672,
0.06403364986181259,
0.13722549378871918,
0.5665050745010376,
0.07329776883125305,
-0.5691660046577454,
-0.6220844984054565,
-0.27970707416534424,
0.5297676920890808,
-0.21769694983959198,
-0.108540929853... | |
plainBufferSize,
&cipherBuffer[0],
&cipherBufferSize
);
NSLog(@"encryption result code: %ld (size: %lu)", | [
-0.06136580556631088,
-0.2274622917175293,
0.5058770775794983,
-0.3256881535053253,
-0.051755331456661224,
-0.041559766978025436,
0.2634746730327606,
-0.25797346234321594,
-0.34082329273223877,
-0.5958184599876404,
-0.5532031059265137,
0.2308487445116043,
-0.4323243796825409,
-0.0834975391... | |
status, cipherBufferSize);
NSLog(@"encrypted text: %s", cipherBuffer);
}
- (void)decryptWithPrivateKey:(uint8_t *)cipherBuffer plainBuffer:(uint8_t *)plainBuffer
{
OSStatus status = noErr;
size_t cipherBufferSize = strlen((char *)cipherBuffer);
NSLog(@"decryptWithPrivateKey: length of buffer: %lu", B... | [
-0.38438600301742554,
-0.15753355622291565,
0.4009471833705902,
-0.21059150993824005,
0.16670486330986023,
0.2355789691209793,
0.5504840612411499,
-0.07377148419618607,
-0.2935827970504761,
-0.6479361057281494,
-0.5739845037460327,
0.5538744330406189,
-0.19682396948337555,
0.00127787934616... | |
&cipherBuffer[0],
cipherBufferSize,
&plainBuffer[0], | [
-0.07607072591781616,
0.16942079365253448,
0.3551548421382904,
-0.3050430715084076,
-0.18247152864933014,
0.10176681727170944,
0.43653830885887146,
-0.1853707730770111,
-0.3395231068134308,
-0.22926974296569824,
-0.453307569026947,
0.19980858266353607,
-0.6160668730735779,
-0.1304281949996... | |
&plainBufferSize
);
NSLog(@"decryption result code: %ld (size: %lu)", status, plainBufferSize);
NSLog(@"FINAL decrypted text: %s", plainBuffer);
}
- (SecKeyRef)getPrivateKeyRef {
OSStatus resultCode = noErr;
SecKeyRef privateKeyReference = NULL;
// NSData *privateTag = [N... | [
-0.12497304379940033,
-0.3513553738594055,
0.6206777691841125,
-0.28946951031684875,
0.12552906572818756,
0.24633920192718506,
0.6114464998245239,
-0.3400258719921112,
-0.23710349202156067,
-0.47959768772125244,
-0.5268059372901917,
0.6025710105895996,
-0.44134023785591125,
-0.016919806599... | |
NSMutableDictionary * queryPrivateKey = [[NSMutableDictionary alloc] init];
// Set the private key query dictionary.
[queryPrivateKey setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass];
[queryPrivateKey setObject:privateTag forKey:(__bridge id)kSecAttrApplicationTag];
[q... | [
-0.4477705955505371,
0.05477728694677353,
0.6488849520683289,
-0.07053239643573761,
-0.127206951379776,
0.08016137778759003,
0.369345098733902,
-0.4505923092365265,
-0.19077394902706146,
-0.4900941848754883,
-0.25361040234565735,
0.4834502637386322,
-0.4787646234035492,
0.2246410846710205,... | |
NSLog(@"getPrivateKey: result code: %ld", resultCode);
if(resultCode != noErr)
{
privateKeyReference = NULL;
}
// [queryPrivateKey release];
// } else {
// privateKeyReference = privateKey;
// }
return privateKeyReference;
}
#pragma mark - View lifecycle
... | [
-0.26447755098342896,
-0.3490592837333679,
0.6190255880355835,
-0.30126601457595825,
-0.06587405502796173,
0.04185307025909424,
0.4296683967113495,
-0.26861771941185,
-0.3249671757221222,
-0.422627329826355,
-0.2460705190896988,
0.40889814496040344,
-0.15113778412342072,
-0.005269587971270... | |
loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
privateTag = [[NSData alloc] initWithBytes:privateKeyI... | [
-0.15415231883525848,
-0.48493891954421997,
0.8293046951293945,
-0.12339601665735245,
-0.1540382355451584,
0.6564038395881653,
0.07664085179567337,
0.16528081893920898,
-0.18956410884857178,
-0.5085829496383667,
-0.5035260915756226,
0.7198415398597717,
-0.23962698876857758,
-0.144472301006... | |
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
- (void)generateKeyPair:(NSUInteger)keySize {
OSStatus sanityCheck = noErr;
publicKey = NULL;
privateKey = NULL;
// LOGGING_FACILITY1( keySize == 512 || keySize == 1024 || keySize == 2048, ... | [
-0.14078718423843384,
-0.2793833017349243,
0.6443915367126465,
-0.0708545595407486,
0.3802086114883423,
0.25454461574554443,
0.6637306213378906,
-0.37067341804504395,
-0.15687812864780426,
-0.36791160702705383,
-0.3406521677970886,
0.7090021967887878,
-0.14850188791751862,
0.26584607362747... | |
init];
NSMutableDictionary * publicKeyAttr = [[NSMutableDictionary alloc] init];
NSMutableDictionary * keyPairAttr = [[NSMutableDictionary alloc] init];
// Set top level dictionary for the keypair.
[keyPairAttr setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
[keyPair... | [
-0.5710722804069519,
0.01067411433905363,
0.4819330871105194,
-0.037775419652462006,
-0.05955903232097626,
0.1051783412694931,
0.2827359735965729,
-0.31050676107406616,
-0.0420294925570488,
-0.3916534185409546,
-0.4652028977870941,
0.43159016966819763,
-0.33266234397888184,
0.0679584145545... | |
[publicKeyAttr setObject:publicTag forKey:(__bridge id)kSecAttrApplicationTag];
// See SecKey.h to set other flag values.
// Set attributes to top level dictionary.
[keyPairAttr setObject:privateKeyAttr forKey:(__bridge id)kSecPrivateKeyAttrs];
[keyPairAttr setObject:publicKeyAttr forKey:(__bridge id)k... | [
-0.2831743359565735,
-0.17255164682865143,
0.3434217572212219,
0.21573975682258606,
0.05926221236586571,
0.1273200660943985,
0.4997173249721527,
-0.44952520728111267,
-0.08705256134271622,
-0.3831329643726349,
-0.36668944358825684,
0.5001602172851562,
-0.3052823543548584,
0.042585890740156... | |
!= NULL)
{
NSLog(@"Successful");
}
// [privateKeyAttr release];
// [publicKeyAttr release];
// [keyPairAttr release];
}
@end
```
Let me know if you need more help.
Hope this helps. | [
-0.011996577493846416,
0.03995371237397194,
0.339307963848114,
-0.2701924741268158,
0.2996179163455963,
-0.2090076506137848,
0.8320218920707703,
-0.12956519424915314,
-0.16255101561546326,
-0.5311110615730286,
-0.5638205409049988,
0.6403772234916687,
-0.18219506740570068,
0.215385168790817... | |
I have two classes (they are persisted in RavenDB):
```
public class Game
{
public int Id { get; set; }
public int HomeTeamId { get; set; }
public int AwayTeamId { get; set; }
public DateTime GameTime { get; set; }
public string Location { get; set; }
public int HomeTeamScore { get; set; }
... | [
0.3238593637943268,
-0.4535372257232666,
0.3943243622779846,
0.0280124694108963,
0.2958995997905731,
0.09385214000940323,
-0.10275699198246002,
0.09865186363458633,
0.07819602638483047,
-0.7409359812736511,
-0.11154153198003769,
0.25772812962532043,
-0.019517051056027412,
0.286297261714935... | |
get; set; }
public int? PositionInGroup { get; set; }
public int? PositionInPlayOffs { get; set; }
public string Group { get; set; }
}
```
I want to output all the games with the team name, date and location like this:
> Poland - Greece, 2012-06-08 18:00:00 - Warsaw (POL)
I know I could include the home... | [
0.13968345522880554,
-0.38415080308914185,
0.3641009032726288,
-0.05949745699763298,
-0.23073486983776093,
-0.3917083144187927,
-0.01804482191801071,
-0.07469609379768372,
-0.6317541599273682,
-0.7490321397781372,
0.00355690554715693,
-0.19068880379199982,
-0.4360803961753845,
0.0240415409... | |
.Customize(c => c.Include<Game, Team>(i => i.Id))
.OrderBy(x => x.GameTime)
.ToList();
foreach (var g in games)
{
var homeTeam = session.Load<Team>(g.HomeTeamId);
var awayTeam = session.Load<Team>(g.AwayTeamId);
Console.WriteLine(
string.Format("{0} - {1}, {2} - {3}",
homeTeam.Name,... | [
-0.1644502580165863,
-0.45954015851020813,
0.5340175032615662,
-0.1992991715669632,
0.4821884036064148,
0.015597603283822536,
0.1936763972043991,
-0.38226914405822754,
-0.2312401682138443,
-0.8903365135192871,
-0.3955385386943817,
0.45062896609306335,
-0.42573580145835876,
0.17829096317291... | |
loop a get request should not be issued to the server? But when I look in the logs I can see this:
> Request #1 654: GET - 0 ms - Euro2012 - 200 - /docs/teams/34
>
>
> Document with key 'teams/34' was found
The first request issued to the server looks like this:
> Request #1 648: GET - 5 ms - Euro2012 - 200 - /ind... | [
0.27122288942337036,
-0.3359553813934326,
0.134029820561409,
0.21487852931022644,
-0.2437543421983719,
-0.4386161267757416,
0.1762753427028656,
-0.325973242521286,
-0.48474016785621643,
-0.1944412738084793,
-0.2960873246192932,
0.2762161195278168,
-0.7215908765792847,
-0.07543441653251648,... | |
compiler does not inline the call, i.e. you've introduced one extra method call.
There are also implications for legibility- if the `name` field is directly accessible within the class, why not refer to it directly? I find this easier to read, but some people find it inconsistent. | [
0.32661905884742737,
0.06859263777732849,
-0.42853474617004395,
0.23207995295524597,
-0.34065166115760803,
-0.2447044998407364,
0.18603551387786865,
0.007931563071906567,
0.025211196392774582,
-0.4721323549747467,
-0.09882263839244843,
0.3918251693248749,
-0.39965370297431946,
-0.075450792... | |
I'm relatively new to Python and struggling to reconcile features of the language with habits I've picked up from my background in C++ and Java.
The latest issue I'm having has to do with encapsulation, specifically an idea best summed up by Item 23 of Meyer's "*Effective C++*":
> [Prefer non-member non-friend funct... | [
-0.04261515289545059,
0.13638974726200104,
0.11200199276208878,
-0.2873733341693878,
-0.16614867746829987,
-0.10896757245063782,
0.3948051929473877,
-0.02631962113082409,
-0.20694851875305176,
-0.5074209570884705,
-0.13586780428886414,
0.45174381136894226,
-0.038969170302152634,
0.08620020... | |
self.dY = dY
def __str__(self):
return "->(" + str(self.dX) + ", " + str(self.dY) + ")"
def scale(self, scalar):
self.dX *= scalar
self.dY *= scalar
def scale(vector, scalar):
vector.dX *= scalar
vector.dY *= scalar
```
Given `v = Vector(10, 20)`, we can now either call `v.s... | [
-0.06946337968111038,
-0.4155329465866089,
0.6882435083389282,
-0.2736750543117523,
-0.5489193797111511,
0.6557501554489136,
-0.05052538588643074,
-0.55678790807724,
-0.42651548981666565,
-0.968035876750946,
0.24510334432125092,
0.6370923519134521,
-0.18135841190814972,
0.23186703026294708... | |
the two options - *if any* - is better, and why?**
Interesting question.
You're starting from a different place than most questions coming from Java programmers, which tend to assume that you need classes when you mostly don't. Generally, in Python there's no point in having classes unless you're specifically doing da... | [
0.2223052978515625,
-0.011263968423008919,
-0.5134124755859375,
0.2629140317440033,
-0.23213088512420654,
-0.019943850114941597,
0.11292237788438797,
0.06950029730796814,
-0.2698802947998047,
-0.42605841159820557,
-0.13269595801830292,
0.41425591707229614,
-0.21251976490020752,
-0.29784607... | |
makes sense for the function to be a method on Vector.
Where you might want to make it a standalone function (we don't really use the word "member" or "non-member") is if you need to make it work with multiple classes which don't necessarily inherit from each other or a common base. Thanks to duck-typing, it's fairly ... | [
0.14260819554328918,
-0.38110676407814026,
-0.19520173966884613,
0.2072630077600479,
-0.10654553025960922,
-0.0851188376545906,
-0.08903878182172775,
-0.0643560141324997,
-0.05076828971505165,
-0.25860831141471863,
-0.08497072756290436,
0.5024184584617615,
-0.3947790265083313,
-0.228609129... | |
There's a feature called anonymous class in C++. It's similar with anonymous struct in C. I think this feature is invented because of some needs, but I can't figure out what that is.
Can I have some example which really needs anonymous class?
The feature is there because `struct` and `class` are the same thing - anyt... | [
0.04682065173983574,
-0.17485876381397247,
-0.14151112735271454,
0.08859368413686752,
-0.3751591145992279,
-0.27098000049591064,
-0.02476388029754162,
0.3216489851474762,
-0.08161536604166031,
-0.523841381072998,
0.06499844789505005,
0.5073772668838501,
-0.3569989502429962,
0.0795244276523... | |
to that type by name.
It's less commonly used in C++, partly because C++ designs tend to be more type-oriented, and partly because you can't declare constructors or destructors for anonymous classes. | [
0.2740045189857483,
-0.12910324335098267,
-0.057573989033699036,
-0.1610986739397049,
-0.26858389377593994,
-0.20441389083862305,
0.009959952905774117,
0.06783860921859741,
-0.1245291605591774,
-0.2006295770406723,
-0.3156147301197052,
0.3631405532360077,
-0.593260645866394,
0.110170878469... | |
Suppose I have div and I want to fetch data and push data into that div. When the user scrolls within the div, the next set of data will be fetched and pushed into the div. How do I detect scroll bar position with jQuery? I don't want to use any plugin. I need jQuery code. Here is the sample link like ahttp://www.steve... | [
0.12615159153938293,
-0.2674589455127716,
0.780369758605957,
-0.1751674860715866,
0.17876379191875458,
0.14841030538082123,
-0.10643705725669861,
-0.388326495885849,
-0.16816087067127228,
-0.6068387031555176,
0.07895612716674805,
0.6482256650924683,
-0.08479344844818115,
0.0186666473746299... | |
$('.main_content').append(new_div.load('/path/to/script.php'));
}
});
```
This will append a new element to the main page container when the scrollbar reaches the bottom of the page. It also fills this new element with content loaded from an external script.
---
If you want to detect whether a user has scrolled ... | [
-0.0857471153140068,
0.053949180990457535,
0.952073872089386,
-0.3157363831996918,
0.07110459357500076,
-0.15750670433044434,
0.40518441796302795,
-0.2833026647567749,
-0.08484524488449097,
-0.6431106925010681,
-0.605358362197876,
0.5551787614822388,
-0.41166749596595764,
0.208220452070236... | |
I have just installed the Facebook C# SDK in my WP7 application using NuGet, so I am sure it is the latest version. However I can't seem to find any documentation for WP7 anywhere... All I am trying to do is authenticate the user using Facebook to gain their Facebook ID. Can someone please tell me how I can do this usi... | [
0.5947854518890381,
0.21524441242218018,
0.25585004687309265,
0.1554153561592102,
0.0365038737654686,
-0.37645667791366577,
0.2223997861146927,
0.03827410191297531,
-0.30130305886268616,
-0.5431906580924988,
0.1006065234541893,
0.470833420753479,
0.06266035884618759,
-0.17255152761936188,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.