Skip to content

Instantly share code, notes, and snippets.

private function getPlayerByLastNameAndSport($lastName,$teamStr,$sport){
$doctrine = $this->getContainer()->get("doctrine");
$em = $doctrine->getManager();
$playerRepo = $em->getRepository("RotoRobotBundle:Player");
$sportsLeagueRepo = $em->getRepository("RotoRobotBundle:SportsLeague");
$teamRepo = $em->getRepository("RotoRobotBundle:Team");
$sportsLeague = $sportsLeagueRepo->findOneBy(["name"=>$sport]);
$teamKeys = array(
public function onPreSetData(FormEvent $event)
{
$form = $event->getForm();
$form->add('plainOasPassword', 'text',
array(
'required'=>false,
'label'=>"Oas Password",
'attr' => array('placeholder'=>'Existing value is set, but obscured for security purposes')
if($scheduleString){
$formattedSchedule = json_decode($scheduleString);
could be shortened to this because json_decode will return false if string doesnt exist or is garbage
if($formattedSchedule = json_decode($scheduleString)){
@jclapp23
jclapp23 / Phantom JS final output from PHP
Created March 30, 2015 15:58
Phantom JS final output from PHP
California has a population of 37,253,956
Texas has a population of 25,145,561
New York has a population of 19,378,102
Florida has a population of 18,801,310
Illinois has a population of 12,830,632
Pennsylvania has a population of 12,702,379
Ohio has a population of 11,536,504
Michigan has a population of 9,883,640
Georgia has a population of 9,687,653
North Carolina has a population of 9,535,483
@jclapp23
jclapp23 / Phantom JS scrape populations by state
Last active August 29, 2015 14:18
Phantom JS scrape populations by state
private function scrapePopulationsByState(){
$cssSelector = "table.sk_popcharttable";
$siteUrl = "http://www.ipl.org/div/stateknow/popchart.html";
$tableXmlObject = pullXmlObjBlogExample($siteUrl,$cssSelector);
$cnt = 0;
@jclapp23
jclapp23 / Phantom JS Html Scraper - Output to XML object
Last active August 29, 2015 14:18
Phantom JS Html Scraper - Output to XML object
public function pullXmlObjBlogExample($siteUrl,$cssSelector){
//create configuration object containing jquery selector and target site url to pass to the phantom script
$config = array(
"selector"=>$cssSelector,
"url"=>$siteUrl
);
//read in the base phantom script and create a copy of it so we don't mess with the original base script
@jclapp23
jclapp23 / Phantom JS html scraper
Last active August 29, 2015 14:18
Phantom JS html scraper
var page = require('webpage').create();
page.onError = function (msg, trace) {
phantom.exit();
};
page.onAlert = function( msg ) {
@jclapp23
jclapp23 / Phantom JS html scraper
Created March 30, 2015 15:46
Phantom JS html scraper
var page = require('webpage').create();
page.onError = function (msg, trace) {
phantom.exit();
};
page.onAlert = function( msg ) {
@jclapp23
jclapp23 / kata
Last active August 29, 2015 14:13
_ _ _ _ _ _ _
|_| | _||_||_ |_ ||_| _|
_| ||_ | _||_| ||_| _|
912456783
---------------------------------------------------------------------
package kata;
mysql> select * from user_count order by count desc limit 50;
+------------------+-------+
| user | count |
+------------------+-------+
| @oracleofmydoc | 12122 |
| oracleofmydoc | 12122 |
| @nasa | 11322 |
| nasa | 11322 |
| @designsbylilla | 10626 |
| designsbylilla | 10626 |