Skip to content

Instantly share code, notes, and snippets.

View ermand's full-sized avatar

Ermand Durro ermand

View GitHub Profile
@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 / 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 / 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 / shuffle_string.rb
Created December 28, 2014 21:59
Shuffle String in Ruby
def shuffle_string(string)
string.split('').shuffle.join
end
@ermand
ermand / singleton-ruby.sublime-snippet
Created November 10, 2015 08:24
Singleton Class for Ruby
<snippet>
<content><![CDATA[
class << ${1:self}
$0
end
]]></content>
<tabTrigger>meta</tabTrigger>
<scope>source.ruby</scope>
</snippet>
@ermand
ermand / sublime-text-key-mappings.json
Last active November 25, 2016 11:11
Sublime Text Key Mappings
[
{
"keys": [".", "p"],
"command": "run_phpunit_test"
},
{
"keys": [".", "m"],
"command": "run_single_phpunit_test"
},
{
@ermand
ermand / buergerbot.rb
Created June 7, 2016 15:47 — forked from tokhi/buergerbot.rb
Bürgerbot: Refreshes the Berlin Bürgeramt page until an appointment becomes available, then notifies you.
#!/usr/bin/env ruby
# make sure you the watir gem installed -> gem install watir
require 'watir'
def log (message) puts " #{message}" end
def success (message) puts "+ #{message}" end
def fail (message) puts "- #{message}" end
def notify (message)
success message.upcase
system 'osascript -e \'Display notification Burgerbot with title "%s"\'' % message
rescue StandardError => e
@ermand
ermand / iterm2-solarized.md
Last active September 29, 2017 19:17 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX)

Solarized

@ermand
ermand / opcache_reset.php
Created October 5, 2016 13:58
Reset opcache in php
<?php
opcache_reset();
?>
@ermand
ermand / is_palindrome.php
Created December 27, 2016 17:29
Check if a string is palindrome
<?php
// <!-- $string = "A man, a plan, a canal, Panama"; -->
function is_palindrome($string)
{
$a = strtolower(preg_replace("/[^A-Za-z0-9]/", "", $string));
return $a == strrev($a);
}