Skip to content

Instantly share code, notes, and snippets.

View johnkary's full-sized avatar

John Kary johnkary

View GitHub Profile
@peterjaap
peterjaap / iterm_open_with
Created December 15, 2016 14:16
Open text files from Iterm2 in PhpStorm by command+clicking on it
#!/bin/sh
# Open text files from Iterm2 in PhpStorm by command+clicking on it
# You will need the Remote call plugin in PhpStorm - https://plugins.jetbrains.com/plugin/6027
# And of course curl
# wget this and chmod +x it
# then move it to somwhere convenient in your path (such as /usr/local/bin)
# With respects to https://gist.github.com/trinitronx/f59a8308d42d71fdba41 for the basis for this
# iterm_open_with - open a URL, file from CWD, full path, or path with linenumber in default app or PhpStorm if text file
"""
Originaly code was taken from: http://djangosnippets.org/snippets/290/
But I was made some improvements like:
- print URL from what queries was
- don't show queries from static URLs (MEDIA_URL and STATIC_URL, also for /favicon.ico).
- If DEBUG is False tell to django to not use this middleware
- Remove guessing of terminal width (This breaks the rendered SQL)
"""
from clint.textui import colored, columns, indent, puts
<?php
namespace App\Component\HttpKernel\CacheWarmer;
use Spork\Batch\Strategy\ChunkStrategy;
use Spork\ProcessManager;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
class SporkCacheWarmerAggregate extends CacheWarmerAggregate
{
@lyrixx
lyrixx / post-checkout
Created June 26, 2013 13:37
Git post checkout
#!/bin/bash
# Put this file at: .git/hooks/post-checkout
# and make it executable
# You can install it system wide too, see http://stackoverflow.com/a/2293578/685587
PREV_COMMIT=$1
POST_COMMIT=$2
NOCOLOR='\e[0m'
@jrmadsen67
jrmadsen67 / gist:5815505
Last active May 1, 2017 21:32
Next time someone asks you to take a FizzBuzz Test...
$biggest =100;
$all_numbers = range(0,$biggest);
$threes = array_fill_keys(range(3, $biggest, 3), 'Fizz');
$fives = array_fill_keys(range(5, $biggest, 5), 'Buzz');
$fifteens = array_fill_keys(range(15, $biggest, 15), 'FizzBuzz');
$all_numbers = array_replace($all_numbers, $threes, $fives, $fifteens);
var_dump($all_numbers);
@havvg
havvg / CatchmentAreaType.php
Created November 23, 2012 13:19
Dynamic validation_groups based on choice value
<?php
namespace Ormigo\Bundle\OrmigoBundle\Form\CatchmentArea\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Ormigo\Bundle\OrmigoBundle\Form\CatchmentArea\DataTransformer\CatchmentAreaModelTransformer;
@dbu
dbu / Vagrantfile
Created November 13, 2012 09:26
vagrant setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
this_dir = File.dirname(__FILE__) + "/"
require this_dir + "vagrant/hostmaster.rb"
Vagrant::Config.run do |config|
# define some colors for our output
def colorize(text, color_code) "#{color_code}#{text}\033[0m" end
@JoshuaEstes
JoshuaEstes / DefaultControllerTest.php
Created October 4, 2012 16:38
Create a symfony test client that is authenticated
<?php
namespace Acme\BlogBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DefaultControllerTest extends WebTestCase
{
public function testIndex()
{
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@Ocramius
Ocramius / User.php
Last active February 16, 2024 14:57
Doctrine 2 ManyToMany - the correct way
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User