Skip to content

Instantly share code, notes, and snippets.

View ermand's full-sized avatar

Ermand Durro ermand

View GitHub Profile
@ermand
ermand / shuffle_string.rb
Created December 28, 2014 21:59
Shuffle String in Ruby
def shuffle_string(string)
string.split('').shuffle.join
end
@ermand
ermand / find_min_max_in_multi_array.php
Created November 5, 2014 11:46
Find min/max in a multidimensional array
<?php
$min = min( array_map("min", $multable) );
$max = max( array_map("max", $multable) );
@ermand
ermand / valdiate_age.php
Last active August 29, 2015 14:07
Validate Age to be greater or equal to 18
<?php
/**
* Validate Age to be greater or equal to 18
*
* @param $birthdate
* @return boolean
*/
function validateAge($birthdate)
{
$currentDate = new DateTime("now");
@ermand
ermand / index.php
Created October 21, 2014 17:23
Perform minor calculations on large integer lists.
<?php
/**
* A class for performing minor calculations on large integer lists.
*/
class Main
{
private $buffSize;
private $list;
/**
@ermand
ermand / functions.php
Created October 20, 2014 20:57
Gets the HTTP status code for the given URL
<?php
/**
* Gets the HTTP status code for the given URL.
*
* @param string $url The URL to check.
* @return int
*/
function url_http_status($url) {
$ch = curl_init($url);
@ermand
ermand / UserSettings
Created October 15, 2014 21:49
Sublime Text 3 User Settings
{
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/base16-eighties.dark (SL).tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"folder_exclude_patterns":
[
@ermand
ermand / sublimetext3_packages
Created October 15, 2014 21:48
Sublime Text 3 List of Packages
{
"installed_packages":
[
"AdvancedNewFile",
"Alignment",
"All Autocomplete",
"AutoFileName",
"Autoprefixer",
"Blade Snippets",
"BracketHighlighter",
@ermand
ermand / aliases.sh
Last active June 7, 2017 12:57
Some useful cli aliases
# Common
alias ..="cd .."
alias ...="cd ../.."
alias h='cd ~'
alias c='clear'
alias ll='ls -lahG'
# Test
alias codecept='vendor/bin/codecept'
alias crf='codecept run functional'
@ermand
ermand / install_ wkhtmltopdf.sh
Last active August 29, 2015 14:06
Installing wkhtmltopdf on Ubuntu Server 12.04
### Install guide
sudo apt-get update
sudo apt-get install wkhtmltopdf
sudo apt-get install xvfb
echo 'xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh
chmod a+x /usr/bin/wkhtmltopdf.sh
ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
wkhtmltopdf http://www.google.com output.pdf
########################################################
@ermand
ermand / Vagrantfile
Created June 22, 2014 09:57
VagrantFile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "base"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"