Skip to content

Instantly share code, notes, and snippets.

View JoshuaEstes's full-sized avatar
👨‍💻

Joshua Estes JoshuaEstes

👨‍💻
View GitHub Profile
@JoshuaEstes
JoshuaEstes / pre-commit.phpcs
Last active August 29, 2015 14:03
Various git hooks
#!/bin/sh
###
#
# Runs phpcs to check for violations
#
PHPCS_BIN=$(command -v phpcs)
if [ ! $PHPCS_BIN ]; then
exit 0
fi
@JoshuaEstes
JoshuaEstes / 00-README.markdown
Last active August 29, 2015 14:00
My goto files for when I initialize a new symfony2 project. It includes bash scripts, composer.json files and a few other things.

README

These are the default files that I will usually start with when setting up a symfony2 project to use vagrant and puppet. I'm putting this readme file here for future updates.

Usage

Make sure the files that end in .sh are executable.

@JoshuaEstes
JoshuaEstes / gist:6831131
Created October 4, 2013 19:13
mysql export table into CSV file
mysql -u USERNAME -p DATABASE -e "select * from TABLE;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g'
@JoshuaEstes
JoshuaEstes / form.html.twig
Last active December 18, 2015 03:18
form.html.twig
{% set email_class = '' %}
{% if form.email.vars.errors %}
{% set email_class = 'error' %}
{% endif %}
{{ form_label(form.email, 'Email', {'label_attr':{'class':email_class}}) }}
{{ form_widget(form.email, {'attr':{'class':email_class}}) }}
{% if form.email.vars.errors %}
{% for error in form.email.vars.errors %}
<small class="error">{{ error.message }}</small>
@JoshuaEstes
JoshuaEstes / form.html.twig
Created June 3, 2013 16:29
Symfony2 Functional Form Tests
<form id="that-one-form">
{{ form_widget(form) }}
</form>
@JoshuaEstes
JoshuaEstes / Vagrantfile
Last active December 15, 2015 08:29
Vagrantfile for symfony2
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.synced_folder ".", "/var/www/app.local", :nfs => true
config.vm.provider :virtualbox do |vb|
@JoshuaEstes
JoshuaEstes / satoshi-picks.php
Last active December 11, 2015 00:19
get 20 numbers from a bitcoin transaction hash
<?php
// get the sha512 hash of the txid and split it by 2
$pool = str_split(hash_hmac('sha512', $txid, $DailySecretKey), 2);
// Loop and get 20
for($N=array(),$i = 0; count($N) < 20 && $i < count($pool); $i++) {
// base 10 that shit
$n = hexdec($pool[$i]);
// make sure it meets the standards
if ($n > 80 || $n < 1) {
@JoshuaEstes
JoshuaEstes / random.php
Created January 10, 2013 17:51
Select n random elements from N without replacement.
<?php
/**
* This function will take an array and select n from it
* without replacement. This can be used as a random number
* generator
*
* Example: I want to select $n numbers from a pool of $N numbers
* <code>
* $values = $srs(range(1,100), 5);
* </code>
@JoshuaEstes
JoshuaEstes / math.php
Last active December 10, 2015 19:19
PHP Math functions =D
<?php
/**
* Computes the factorial of $n
* @param interger $n Number you want to find the factorial for
* @return string
*/
$factorial = function($n) {
for($k=1, $i=1;$i <= $n;$i++) {
$k = $k * $i;