This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo pfctl -s nat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\BlogBundle\Controller; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
class AttachmentController extends Controller | |
{ | |
public function redirectAction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remote Server | |
useradd www-deploy -c "Deployment User" -d /home/www-deploy -G www-data -m -s /bin/bash | |
sudo su - www-deploy | |
# Localhost | |
ssh-keygen -t rsa | |
# Append your key to the Remote host authorized keys file | |
cat id_rsa.pub >> ~/.ssh/authorized_keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Entity; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Doctrine\Common\Collections\Criteria; | |
/** | |
* This assumes you already have a User entity, this just shows the parts | |
* required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AppBundle\Form\DataMapper; | |
use Symfony\Component\Form\DataMapperInterface; | |
use Symfony\Component\Form\Exception\UnexpectedTypeException; | |
use Symfony\Component\Security\Core\User\UserInterface; | |
class UserSettingDataMapper implements DataMapperInterface | |
{ | |
public function mapDataToForms($data, $forms) |