Skip to content

Instantly share code, notes, and snippets.

View brpaz's full-sized avatar

Bruno Paz brpaz

View GitHub Profile
@brpaz
brpaz / ManyToEntityTransformer
Last active August 29, 2015 14:09 — forked from frodosghost/ManyToEntityTransformer
Data Transformer: Many to Many for Entity Field #symfony #datatransformer
<?php
namespace Acme\DemoBundle\Form\DataTransformer;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
@brpaz
brpaz / EntityHiddenType.php
Last active August 29, 2015 14:09 — forked from bjo3rnf/EntityHiddenType.php
Hidden field for Symfony2 entities #symfony #datatransformer
<?php
namespace Dpn\ToolsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Dpn\ToolsBundle\Form\DataTransformer\EntityToIdTransformer;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\Common\Persistence\ObjectManager;
@brpaz
brpaz / Add business days.php
Last active October 9, 2023 20:31 — forked from davidsalazar/Add business days.php
Add business days to a DateTime #php #date #businessdays
public function add_business_days($datetime, $duedays)
{
$i = 1;
while ($i <= $duedays)
{
$next_day = date('N', strtotime('+1 day', $datetime));
if ($next_day == 6 || $next_day == 7)
{
$datetime = strtotime('+1 day', $datetime);
continue;
@brpaz
brpaz / redis.sh
Last active August 29, 2015 14:10 — forked from pbrisbin/redis.sh
Redis cheat shet #redis
# Connect to a server
redis-cli server
# Make an insert
set key value
# Make multiple insert
@brpaz
brpaz / hash_hmac_receiver.php
Last active August 29, 2015 14:12 — forked from samarpanda/hash_hmac_receiver.php
#php #hmac #crypt #base64
<?php
function get_private_key_for_public_key($public_key) {
// extract private key from database or cache store
return 'private_key_user_id_9999';
}
// Data submitted
$data = $_GET['data'];
$data = json_decode(stripslashes($data), TRUE);
@brpaz
brpaz / prepend_string.sh
Created January 1, 2015 18:35
Prepend a string to the beginning of each line in a file #bash #aws #string (From: http://stackoverflow.com/questions/13586349/how-can-i-prepend-a-string-to-the-beginning-of-each-line-in-a-file
awk '{print "prefix" $0}' file
@brpaz
brpaz / multiple_ssh_setting.md
Last active August 29, 2015 14:13 — forked from jexchan/multiple_ssh_setting.md
How to configure multiple ssh accounts for github. #ssh #github

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@brpaz
brpaz / gif2mp4.sh
Last active August 29, 2015 14:13 — forked from csabapalfi/gif2mp4.sh
Convert gif to mp4
ffmpeg -f gif -i infile.gif outfile.mp4
@brpaz
brpaz / autoload_namespace.rb
Created January 20, 2015 19:23
Autoloads a class from a namespace #ruby #autoload
module App::ModuleA
autoload :Inner, "path/to/inner"
end
@brpaz
brpaz / bash_check_package_installed.sh
Created January 21, 2015 09:21
Bash snippet that checks if a package is installed. (in uses the which command) #bash
# check for EC2 API tools in $PATH
if ! which aws > /dev/null; then
echo_red 'Please install the AWS command-line tool and ensure it is in your $PATH.'
exit 1
fi