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 / _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
@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 / 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 / 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 / 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 / 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 / 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 / README.md
Last active February 28, 2019 14:51
Alkmaar Elixir Meetup (20-06-2018)

Alkmaar Elixir Meetup demo (20-06-2018)

A simple host and client script written in Elixir. Hosting a little Elixir quiz.

Running locally (on your own computer)

Run the following in two Terminal windows:

iex -r host.ex
@archan937
archan937 / 1.simple-examples.ex
Last active September 10, 2019 07:06
Amsterdam |> Elixir (10-09-2019) (see also: https://github.com/archan937/clustorage)
# iex(1)>
ast = quote do: 1 + 1
# iex(2)>
Code.eval_quoted(ast)
# iex(3)>
ast = quote do: sum(1, 2 + 3)
# iex(4)>
require "net/telnet"
def keys(hosts, pattern = nil)
[hosts].flatten.each do |host|
slabs = {}
telnet = Net::Telnet::new("Host" => host, "Port" => 11211, "Timeout" => 3)
telnet.cmd("String" => "stats items", "Match" => /^END/) do |stats|
slabs = Hash[stats.scan(/STAT items:(\d+):number (\d+)/)]
end