text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
id = UrlParameter.Optional },
new {action = @"Index|Delete|Add"}
);
routes.MapRoute(
"test",
"homepage/{name}",
new { controller = "Homepage", action = "Test" }
);
```
This way the first route will only be used if the action value matches one provid... | [
-0.03651207685470581,
-0.3894357681274414,
0.5282458662986755,
0.22963297367095947,
-0.02948671020567417,
0.057787369936704636,
0.1609179824590683,
-0.22987058758735657,
-0.23362484574317932,
-0.9480586051940918,
-0.22622902691364288,
0.009569003246724606,
-0.33319130539894104,
0.036494571... | |
constraint, otherwise it will move to the next rule.
You will also have to make sure when you create user profiles, that no name should match one of your supported actions for the `default` route. | [
0.11279542744159698,
-0.2863341271877289,
0.4409898817539215,
0.07301179319620132,
0.23242774605751038,
-0.3275794982910156,
0.35336893796920776,
-0.0872633159160614,
-0.46738409996032715,
-0.5672527551651001,
-0.10445060580968857,
0.4833017885684967,
-0.5335798263549805,
0.078700348734855... | |
Using JavaScript I am pulling names out of webpage and stringing them together somehow (probably going with an array). Once I gather all the names together I need to make another string that gives all the email addresses of the names. The email addresses are not on the webpage so I will have to list every possible this... | [
0.33555442094802856,
0.23210930824279785,
0.1708502471446991,
-0.1540757417678833,
-0.15070228278636932,
0.0716516450047493,
0.30825909972190857,
-0.020757652819156647,
-0.016765408217906952,
-0.8099831342697144,
-0.17776910960674286,
0.4569069445133209,
-0.5625657439231873,
0.099792607128... | |
}
if (name == 'Bob'){ email == 'duckhunter89@gmail.com'; }
....
```
A switch statement, as your code is only if-elses :-)
No, honestly. The best thing would be if you'd find a simple algorithm to create an email address from any given name, like
```
function mail(name) {
return name.toLowerCase() + "@gmail.com";... | [
0.11199656128883362,
0.10767713189125061,
0.3656568229198456,
-0.0007983603863976896,
0.18237391114234924,
-0.03133624419569969,
0.2334337681531906,
-0.2058963030576706,
-0.2955034077167511,
-0.7133695483207703,
-0.11736109107732773,
0.651760458946228,
-0.37962040305137634,
-0.041988074779... | |
use:
```
var map = [{
algorithm: function(name) { return name+"@something"; },
names: ["Steve", "Bob", ...]
},{
algorithm: function(name) { return "info@"+name+".org"; },
names: ["Mark", ...]
}];
for (var i=0; i<map.length; i++)
if (map[i].names.indexOf(name) > -1) {
var email = map[i].algo... | [
0.10329879820346832,
0.046886418014764786,
0.7008013725280762,
-0.10516765713691711,
-0.0016639300156384706,
-0.20920516550540924,
0.15848039090633392,
-0.09795907884836197,
-0.15021900832653046,
-0.7156620621681213,
-0.34811049699783325,
0.6254631280899048,
-0.4251255989074707,
0.31702366... | |
if (domains[domain].indexOf(name) > -1)
var email = name.toLowerCase()+"@"+domain;
break;
}
```
Just try to reduce the amount of data to deliver to the client as much as you can. | [
-0.027412448078393936,
-0.029383458197116852,
0.4893711805343628,
-0.2411586344242096,
0.10820412635803223,
-0.3280526399612427,
0.4634329676628113,
-0.1267455816268921,
-0.09837557375431061,
-0.8429973721504211,
-0.11812470853328705,
0.6759788990020752,
-0.2961212992668152,
0.283207714557... | |
I have a simple example ([SVG source](http://pastie.org/3732822)) looks like you can see below. The **path** with id "**rect2816**" described in **d** attribute:
```
m 140.53571,188.625 0,148.1875 273.9375,0 0,-148.1875 -273.9375,0 z
m 132.25,42.03125 c 3.64586,0.0236 7.47296,0.12361 11.5,0.28125 36.65941,1.43507 57.... | [
-0.03914906084537506,
0.4666310250759125,
0.2889423370361328,
-0.05368650704622269,
-0.18573032319545746,
0.3385999798774719,
0.6077196002006531,
-0.31119686365127563,
-0.18778318166732788,
-0.7015374302864075,
0.1138094887137413,
0.2083733081817627,
-0.38759052753448486,
0.122089706361293... | |
each point of the second polygon.
<http://www.ariel.com.au/a/python-point-int-poly.html> | [
-0.14228500425815582,
0.017171109095215797,
0.010577261447906494,
-0.09835155308246613,
-0.4627538025379181,
0.5303007364273071,
-0.005536848679184914,
-0.20694857835769653,
-0.4198192358016968,
-0.03928109630942345,
-0.11501795798540115,
0.0501050166785717,
-0.27842286229133606,
-0.260458... | |
I am comfortable scraping HTML content by using the CSS elements as a method of identifying the section of content that I want, but I need to scrape the content of the section of a webpage:
```html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">... | [
0.038599010556936264,
0.3118304908275604,
0.7676594853401184,
-0.38975077867507935,
-0.06640300154685974,
-0.06876415759325027,
0.07765001803636551,
-0.39757341146469116,
-0.34051603078842163,
-0.791957437992096,
-0.13821399211883545,
0.24404491484165192,
0.3409120440483093,
0.031389474868... | |
<script type="text/javascript" src="js/tabpane.js"></script>
<link type="text/css" rel="StyleSheet" href="css/tab.webfx.css?v=2" />
<meta http-equiv="Author" content="Rare Creative Group" />
<meta http-equiv="Description" content="Experts in lone worker safety" />
<meta http-equiv="Keywords" content="... | [
0.12406237423419952,
0.35972079634666443,
0.2534339129924774,
-0.1478874236345291,
-0.021043557673692703,
0.046544138342142105,
0.5573386549949646,
-0.490313321352005,
-0.15170161426067352,
-0.5465903282165527,
-0.1857486069202423,
0.5547893643379211,
-0.27552253007888794,
-0.1717380583286... | |
codice setcenter:
var map = new GMap2( document.getElementById( "map" ) );
var customUI = map.getDefaultUI();
// Remove MapType.G_HYBRID_MAP
//customUI.maptypes.hybrid = false;
map.setUI(customUI);
//map.addControl( new GSmallMapControl() );
//map.addControl( new... | [
-0.1795281171798706,
-0.44957295060157776,
0.9025830626487732,
-0.15655861794948578,
-0.05042251572012901,
0.33270108699798584,
0.30906155705451965,
-0.5522894859313965,
-0.24412252008914948,
-0.6900732517242432,
-0.49163180589675903,
0.6458694338798523,
-0.42140093445777893,
-0.0587677992... | |
// Crea un nuovo marker nel punto specificato con una descrizione HTML associata:
function createMarker( point, description, primary_contact_id )
{
//var icon = new GIcon();
////icon.shadow = "/images/nuvola.png";
//icon.iconSize = new GSize(87, 38);
////i... | [
-0.03769751265645027,
-0.3279290497303009,
0.6750174760818481,
-0.09095407277345657,
-0.14413221180438995,
0.45772242546081543,
-0.2052980214357376,
-0.05037430673837662,
-0.302019864320755,
-0.501481294631958,
-0.2795407474040985,
0.45846065878868103,
-0.3932096064090729,
-0.0873517692089... | |
//icon.iconAnchor = new GPoint(6, 20);
//icon.infoWindowAnchor = new GPoint(5, 1);
//icon.image = "/img/.";
```
I need to somehow parse the latitude and longitude from this line:
```
map.setCenter( new GLatLng( 51.612308, -1.239453 ), 11 );
```
So in one column of my table I would like the ... | [
0.017750434577465057,
0.2734539806842804,
0.7855442762374878,
0.027986643835902214,
0.12314487993717194,
0.0838857963681221,
0.49049943685531616,
-0.2945314645767212,
-0.30506131052970886,
-1.0202915668487549,
-0.06383699923753738,
0.16190479695796967,
-0.09802402555942535,
-0.065018609166... | |
problem was to do with a redirect as soon as you log in to the site, I've sorted that and now when I do:
```
put page.root
```
I get the full source of the page that I expected. So now my code (after logging in) is:
```
html_doc = page.root
# Find the first <script> in the head that does not have src="..."
#script... | [
-0.37548574805259705,
0.09616895020008087,
0.7488045692443848,
-0.2977302074432373,
-0.047004226595163345,
-0.032720111310482025,
0.34625905752182007,
-0.10996005684137344,
-0.27242475748062134,
-0.7937172055244446,
-0.1490655541419983,
0.40608957409858704,
-0.33710265159606934,
-0.0815448... | |
the returned parts are strings, and so you may need to call `to_f` on them to perform calculations:
```ruby
require 'nokogiri'
html_doc = Nokogiri.HTML(my_html)
# Find the first <script> in the head that does not have src="..."
script = html_doc.at_xpath('/html/head/script[not(@src)]')
# Use a regex to find the corr... | [
-0.24118275940418243,
-0.04341239482164383,
0.5139576196670532,
-0.06314817070960999,
0.08461685478687286,
0.06915915012359619,
0.14888228476047516,
-0.40270519256591797,
0.17632903158664703,
-0.4705987572669983,
-0.41541528701782227,
0.32999566197395325,
-0.23974700272083282,
-0.216532558... | |
matching a particular criterion.
**Edit**: If you are using Mechanize, it uses Nokogiri internally to parse and process the document. You can either get the Nokogiri HTML Document object directly via the code
```
html_doc = my_mechanize_page.root
```
…or you can use the [`Mechanize::Page#at`](http://mechanize.ruby... | [
0.12179581075906754,
0.11691538989543915,
0.3680672347545624,
0.00865496601909399,
-0.6904208660125732,
0.02229447104036808,
0.4905226528644562,
-0.906313955783844,
0.2219831496477127,
-0.743253231048584,
-0.04520602524280548,
0.8977869153022766,
-0.43389251828193665,
0.03328883275389671,
... | |
How to organize rspec 2 tests into 'unit' (fast) and 'integration' (slow) categories?
* I want to be able to run all unit tests with just `rspec` command, but not the 'integration' tests.
* I want to be able to run only 'integration' tests.
We have groups of the same nature.
We run then one by one both on the local d... | [
0.40601155161857605,
-0.2808215022087097,
0.263248085975647,
0.16541418433189392,
-0.15572230517864227,
-0.2171729952096939,
0.05615760013461113,
-0.918063759803772,
0.20984207093715668,
-0.741378903388977,
-0.10632476210594177,
0.5318785309791565,
-0.4146435856819153,
-0.09924399852752686... | |
|f| f['/api/v1'] || f['/integration'] }
end
RSpec::Core::RakeTask.new(:api) do |t|
t.pattern = "spec/*/{api/v1}*/**/*_spec.rb"
end
RSpec::Core::RakeTask.new(:integration) do |t|
t.pattern = "spec/integration/**/*_spec.rb"
end
end
``` | [
-0.026189537718892097,
-0.09363897144794464,
0.6772246360778809,
-0.17140738666057587,
0.21474666893482208,
0.09296949207782745,
0.16443395614624023,
-0.7897188067436218,
-0.24624526500701904,
-0.39145249128341675,
-0.3960621953010559,
0.4664037227630615,
-0.4598248600959778,
0.15343995392... | |
I believe, that this question is duplicated, but i can't find it =(.
How to create own UIView class, which is loaded from (iPhone/iPad)\*.xib
I was trying next things:
```
@interface CurtainView : UIView
```
...
```
- (id)init {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {... | [
-0.11586632579565048,
-0.05382397770881653,
0.989788293838501,
-0.3193100392818451,
0.08658500015735626,
0.2592886686325073,
0.44825616478919983,
-0.2767045795917511,
-0.15236727893352509,
-0.775378406047821,
0.2781193256378174,
0.6936371326446533,
-0.15253737568855286,
0.1326669454574585,... | |
self = [[[NSBundle mainBundle] loadNibNamed:@"CurtainView_ipad" owner:self options:nil] objectAtIndex:0];
[self setFrame:CGRectMake(0, 0, 768, 1004)];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
NSLog(@"there should be some animation on view appirance");
}
```
and ...
```
CurtainView* curta... | [
0.19738993048667908,
-0.2005004733800888,
1.043624997138977,
-0.1468571275472641,
-0.20339195430278778,
0.4170924127101898,
0.3187640905380249,
-0.4673403203487396,
-0.0507071316242218,
-0.7997694611549377,
0.08969726413488388,
0.5970171093940735,
-0.22561503946781158,
-0.06004258990287781... | |
on the CI.
you can simply do
```
bundle exec rake spec:unit
bundle exec rake spec:integration
bundle exec rake spec:api
```
This is what our spec.rake looks like
```
namespace :spec do
RSpec::Core::RakeTask.new(:unit) do |t|
t.pattern = Dir['spec/*/**/*_spec.rb'].reject{ |f| f['/api/v1'] || f['/integra... | [
0.5645116567611694,
-0.26806408166885376,
0.5754207372665405,
0.4166050851345062,
0.1148558035492897,
-0.3952968120574951,
-0.2973644435405731,
-0.5482487678527832,
-0.020609548315405846,
-0.7229650020599365,
-0.23562699556350708,
0.4596848785877228,
-0.18931318819522858,
0.639743506908416... | |
I have a variable which I need to strip of sybols before inserting into my database, any ideas how I would add the mysql\_real\_escape\_string() function to my existing code?
Form page
This page is a basic html form which shows the database content.
```
<?php
$query = sprintf( "SELECT * FROM sitecontent WHERE ID =... | [
-0.02281959354877472,
0.1096760481595993,
0.8130361437797546,
-0.032210733741521835,
-0.018894854933023453,
0.03520284220576286,
0.19026711583137512,
-0.47893935441970825,
-0.057799745351076126,
-0.6324189901351929,
-0.17517141997814178,
0.01619316078722477,
-0.15666115283966064,
0.0775345... | |
for="pCategory" style="padding:10px; ">Category</label>
<input type="text" name="pCategory" style=" width:50px;border:#000099; margin:10px;" value="<?php echo $post['Post_Year']; ?>"/>
<label for="pItem" style="padding:10px;">Item Type</label>
<select name="pItem" style="border:#000099; margin:10px;">
<o... | [
-0.23668497800827026,
0.2503528892993927,
0.8097257018089294,
-0.166396364569664,
-0.07047203183174133,
0.1855631172657013,
0.0928126648068428,
-0.4992561638355255,
-0.2585213780403137,
-0.27307218313217163,
-0.20913712680339813,
0.20332297682762146,
0.01001047808676958,
0.0964343622326850... | |
<option value="0">None</option>
<option value="1">Home</option>
</select>
<label for="pPriority" style="padding:10px;">Home Priority</label>
<select name="pPriority" style="border:#000099; margin:10px;">
<option value="0">None</option>
<option value="1">1</option>
<option value="2">2</option>
<option valu... | [
-0.6080900430679321,
-0.1706288903951645,
0.7017245888710022,
-0.01874343678355217,
-0.17875932157039642,
0.7674076557159424,
0.17686156928539276,
-0.49293118715286255,
-0.3940724730491638,
-0.6198350191116333,
-0.5526899695396423,
0.38664010167121887,
-0.10617323964834213,
-0.115859121084... | |
echo $post['Image_Name']; ?>"/>
<label for="pApproval" style="padding:10px;">Approval</label>
<select name="pApproval" style="border:#000099; margin:10px;">
<option value="0">Pending</option>
<option value="1">Approved</option>
</select>
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>"/>... | [
0.05693647637963295,
0.0012489354703575373,
0.8296934366226196,
-0.15598854422569275,
-0.10965687781572342,
-0.22777478396892548,
0.00039791673771105707,
-0.6619411110877991,
-0.18747033178806305,
-0.34210556745529175,
-0.32659441232681274,
0.17928288877010345,
-0.24697567522525787,
-0.225... | |
the database.
```
<?php
include'includes/connection.php';
$pName = $_POST['pName'];
$pItem = $_POST['pItem'];
$pCategory = $_POST['pCategory'];
$pDate = $_POST['pDate'];
$pAuthor = $_POST['pAuthor'];
$pContent = $_POST['pContent'];
$Page = $_POST['Page'];
$id = $_POST['id'];
$pApproval = $_POST['pApprova... | [
-0.3477959632873535,
-0.2014305144548416,
0.8384449481964111,
0.29794931411743164,
0.0860944539308548,
0.32571741938591003,
-0.20472833514213562,
-0.10917812585830688,
-0.3175952136516571,
-0.6460351347923279,
-0.4670409858226776,
0.1565137356519699,
-0.12078999727964401,
0.181323647499084... | |
header("Location:admin.php");
?>
```
For strings just say:
```
$pName = mysql_real_escape_string($_POST['pName']);
```
For integers:
```
$id = intval($_POST['id']);
```
That's all there is to it; just do it for all your variables
**edit**
Anyways, I'd advise you to use PDO in stead, way better to prevent s... | [
0.13399720191955566,
0.06000809744000435,
0.19200800359249115,
0.02874448522925377,
-0.018577171489596367,
-0.26594647765159607,
0.1794682890176773,
-0.07751384377479553,
-0.1060100793838501,
-0.5318253636360168,
-0.03274792805314064,
0.37101468443870544,
-0.42226800322532654,
-0.109467901... | |
I have following jQuery function to make textbox accepting only decimal number, but problem is it didn't accept `.` , so it works as only integer textbox,
I don't want to use any plugin
here is the jQuery function :
```
$(document).ready(function () {
$("#textbox1").keydown(function(event)
{
if (even... | [
-0.11441884189844131,
-0.019071560353040695,
0.5433219075202942,
-0.06055274233222008,
0.13751745223999023,
-0.08346705883741379,
0.09060250222682953,
-0.2741033732891083,
-0.10808181017637253,
-0.34239980578422546,
-0.14297164976596832,
0.847666323184967,
-0.1328112781047821,
-0.103747926... | |
return;
}
else if(event.keyCode == 46)
{
return;
}
else
{
if ((event.keyCode < 48 || event.keyCode > 57) && | [
0.04222564026713371,
-0.19760236144065857,
-0.09854159504175186,
-0.2860250473022461,
0.3508301079273224,
0.16969357430934906,
0.38548746705055237,
-0.5352780222892761,
-0.11023210734128952,
-0.1528000682592392,
-0.29118847846984863,
0.592823326587677,
-0.06951718777418137,
0.1121805384755... | |
(event.keyCode < 96 || event.keyCode > 105 ))
{
event.preventDefault();
}
}
});
});
```
[Fiddle is here](http://jsfiddle.net/VKrLx/)
```
$("#textbox1").keydown(function(e){
var key = e.which;
// backspace, tab, left arrow, up arrow, right arrow... | [
-0.5318072438240051,
-0.005701737478375435,
0.5869918465614319,
-0.2985805869102478,
0.15654167532920837,
0.21491891145706177,
0.3105238378047943,
-0.3433256149291992,
-0.4201053977012634,
-0.3918642997741699,
-0.13219964504241943,
0.6027551889419556,
0.12847600877285004,
0.130917012691497... | |
pt, period, enter
if (key != 8 && key != 9 && key != 37 && key != 38 && key != 39 && key != 40 && key != 46 && key != 110 && key != 190 && key != 13){
if (key < 48){
e.preventDefault();
}
else if (key > 57 && key < 96){ | [
0.1912522315979004,
-0.49940675497055054,
0.5384559631347656,
-0.14500823616981506,
0.6063982248306274,
0.23947462439537048,
0.2834186851978302,
-0.758621335029602,
-0.015394710935652256,
-0.08754127472639084,
-0.34029650688171387,
0.4758380055427551,
-0.16144239902496338,
0.17693151533603... | |
e.preventDefault();
}
else if (key > 105) {
e.preventDefault();
}
}
});
``` | [
0.022813117131590843,
0.10725397616624832,
0.40502607822418213,
-0.5533115863800049,
0.2461588829755783,
-0.15216654539108276,
0.49649715423583984,
-0.5805338621139526,
0.22963373363018036,
-0.45595893263816833,
-0.6217300891876221,
0.5794953107833862,
-0.4649750590324402,
0.18937948346138... | |
I have a GAE project written in Java and I have some thoughts about the HRD and a problem that I'm not sure how to solve.
Basically I have users in my system. A user consists of a userid, a username, an email and a password. Each time I create a new user, I want to check that there isn't already a user with the same u... | [
0.11320260912179947,
0.19359537959098816,
0.3405558168888092,
0.029232781380414963,
-0.01087028905749321,
0.15403681993484497,
0.15381348133087158,
0.03471740335226059,
0.11338597536087036,
-0.7386390566825867,
-0.04063865914940834,
0.49055683612823486,
-0.1124982237815857,
0.2544931769371... | |
possible users with the same username or email, I can't be sure that the results are consistent. So if someone has created a user with the same username or email a couple of seconds ago, I might not find it with my query. I understand that ancestors are used to work around this problem, but what if I don't have an ance... | [
0.20903602242469788,
0.10680387914180756,
-0.014905108138918877,
0.28900229930877686,
0.0731809139251709,
0.07517998665571213,
0.4111379086971283,
0.11422024667263031,
-0.30892616510391235,
-0.7778357267379761,
0.2800654172897339,
0.28770434856414795,
-0.2439960539340973,
0.430572420358657... | |
that changes anything.
I wouldn't recommend using email or any other natural key for your User entity. Users change their email addresses and you don't want to end up rewriting all the foreign key references in your database whenever someone changes their email.
Here's a short blurb on how I solve this issue:
<https:... | [
0.12869131565093994,
0.2555939853191376,
0.2618066072463989,
-0.04555721953511238,
-0.08319661021232605,
-0.1259957104921341,
0.19694310426712036,
0.19376656413078308,
-0.2543402910232544,
-0.742490291595459,
0.04180930554866791,
0.208136186003685,
-0.4514963924884796,
0.2518579065799713,
... | |
email addresses for lookup */
public static String normalize(String email) {
return email.toLowerCase();
}
@Id String email;
@Index long personId;
public EmailLookup(String email, long personId) {
this.email = normalize(email);
this.personId = personId;
}
}
```
There ... | [
-0.24317875504493713,
-0.07010404020547867,
0.534527063369751,
-0.21402648091316223,
0.11066894233226776,
0.10838496685028076,
0.334952712059021,
0.01147677656263113,
-0.017005668953061104,
-0.510219395160675,
-0.29712778329849243,
0.415517657995224,
-0.5144466757774353,
0.0103699564933776... | |
creates an account with a particular email, I load/create the EmailLookup and the User entities by key **in a XG transaction**. This guarantees that any individual email address will be unique.
The same strategy applies for any other kind of unique value; facebook id, username, etc. | [
0.46180060505867004,
0.3621293306350708,
0.3648490011692047,
-0.006153697147965431,
-0.07088793069124222,
-0.10511531680822372,
0.02312108501791954,
0.18972156941890717,
0.000014324097719509155,
-0.6149959564208984,
-0.12842170894145966,
0.11129649728536606,
-0.025186240673065186,
0.180824... | |
Following is my php login script, There are one problem. If i put any password then it's doesn't validate the password and it's going to user panel page. where is the wrong in my code, can anyone tell me the right direction
N:B: I'M NEW IN PHP ALSO NEW IN THIS SITE.
```
<?php
if(isset($_POST['action']) && isset($_POS... | [
-0.36807411909103394,
-0.017210321500897408,
0.4966259002685547,
-0.14425502717494965,
-0.2543557286262512,
0.18642613291740417,
0.46298152208328247,
-0.5735085606575012,
-0.27512845396995544,
-0.5481691956520081,
-0.17226296663284302,
0.42983219027519226,
-0.4062938988208771,
-0.064497746... | |
FROM members");
$re = mysql_fetch_array($userid);
$userid = (int) $re['userid'];
if(isset($uname) && isset($pass))
{
if(empty($uname) && empty($pass))
$err[] = "All field required";
else
{
// username validation process....
if(empty($uname))
$err[] = "Username ... | [
0.003963064402341843,
-0.1376960277557373,
0.6887040138244629,
-0.20237162709236145,
0.13673534989356995,
0.06968189775943756,
0.4333461821079254,
-0.8785431385040283,
-0.36375272274017334,
-0.3479995131492615,
-0.6694537997245789,
0.4875306189060211,
-0.3301048278808594,
0.133698523044586... | |
if($num_uname == 0)
$err[] = "Username is not correct";
}
// password validaiton process...
if(empty($pass))
$err[] = "Password required";
else | [
-0.08980409055948257,
-0.13781119883060455,
0.39954474568367004,
-0.2185692936182022,
0.23290185630321503,
-0.14159564673900604,
0.5652170181274414,
-0.465239942073822,
-0.02461014688014984,
-0.37782204151153564,
-0.4335867464542389,
0.6691819429397583,
-0.0743555799126625,
0.2140299677848... | |
{
if($num_pass == 0)
$err[] = "Password is not correct";
}
}
}
if(!empty($err))
{
foreach($err as $er)
{
echo "<font color=red>$er<br></font>";
}
}
else
{
include("user/include/newsession.php"); | [
0.08541309088468552,
0.06667347252368927,
0.40271300077438354,
-0.5090851783752441,
0.08836669474840164,
0.050570160150527954,
0.3720078468322754,
-0.5066606402397156,
-0.020617838948965073,
-0.2965262830257416,
-0.5830016136169434,
0.5715031027793884,
-0.3681986629962921,
-0.0134306438267... | |
header("Location:user/index.php");
}
}
?>
```
So many thing are wrong here
Replace
```
if (isset ( $_POST ['action'] ) && isset ( $_POST ['action'] ) == 'Log In') {
```
With
```
if (isset ( $_POST ['action'] ) && $_POST ['action'] == 'Log In') {
```
Too many things to replace .. hold... | [
0.2080613374710083,
-0.12487953901290894,
0.374507874250412,
0.11861550807952881,
0.13821417093276978,
-0.2515293061733246,
0.4331653416156769,
-0.35344967246055603,
-0.29073089361190796,
-0.513242244720459,
-0.35170990228652954,
0.5145871043205261,
-0.4601184129714966,
-0.1499102860689163... | |
) && $_POST ['action'] == 'Log In') {
$uname = prepareStr ( $_POST ['uname'] );
$pass = prepareStr ( $_POST ['pass'] );
$shaPass = hash ( 'sha512', $pass );
$errors = array ();
include_once ("toplevel/content/manage/dbcon/dbcon.php");
if (! isset ( $uname ) || empty ( $uname )) {
$err ... | [
-0.38902685046195984,
-0.02177606150507927,
0.48255887627601624,
-0.2849017381668091,
-0.007692799903452396,
0.1572624146938324,
0.6124178767204285,
-0.7179307341575623,
-0.1880842000246048,
-0.3646741509437561,
-0.649613082408905,
0.307678759098053,
-0.37469884753227234,
0.094296991825103... | |
$err [] = "Empty Password not allowed";
}
if (count ( $err ) == 0) {
$mysqli = new mysqli ( "localhost", "root", "", "test" ); // Replace with | [
-0.24399887025356293,
-0.2311384677886963,
0.4489413797855377,
-0.23302793502807617,
0.3737107515335083,
-0.0027869483456015587,
0.4545136094093323,
-0.14644771814346313,
-0.030333098024129868,
-0.461601585149765,
-0.2564559280872345,
0.7827345132827759,
-0.28041914105415344,
0.13680332899... | |
// DB
// Information
$result = "SELECT uname ,pass FROM members WHERE uname = '$uname' AND | [
0.06729134917259216,
-0.37501752376556396,
0.06381082534790039,
-0.14852075278759003,
0.08491063863039017,
0.07926158607006073,
0.2684074342250824,
-0.5555325746536255,
0.15762361884117126,
-0.3693420886993408,
-0.291803777217865,
0.13269200921058655,
-0.2823553681373596,
0.316962480545043... | |
pass = '$shaPass'";
if ($result->num_rows > 0) {
$err [] = "Invalid username or Password";
}
if (count ( $err ) == 0 && $result) {
$userInfo = $result->fetch_assoc ();
/**
* You can do what every you like here | [
-0.048631612211465836,
-0.42996546626091003,
0.8056257367134094,
-0.11679334938526154,
0.03885941579937935,
0.00023958735982887447,
0.32796308398246765,
-0.528964102268219,
-0.3159154951572418,
-0.6748921871185303,
-0.2112942785024643,
0.2919820547103882,
-0.3310053050518036,
0.21876376867... | |
*/
}
}
if (count ( $err ) > 0) {
/**
* Kill the user
*/
echo "<pre>";
foreach ( $err as $value ) {
echo $value . "\n"; | [
0.34588074684143066,
0.10728976875543594,
0.2978571355342865,
-0.7674548625946045,
0.36317476630210876,
0.09697256982326508,
0.7141366004943848,
-0.5254313945770264,
0.055594176054000854,
-0.2749958038330078,
-0.1754312962293625,
0.41000935435295105,
-0.6253769397735596,
0.5127910375595093... | |
}
die ( "Die! Die! Die!" );
}
}
function prepareStr($str) {
$str = htmlspecialchars ( $str );
$str = trim ( $str );
$str = mysql_real_escape_string ( $str );
return $str;
}
```
Thanks | [
0.11169002205133438,
0.13314701616764069,
0.7454347610473633,
-0.3276366591453552,
0.0584406852722168,
0.26054856181144714,
0.6438378691673279,
-0.3500276505947113,
0.09563808888196945,
-0.5559832453727722,
-0.3245879113674164,
0.35808035731315613,
-0.15551503002643585,
0.0861552357673645,... | |
I've recently started using APC cache on our servers. One of the most important parts of our product is a CLI (Cron/scheduled) process, whose performance is critical. Typically the batchjob consists of running some 16-32 processes in parallel for about an hour (they "restart" every few minutes).
By default, using APC ... | [
0.13018301129341125,
0.15215229988098145,
0.498168408870697,
0.07598669826984406,
0.3590700030326843,
-0.05537229776382446,
0.05768727883696556,
-0.07238878309726715,
-0.1905362457036972,
-0.4786977767944336,
-0.06602369248867035,
0.4110199809074402,
-0.23663966357707977,
0.087454795837402... | |
batchjob, stored in a single dumpfile and having the individual processes load the dumpfile.
Does anybody have any experience with such a scenario or can you give good reasons why it will or will not work? If any significant gains could reasonably be had, either in memory use or performance? What pitfalls are lurking ... | [
0.35187041759490967,
-0.053940948098897934,
0.24696965515613556,
0.14192600548267365,
0.3480585813522339,
-0.2676421105861664,
0.033479414880275726,
0.47110456228256226,
-0.31471094489097595,
-0.45492178201675415,
0.028321633115410805,
0.4185057282447815,
0.093578040599823,
-0.211664453148... | |
cache that is why it seems like its doing nothing, it is actually doing nothing. Delete dump file, start with just the basics, if that doesn't work forget it try a new machine, new OS, if it is working make a copy, piece by piece expand functionality - there are loads of things that won't work, if it is working commit ... | [
0.5025178790092468,
0.367912620306015,
-0.03449026867747307,
0.4504891633987427,
0.26085326075553894,
0.11083921790122986,
0.32885006070137024,
-0.12927615642547607,
-0.09052041918039322,
-0.7640306949615479,
0.2040211707353592,
0.6647760272026062,
-0.09148170053958893,
0.00666245445609092... | |
new results.
Ready? This is what you've been waiting for:
Enable apc for cli
------------------
[apc.enable-cli](http://www.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli)=1
> it is not ideal to create, populate and destroy the APC cache on every CLI request
>
>
>
> ```
> - previous answer by unkn... | [
0.23683331906795502,
0.12852822244167328,
0.5966589450836182,
0.13587595522403717,
0.2691097855567932,
-0.27801474928855896,
0.523684561252594,
0.040655527263879776,
-0.27633076906204224,
-0.7788686156272888,
-0.4376119375228882,
0.7043115496635437,
-0.5746707320213318,
0.11571985483169556... | |
not enabled,
apc_bin_dumpfile not available.
```
**Warning:** I suggest you don't enable cli in php.ini, it is not worth the frustration, you are going to forget you did it and have numerous other headaches with other scripts, trust me its not worth it, use a launcher script instead. (see below)
apc\_... | [
-0.06327779591083527,
0.0927908793091774,
0.4233686029911041,
0.05044190585613251,
0.17831668257713318,
-0.31321731209754944,
0.40459585189819336,
0.1498342752456665,
-0.17056967318058014,
-0.5823922157287598,
-0.4177834689617157,
0.7785388231277466,
-0.5058821439743042,
-0.164184331893920... | |
Cached files must be included using full path with apc.stat=0.
```
launcher script - php-apc.sh
----------------------------
We will use this script to launch our apc enabled scripts (ex. `./php-apc.sh apc-cli.php`) instead of changing the properties in `php.ini` directly.
```
#/bin/sh
php -d apc.enable_cli=1 -d a... | [
0.14278626441955566,
0.14339204132556915,
0.5157409906387329,
0.18425561487674713,
0.3702912926673889,
-0.16372981667518616,
0.3197821378707886,
-0.3041767179965973,
0.13093328475952148,
-0.6985499858856201,
-0.26783621311187744,
0.7254545092582703,
-0.1722155213356018,
-0.0836738348007202... | |
/** fetch what was stored last run just for fun */
if (false !== $value = apc_fetch('my.awesome.apc.store'))
echo "$value from apc\n";
/** store what gets fetched the next run just for fun */
apc_store('my.awesome.apc.store', 'awesome in cli');
/** what a shlep lets not do that all over again shall... | [
0.5056959986686707,
-0.04489292949438095,
0.4056079387664795,
0.04481559246778488,
0.11557911336421967,
-0.1997470110654831,
0.3842874765396118,
-0.34468984603881836,
-0.29924941062927246,
-0.3414306044578552,
-0.2793373763561249,
0.8949052691459656,
-0.1812330037355423,
-0.267864733934402... | |
and not relative paths - as returned by `stream_resolve_include_path();` avoid `include_once`, `require_once` use the non `*_once` counterparts; check your stat usage, when **not using APC**(Muchos important senor), with the help of a StreamWrapper echo for calls to method `url_stat;` Oops: Fatal scope over-run error! ... | [
0.08767316490411758,
-0.14544177055358887,
0.25421276688575745,
0.26925235986709595,
0.023705845698714256,
-0.19955065846443176,
0.49947047233581543,
-0.0056909299455583096,
-0.09429772198200226,
-0.5329782366752625,
-0.05253862962126732,
0.8710107803344727,
-0.3615909218788147,
-0.1099471... | |
file called apc.dump see if you can find it? If you can't find it then it didn't work, sorry.
Good we have the dump file there were no errors lets run it again.
```
./php-apc.sh apc-cli.php
```
What you want to see:
```
awesome in cli from apc
```
Success! =)
There are few in PHP as satisfying as a working APC ... | [
0.39191555976867676,
0.07676830142736435,
0.17384123802185059,
0.17138904333114624,
-0.069057397544384,
-0.42202702164649963,
0.36150816082954407,
0.07687728106975555,
-0.07000736147165298,
-0.4527040123939514,
0.16254088282585144,
0.7732309103012085,
-0.17349667847156525,
-0.2903915941715... | |
Let's say you had an external process writing files to some directory, and you had a separate process periodically trying to read files from this directory. The problem to avoid is reading a file that the other process is currently in the middle of writing out, so it would be incomplete. Currently, the process that rea... | [
0.5717635750770569,
0.36914196610450745,
0.1979849934577942,
0.08766404539346695,
0.39812418818473816,
-0.2076769918203354,
0.27092376351356506,
0.27364373207092285,
-0.5200014710426331,
-0.5463290214538574,
0.00533452071249485,
0.2206517606973648,
0.10885915160179138,
0.7158216238021851,
... | |
of different formats) is there some reliable way to check the file header for the number of bytes that should be in the file, vs the number of bytes currently in the file to confirm they match?
Thanks for any thoughts or ideas!
You could use an external marker file. The writing process could create a file XYZ.lock bef... | [
0.498661607503891,
0.13213293254375458,
0.40612250566482544,
0.426349937915802,
0.08322418481111526,
-0.10807178914546967,
0.1835632026195526,
-0.0068314652889966965,
-0.23298220336437225,
-0.5894888639450073,
-0.03601665794849396,
0.54326993227005,
-0.10851375758647919,
0.0651124939322471... | |
This is supposed to work yet just says no stocks table - supposed lost the connection somewhere inside the contextmanager?
```
import sqlite3
from contextlib import contextmanager
@contextmanager
def doquery(conn, q, params=()):
c = conn.cursor()
c.execute(q, params)
conn.commit()
yield c
c.cl... | [
0.03233844414353371,
0.1671917736530304,
0.524648129940033,
-0.030614685267210007,
0.07754089683294296,
0.04649382457137108,
-0.05381571874022484,
-0.34158259630203247,
-0.2641104757785797,
-0.3084642291069031,
-0.09572651237249374,
0.5986841320991516,
-0.39348915219306946,
0.1907042115926... | |
('2006-01-05','BUY','RHAT',100,35.14)""")
with doquery(db, 'select * from stocks') as r:
for row in r:
print row
```
The problem is with the way you are using the context manager. Calling `doquery` simply creates a context manager object - you need to use it within a `with` statement, which ca... | [
-0.4344147741794586,
0.13051265478134155,
0.2753371596336365,
-0.2933863401412964,
0.03563879802823067,
0.1524464190006256,
-0.03682974353432655,
-0.36404871940612793,
-0.07357066869735718,
-0.3409966230392456,
-0.18448328971862793,
0.7455997467041016,
-0.3512866199016571,
0.16912677884101... | |
t:
print(t)
```
The output I get is:
```
<contextlib._GeneratorContextManager object at 0xcf3e90>
entering
attempt 2
exiting
```
You might want to re-read the documentation about [the with statement](http://www.python.org/dev/peps/pep-0343/) and [contextlib](http://docs.python.org/library/contextlib.html).
An... | [
0.019562112167477608,
0.1093386560678482,
0.4153924882411957,
-0.27667126059532166,
-0.07485488802194595,
-0.02229919843375683,
0.27249911427497864,
-0.29232141375541687,
-0.23968830704689026,
-0.44394761323928833,
-0.3470783829689026,
0.834342360496521,
-0.5449943542480469,
-0.01388265751... | |
c.execute(q, params)
conn.commit()
yield c
finally:
c.close()
with sqlite3.connect(':memory:') as db:
with doquery(db,'''create table stocks
(date text, trans text, symbol text,
qty real, price real)'''):
pass
with | [
0.08126668632030487,
0.08301524817943573,
0.5592989921569824,
-0.04697348177433014,
-0.17498435080051422,
0.08987608551979065,
-0.029286744073033333,
-0.40227043628692627,
0.03403085470199585,
-0.370828777551651,
-0.3295721411705017,
0.5374239087104797,
-0.2750757932662964,
0.1973906308412... | |
doquery(db,"""insert into stocks
values ('2006-01-05','BUY','RHAT',100,35.14)"""):
pass
with doquery(db, 'select * from stocks') as r:
for row in r:
print(row)
```
However, I don't think this is the cleanest way of doing this. As far as I can see, there is no reason t... | [
-0.07728028297424316,
0.26616936922073364,
0.45716676115989685,
0.11252287030220032,
-0.26862162351608276,
-0.05226307734847069,
-0.10451166331768036,
-0.31650564074516296,
0.021705787628889084,
-0.30957847833633423,
-0.06092345342040062,
0.4097716510295868,
-0.15708090364933014,
0.1740345... | |
I don't think the call to `conn.commit` is actually necessary either - using the database connection as a context manager will automatically commit transactions, or roll them back if an exception is raised (see the [sqlite3 module documentation](http://docs.python.org/library/sqlite3.html)).
EDIT: Here is a much clean... | [
-0.042461030185222626,
0.36063724756240845,
0.3927382528781891,
-0.24815212190151215,
-0.22331976890563965,
-0.14390727877616882,
0.022185374051332474,
-0.21841834485530853,
-0.2970809042453766,
-0.5785860419273376,
-0.12834854423999786,
0.6141860485076904,
-0.48929286003112793,
0.23787699... | |
(date text, trans text, symbol text,
qty real, price real)''')
c.execute("""insert into stocks
values ('2006-01-05','BUY','RHAT',100,35.14)""")
c.execute('select * from stocks')
for row in c:
print(row)
``` | [
0.0972777009010315,
0.14420031011104584,
0.25124219059944153,
-0.17745880782604218,
0.2488047331571579,
0.33798009157180786,
-0.3090263307094574,
-0.42857152223587036,
-0.146927148103714,
-0.11615535616874695,
-0.5734532475471497,
0.4941667318344116,
-0.19744524359703064,
0.220764458179473... | |
I went through the documentation of [open3](http://perldoc.perl.org/IPC/Open3.html) and here is the portion that I could not understand:
> If you try to read from the child's stdout writer and their stderr
> writer, you'll have problems with blocking, which means you'll want to
> use select() or the IO::Select, which ... | [
0.09755659103393555,
-0.046782754361629486,
0.10279296338558197,
-0.016947530210018158,
-0.1055905744433403,
0.03438952565193176,
0.29467979073524475,
-0.0813591480255127,
-0.09756253659725189,
-0.6237633228302002,
-0.03260074928402901,
0.07935559749603271,
-0.21622584760189056,
0.06527149... | |
a line at a time and output a line at a time. Programs
> like sort that read their entire input stream first, however, are
> quite apt to cause deadlock.
So I tried out `open3` hoping to know it better. Here is the first attempt:
```
sub hung_execute {
my($cmd) = @_;
print "[COMMAND]: $cmd\n";
my $pid = o... | [
-0.1450994461774826,
-0.4170539081096649,
0.5515630841255188,
-0.34876126050949097,
-0.19416433572769165,
0.3117723762989044,
0.3899577260017395,
-0.2285870611667633,
-0.1670268028974533,
-0.5229378342628479,
-0.2196814864873886,
0.20642437040805817,
-0.592010498046875,
0.09140853583812714... | |
die;
}
print "[OUTPUT]: $_" while (<$out>);
}
```
It's interesting to note that I must initialize `$err` here.
Anyway, this just hangs when I `execute("sort $some_file");` given that `$some_file` is a text file containing more than 4096 chars (limits for my machine).
I then looked into [this](http://perldoc... | [
0.36049672961235046,
0.16818809509277344,
0.42101582884788513,
-0.5764580965042114,
0.05058590695261955,
0.07695893943309784,
0.2856065034866333,
-0.4207448959350586,
-0.2730477452278137,
-0.3159171938896179,
0.15036343038082123,
0.5597813129425049,
-0.3025427758693695,
0.11018609255552292... | |
expects a glob?
local *OUT = IO::File->new_tmpfile;
local *ERR = IO::File->new_tmpfile;
my $pid = open3($in, ">&OUT", ">&ERR", $cmd);
print "[PID]: $pid\n";
waitpid($pid, 0);
seek $_, 0, 0 for \*OUT, \*ERR;
if(<ERR>) {
print "[ERROR] : $_" while(<ERR>);
die;
}
print "... | [
-0.19943585991859436,
-0.34133315086364746,
0.9198529124259949,
-0.5370064377784729,
0.09235580265522003,
0.4658676087856293,
0.21052859723567963,
-0.22295045852661133,
0.09754586219787598,
-0.3414754569530487,
0.035254981368780136,
0.7312391400337219,
-0.5845779180526733,
-0.2945529520511... | |
I read `IO::Select`, and after some more googling, have come up with this version of `execute`:
```
sub good_execute {
my($cmd) = @_;
print "[COMMAND]: $cmd\n";
my $pid = open3(my $in, my $out, my $err = gensym(), $cmd);
print "[PID]: $pid\n";
my $sel = new IO::Select;
$sel->add($out, $err);
... | [
0.00439677806571126,
0.18170659244060516,
0.5747602581977844,
-0.5228605270385742,
0.11930713057518005,
0.21360881626605988,
0.46640363335609436,
-0.25334692001342773,
0.011192199774086475,
-0.6500962972640991,
-0.2821388244628906,
0.602713942527771,
-0.3166607618331909,
-0.020197486504912... | |
unless(defined $line) {
$sel->remove($fh);
next;
}
if($fh == $out) {
print "[OUTPUT]: $line"; | [
-0.05627203732728958,
-0.3211456835269928,
0.4580391049385071,
-0.5697693824768066,
0.31388211250305176,
-0.06515566259622574,
0.16965483129024506,
-0.18587914109230042,
0.13584142923355103,
-0.3955867290496826,
-0.785830020904541,
0.33692845702171326,
-0.4075714945793152,
0.07257599383592... | |
}elsif($fh == $err) {
print "[ERROR] : $line";
}else{
die "[ERROR]: This should never execute!";
}
}
}
waitpid($pid, 0);
}
```
This is working fine, and a few things have become clearer now. But the overall | [
0.06851103901863098,
-0.26754096150398254,
0.5373824238777161,
-0.2514459192752838,
0.22395551204681396,
-0.0007252679788507521,
0.3985244333744049,
-0.47554776072502136,
-0.017228348180651665,
-0.500699520111084,
-0.07751931250095367,
0.897513210773468,
-0.2788658142089844,
-0.00611688662... | |
picture is still a little hazy.
So my questions are:
1. What's wrong with `hung_execute`?
2. I guess `good_execute` works because of the `>&` in the open3 call. But why and how?
3. Also, `good_execute` did not work when I used lexical variables (`my $out` instead of `OUT`) for filehandles. It gave this error: `open3:... | [
0.36729273200035095,
0.4065140187740326,
0.2822546362876892,
-0.29643410444259644,
-0.06712108105421066,
-0.11465438455343246,
0.5032616853713989,
-0.21426117420196533,
-0.3103700578212738,
-0.2097693383693695,
0.10308151692152023,
0.5276822447776794,
-0.29757624864578247,
0.23943324387073... | |
streams, and did not share any resource. I guess my understanding is a bit flawed here. Kindly give me some pointers on this too.
You’ve encountered the very problems I wrote about in the documentation, and then some. You’re deadlocking because you are waiting for the child to exit before you read from it. If it has mo... | [
0.35011228919029236,
-0.22585098445415497,
0.016967304050922394,
0.7211030125617981,
0.11142735183238983,
-0.1063547134399414,
0.14158329367637634,
0.007375576067715883,
-0.030909312888979912,
-0.5402390360832214,
0.4731576144695282,
0.33727648854255676,
-0.20341235399246216,
0.41925728321... | |
discarded its results. Furthermore, if you try to read all the stderr before the stdout, and if there is more than a pipe buffer of output on stdout, then your child will block writing to stdout while you block reading from his stderr.
You really have to use `select`, or `IO::Select`, to do this correctly. You must on... | [
-0.021863464266061783,
0.15290597081184387,
0.05486947298049927,
-0.011612864211201668,
0.004698643926531076,
0.40287452936172485,
0.12066663801670074,
0.030434774234890938,
-0.08391266316175461,
-0.44283753633499146,
-0.2173222154378891,
0.3903876543045044,
-0.11271122843027115,
0.3009050... | |
These are my domain and view classes:
```
public abstract class Entity : IEntity
{
[Key]
public virtual int Id { get; set; }
}
public class City:Entity
{
public string Code { get; set; }
}
public class BaseViewModel:IBaseViewModel
{
public int Id { get; set; }
}
public class CityModel:BaseViewModel
... | [
0.23196765780448914,
-0.3222867548465729,
0.9562978148460388,
-0.006785821169614792,
-0.08185882866382599,
0.010281159542500973,
-0.12065193802118301,
-0.15580786764621735,
-0.2441408634185791,
-0.8932730555534363,
-0.2853485643863678,
0.5172715783119202,
-0.252819687128067,
0.316493362188... | |
it doesn't work:
```
List<City> cities = GetCities();
List<CityModel> model =cities.ToModel<CityModel>() // doesn't work
```
Is it possible to write an extension method for a generic list?
You will need something like this
```
public static List<TModel> ToModel<TModel>(this IEnumerable<IEntity> entity)
where T... | [
0.11700822412967682,
-0.36135178804397583,
0.7987126111984253,
0.1753016859292984,
0.03744140639901161,
-0.16077885031700134,
0.04608241096138954,
-0.18975821137428284,
-0.32127678394317627,
-0.6809571385383606,
-0.07692401856184006,
0.4926115572452545,
-0.5075787305831909,
0.1785063147544... | |
I am trying to solve Python challenges in [pythonchallenge.com](http://www.pythonchallenge.com/). I am in level 2. I was asked to find rare characters in a very large text which is given in the source code of the web page. Here it is:
<http://www.pythonchallenge.com/pc/def/ocr.html>
First of all, I don't want any solu... | [
-0.14575403928756714,
0.4326494038105011,
0.09097837656736374,
-0.18637977540493011,
-0.13460685312747955,
-0.20295998454093933,
0.2951975464820862,
0.2777906358242035,
-0.21825231611728668,
-0.6130635142326355,
0.20739701390266418,
0.44984129071235657,
0.23256240785121918,
-0.106450796127... | |
files to solve this. So can you show me what to study?
Hint 1: To open and read a file's contents, use
```
with open("filename") as f:
contents = f.read()
```
Hint 2: To count characters, one option is to use a `Counter`. | [
0.1423761397600174,
0.003939524758607149,
0.14048539102077484,
0.020891789346933365,
-0.07413418591022491,
-0.0493692122399807,
0.002240563277155161,
-0.057028163224458694,
-0.006854192819446325,
-0.5638235211372375,
-0.06519994139671326,
0.2251031994819641,
-0.33611389994621277,
-0.198523... | |
Is there a way to call multiple methods from backing bean in JSF?
I have something like this:
```
<h:outputLink value="#{bean.selectedEntry.link}">
<h:graphicImage
url="/CMS/button.png" | [
0.1292412430047989,
-0.30390721559524536,
0.20612464845180511,
-0.06462357938289642,
-0.32237038016319275,
-0.021412132307887077,
-0.25213757157325745,
0.26563557982444763,
-0.5370779037475586,
-0.6848315596580505,
0.11852911114692688,
0.48193439841270447,
-0.5132907032966614,
-0.158145591... | |
alt="button"></h:graphicImage>
</h:outputLink>
```
I want to execute some other method from Bean when user click on outputLink. It is possible?
P.S I'm using JSF 1.2
Replace it by `<h:commandLink>`.
E.g.
```
<h:form>
<h:commandLink action="#{bean.openLink}">
<h:graphicImage
url=... | [
-0.1330699473619461,
-0.11849056929349899,
0.41056665778160095,
-0.37982177734375,
-0.4234062433242798,
0.31163182854652405,
0.06414607912302017,
-0.13441751897335052,
-0.3791676461696625,
-0.7651398777961731,
0.0063230483792722225,
0.3766927123069763,
-0.43749046325683594,
-0.324009269475... | |
// ...
FacesContext.getCurrentInstance().getExternalContext().redirect(selectedEntry.getLink());
}
``` | [
-0.22473736107349396,
-0.17893582582473755,
0.619763195514679,
-0.1297849416732788,
0.25955790281295776,
0.012377812527120113,
0.31990501284599304,
-0.05087032914161682,
-0.2883837819099426,
-0.8109281063079834,
-0.5619356632232666,
0.32848402857780457,
-0.3574061989784241,
0.3499700129032... | |
I have a array with some id's I use to select a row set form the database.
The selection goes well but I dont receive my results back in the ordered given array
Inserted array (var\_dump)
```
0 => string '40201' (length=5)
1 => string '44089' (length=5)
2 => string '42106' (length=5)
3 => string '42740' (len... | [
0.02507629804313183,
0.2859918773174286,
0.3713468909263611,
-0.05317189171910286,
-0.052719950675964355,
0.1481098234653473,
0.3368132710456848,
-0.6815043687820435,
0.126071497797966,
-0.6264176964759827,
0.09734806418418884,
0.46160265803337097,
-0.0762893408536911,
0.10434291511774063,... | |
array
'id' => string '40201' (length=5)
1 =>
array
'id' => string '40464' (length=5)
2 =>
array
'id' => string '42106' (length=5)
3 =>
array
'id' => string '42108' (length=5)
4 =>
array
'id' => string '42109' (length=5)
5 =>
array
'id' => | [
-0.008110346272587776,
-0.10124650597572327,
-0.042699508368968964,
-0.034902069717645645,
-0.10661480575799942,
0.32617616653442383,
0.21190880239009857,
-0.573010265827179,
0.11547229439020157,
-0.029601139947772026,
0.01771429553627968,
0.35861217975616455,
-0.1859889030456543,
-0.18200... | |
string '42740' (length=5)
6 =>
array
'id' => string '43812' (length=5)
7 =>
array
'id' => string '44089' (length=5)
8 =>
array
'id' => string '44147' (length=5)
9 =>
array
'id' => string '44331' (length=5)
```
My zend query:
```
$select = $this->_db
->s... | [
-0.2824125289916992,
-0.14837715029716492,
0.03032483533024788,
-0.10046163201332092,
0.09252447634935379,
0.1687575876712799,
0.2711467742919922,
-0.6624220013618469,
0.028632452711462975,
-0.25408828258514404,
-0.25637558102607727,
0.48028644919395447,
-0.3508988916873932,
0.196970790624... | |
->where('file.id IN(?)', $array);
$result = $this->getAdapter()->fetchAll($select);
return $result
```
I think it's the conclusion of the id following up, first one is taken and then he just take the one who he finds first who is in the array right? How can I make this more strict so the query doesn't change... | [
-0.09267006814479828,
-0.0502651073038578,
0.451100617647171,
-0.12165170907974243,
0.07422732561826706,
-0.12056131660938263,
0.21116580069065094,
-0.5389034152030945,
0.04763158783316612,
-0.3522548973560333,
-0.5369013547897339,
0.6665133833885193,
-0.19514189660549164,
0.05196065828204... | |
I have a `Ticket` model which `has_many :tags`. I would like to find all tickets that have tags where `tag.label` is in an array of strings.
Here's what i'm trying at the moment:
```
tags = params[:tags].split(',')
if tags.count > 0 then
t = t.scoped(include: :tag).where('tags.label' => tags.map(&:label))
end
```
... | [
0.15044370293617249,
-0.20965273678302765,
0.17638427019119263,
0.35923266410827637,
-0.1644277125597,
-0.19255195558071136,
-0.06024320423603058,
-0.5950295925140381,
-0.3722270727157593,
-0.6089558601379395,
-0.05861828848719597,
0.40115079283714294,
-0.7046964764595032,
0.18498031795024... | |
I am trying to make a resource loader, and wish to have a class resource and a template class resource manager. Different types of resources inherit from the base resource class, for example a image, 3d mesh etc.
I could have a map for any type of resource, but then I will be unable to call functions specific to a der... | [
0.30313488841056824,
-0.04674726352095604,
0.2619149386882782,
0.10853299498558044,
-0.19570036232471466,
0.15321314334869385,
0.15549759566783905,
-0.25997403264045715,
-0.13465362787246704,
-0.9847857356071472,
0.008295009844005108,
0.7469292879104614,
-0.4618717432022095,
0.406279504299... | |
pointer of the resource type rather than the base resource class. That way you could call functions specific to each resource type.
```
pointerToMesh->getVerticies();
pointerToPicture->getWidth();
```
However, using this approach, you could pass in anything to make a resource manager of.
```
resourceManager<int... | [
0.08545532822608948,
-0.21750901639461517,
0.2688508629798889,
0.11486265808343887,
-0.11164408177137375,
-0.04550981894135475,
0.21447192132472992,
-0.2341252863407135,
-0.3265727460384369,
-0.7149364352226257,
-0.2163633108139038,
0.6385300159454346,
-0.3585589528083801,
0.33482575416564... | |
or whatever doesnt have loadFromFile().
I was thinking of doing something with template specilaisation with the base class, but then it would return pointers of the base class and not the derived ones, unless I specialised it for every single derived class, but then I may as well not have a templated class, but instea... | [
0.3704644739627838,
-0.18965861201286316,
0.08055020868778229,
0.3140665590763092,
-0.37680643796920776,
-0.16182740032672882,
0.29721948504447937,
0.06391362845897675,
-0.43940025568008423,
-0.29927051067352295,
-0.029777657240629196,
0.3705984950065613,
-0.31298646330833435,
-0.258571475... | |
and python implementation can be found [here](https://medium.com/hacking-and-gonzo/how-reddit-ranking-algorithms-work-ef111e33d0d9)
```
#Rewritten code from /r2/r2/lib/db/_sorts.pyx
from math import sqrt
def confidence(ups, downs):
n = ups + downs
if n == 0:
return 0
z = 1.0 #1.44 = 85%, 1.96 ... | [
-0.13429886102676392,
0.0529932901263237,
0.0798809602856636,
-0.05890660360455513,
-0.03579295799136162,
0.26813116669654846,
0.11597274243831635,
-0.3398204445838928,
-0.23010404407978058,
-0.04540687054395676,
0.0041531650349497795,
0.848513662815094,
-0.3700403571128845,
-0.46923840045... | |
I'm drawing a path in Flex using Spark:Path.
I want to subtract a circle shape from this path, as in the following image:

(The path is black and wide)
Any ideas?
I tried creating a mask using a Shape object but couldn't quite manage to create a m... | [
0.25008681416511536,
-0.07442545890808105,
0.41496968269348145,
-0.2680930495262146,
-0.2718038558959961,
0.0568944476544857,
-0.0863632783293724,
-0.39896103739738464,
0.057564012706279755,
-0.9150305390357971,
0.22808034718036652,
0.11578104645013809,
-0.45115354657173157,
-0.21741916239... | |
I have a class library written in Java and want to convert it to Javascript. All methods are pretty simple and mostly have to do with manipulating collections. I have this one class, GameControl, which I could instantiate and I want its methods exposed to other Javascript code on the page.
I thought to use GWT. I have... | [
0.4004976153373718,
-0.1454504132270813,
-0.09547045826911926,
0.12943466007709503,
-0.38300621509552,
-0.2679634690284729,
-0.014498064294457436,
0.028100503608584404,
-0.19463209807872772,
-0.7933270335197449,
0.19068370759487152,
0.5604276657104492,
-0.2489304393529892,
0.20119853317737... | |
look like right now:
**GameEntryPoint.java**
```
import com.google.gwt.core.client.EntryPoint;
public class GameEntryPoint implements EntryPoint {
private GameControl _gameControl;
@Override
public void onModuleLoad() {
_gameControl = new GameControl();
expose();
}
public nativ... | [
-0.05803040787577629,
-0.23708443343639374,
0.3349674344062805,
-0.17336265742778778,
0.33185693621635437,
-0.20419831573963165,
-0.07415733486413956,
-0.03912464901804924,
-0.08672275394201279,
-0.8887313604354858,
-0.4677657186985016,
0.7286872863769531,
-0.3060503900051117,
0.2973196208... | |
true;
}
}
```
So, GWT indeed compiles the code, and I see that there is a `GameControl_0` object being built and set into `$wnd.game`, but no `isEmpty()` method to be found.
My expected end result is to have a `window.game` as an instance of `GameControl` with all public methods `GameControl` exposes.
How ca... | [
0.074811652302742,
-0.021097948774695396,
0.20119382441043854,
-0.0549401193857193,
0.12759295105934143,
-0.2412630170583725,
-0.009499925188720226,
0.0867183730006218,
-0.12509313225746155,
-0.7661519646644592,
-0.33183979988098145,
0.8705260157585144,
-0.34437960386276245,
0.382658243179... | |
{
ExporterUtil.exportAll();
}
}
```
**RoadServer.java**
```
package game.client;
import org.timepedia.exporter.client.Export;
import org.timepedia.exporter.client.ExportPackage;
import org.timepedia.exporter.client.Exportable;
@ExportPackage("game")
@Export("RoadServer")
public class RoadServer implem... | [
-0.010626858100295067,
0.19977134466171265,
-0.16862215101718903,
-0.14724640548229218,
-0.06252250075340271,
-0.10442738980054855,
0.11455054581165314,
-0.15099334716796875,
-0.28548288345336914,
-0.7063236236572266,
-0.2674570083618164,
0.7017762064933777,
-0.5059741139411926,
0.25818946... | |
var control = this.@game.client.GameEntryPoint::_gameControl;
var gameInstance = {
gameControl: control,
isEmpty:function(param){
control.@game.client.GameEntryPoint::isEmpty(*)(param);
}
}
$wnd.game = gameInstance;
}-*/;
```
Also... | [
-0.3290995955467224,
-0.48552948236465454,
0.2548334002494812,
0.19860988855361938,
0.2745930552482605,
0.019090326502919197,
0.02438613958656788,
-0.26142436265945435,
-0.3575873076915741,
-0.35460400581359863,
-0.4306687116622925,
0.5222306847572327,
-0.14559558033943176,
0.2900209128856... | |
a framework called [gwt-exporter](http://code.google.com/p/gwt-exporter/), it might make things easier for you | [
0.5341511368751526,
-0.13396573066711426,
0.15812768042087555,
0.1219933032989502,
-0.17575304210186005,
-0.09150561690330505,
-0.013844363391399384,
0.04591820389032364,
-0.278445839881897,
-0.4562745988368988,
-0.23432958126068115,
0.3893856704235077,
-0.39614778757095337,
-0.12407213449... | |
That may look paradoxical, I know that secret changesets are meant to be private, but what if I want to backup those secret changesets?
I work with some branches in parallel and sometimes I want to push one, but not the others. To achieve that, I work in separate clones but I hate that.
So now mercurial has phases, I... | [
0.32690536975860596,
-0.10553258657455444,
0.4465342164039612,
0.2551552355289459,
0.1042642816901207,
-0.010669789277017117,
0.039409659802913666,
0.16974423825740814,
-0.5736783742904663,
-0.26799219846725464,
0.14890450239181519,
0.20536720752716064,
-0.1402944177389145,
0.4267930984497... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.