Skip to content

Instantly share code, notes, and snippets.

View frank184's full-sized avatar
👌
pro g[r]amer

François Bélanger frank184

👌
pro g[r]amer
View GitHub Profile
@frank184
frank184 / ordinal_suffix_of.js
Created April 9, 2019 14:17
ordinal_suffix_of
ordinal_suffix_of = function(i) {
var j, k;
j = i % 10;
k = i % 100;
if (j === 1 && k !== 11) {
return i + 'st';
}
if (j === 2 && k !== 12) {
return i + 'nd';
}
@frank184
frank184 / stringify_keys.rb
Created December 5, 2018 06:22
Stringify Keys in Ruby
def self.stringify_keys(h)
h.is_a?(Hash) ? h.collect{|k,v| [k.to_s, stringify_keys(v)]}.to_h : h
end
@frank184
frank184 / header.rb#L181
Created July 19, 2018 02:35
VENDOR_VERSION_HEADER_REGEX
VENDOR_VERSION_HEADER_REGEX = /\Avnd\.([a-z0-9.\-_!#\$&\^]+?)(?:[-.](?:[-a-z0-9*.]+))?(?:\+([a-z0-9*\-._]+))\z/
@frank184
frank184 / gist:41fb1a98542d6b5c9691ff9b0b6c73f0
Created July 4, 2018 01:19
Download Gitignore Templates
curl "https://raw.githubusercontent.com/github/gitignore/master/Unity.gitignore" >> .gitignore
module Probabilities
def prob(event_percentage, event_frequency = 1)
event_percentage ** event_frequency
end
def inverse_prob(event_percentage, event_frequency = 1)
1 - prob(event_percentage, event_frequency)
end
end
@frank184
frank184 / styles.less
Last active June 9, 2017 11:44
Atom Git-Diff styles for github-atom-light-syntax package
.editor .gutter .line-number {
&[class*="git"] {
padding-left: 0 !important;
border-left: none !important;
color: #ffffff;
opacity: 1;
width: 40px;
}
&.git-line-added {
@frank184
frank184 / wait_db.rb
Created March 30, 2017 23:19
Wait for DB
require 'socket'
def try_connection
TCPSocket.new(ENV['DB_HOST'], 3306)
rescue Errno::ECONNREFUSED
false
else
true
end
@frank184
frank184 / setup_atom.sh
Last active April 3, 2017 02:55
Personal Atom Setup
# install atom from repo
sudo add-apt-repository ppa:webupd8team/atom
sudo apt-get update
sudo apt-get install atom
# install favorite atom packages
apm install github-atom-light-syntax
apm install goto-definition
apm install open-in-browser
apm install language-haml
@frank184
frank184 / kill_rogue_server.sh
Created March 21, 2017 01:37
Script to kill a rogue Rails Server
cat tmp/pids/server.pid | xargs kill -9
@frank184
frank184 / hello.bf
Last active March 15, 2017 03:50
Hello World in Brainfuck
+++++ +++++ * = | 10^| 0 | 0 | 0 | 0 |
[ * = | 10^| 0 | 0 | 0 | 0 | loops current cursor
>+ * = | 10 | 1^| 0 | 0 | 0 |
>+++ * = | 10 | 1 | 3^| 0 | 0 |
>+++++ ++ * = | 10 | 1 | 3 | 7^| 0 |
>+++++ +++++ * = | 10 | 1 | 3 | 7 | 10^|
<<<<- * = | 9v| 1 | 3 | 7 | 10 |
] * = | 0*| 10 | 30 | 70 | 100 |
>>>++. * = | 0 | 10 | 30 | 72^| 100 | print cursor value ASCII 72 = H
>+. * = | 0 | 10 | 30 | 72 | 101^| print cursor value ASCII 101 = e