Skip to content

Instantly share code, notes, and snippets.

View archan937's full-sized avatar
🤔
Always thinking about writing the next most creative and nifty piece of software

Paul Engel archan937

🤔
Always thinking about writing the next most creative and nifty piece of software
  • BettyBlocks
  • The Netherlands, Amsterdam
View GitHub Profile
@archan937
archan937 / mod.js
Last active March 1, 2020 22:31
mod.js - A clean and lightweight implementation to define and extend from modules without exposing private members
var mod, define;
mod = (function() {
'use strict';
var modules = {};
return {
define: function(name, mod) {
modules[name] = (typeof(mod) == 'function') ? mod : function() { return mod; };
@archan937
archan937 / handy-dandy.md
Last active October 18, 2019 12:51
A collection of handy one-liners and snippets

Handy-dandy

A collection of handy one-liners and snippets by Paul Engel

Execute Bash command within its own environment

bash -c 'source /path/to/your/.env; echo $MYENVVAR'

Execute Fish command within its own environment

@archan937
archan937 / Rakefile
Created January 8, 2014 10:49
Override Rake::Task.define_task for cleaner arguments passing
require_relative "task"
desc "Send an invite"
task :invite do |name, email|
puts "Invitation sent to '#{name} <#{email}>'"
end
# Example:
#
# $ rake invite "Paul Engel" [email protected]
@archan937
archan937 / pretty_inspect.rb
Last active December 12, 2015 08:29
A simple Ruby method which returns an inspection string of the passed object with pretty indention ^^
def pretty_inspect(object, indent = 2)
if object.is_a?(Array)
entries = object.collect{|x| "#{pretty_inspect x, indent + 2}"}
pretty_indent entries, "[", "]", indent
elsif object.is_a?(Hash)
entries = object.keys.sort.collect{|x| "#{pretty_inspect x} => #{pretty_inspect object[x], indent + 2}"}
pretty_indent entries, "{", "}", indent
else
object.inspect
end
@archan937
archan937 / inspector.js
Created March 2, 2012 22:16
Inspect Javascript objects similar to 'object.toSource()' within Mozilla. Used in IE6+, Safari, Firefox and Chrome.
function inspect(object) {
switch (typeof(object)) {
case "undefined":
return "undefined";
case "string":
return "\"" + object.replace(/\n/g, "\\n").replace(/\"/g, "\\\"") + "\"";
case "object":
if (object == null) {
return "null";
}
@archan937
archan937 / rvm_git_prompt.sh
Created May 15, 2011 10:02
Current RVM Ruby & Gemset and Git branch in your Bash prompt
function current_rvm_ruby {
color=$(tput setaf 3)
default=$(tput sgr0)
version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
full=${color}${version}${gemset}${default}
[ "$full" != "" ] && echo "$full "
}
@archan937
archan937 / _mixins.sass
Created September 6, 2010 07:34
Mixins for SASS in combination with Compass and Lemonade to render indented text displayed with a sprite-image (IE6 compatible)
=block
display: block
=clear
*display: inline-block
&:after
content: " "
height: 0
+block
clear: both