Skip to content

Instantly share code, notes, and snippets.

View akluth's full-sized avatar
🟢
Per aspera ad astra.

Alexander Kluth akluth

🟢
Per aspera ad astra.
View GitHub Profile
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
def output name=((default=true); "caius")
puts "name: #{name.inspect}"
puts "default: #{default.inspect}"
end
output
# >> name: "caius"
# >> default: true
output "avdi"
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 9, 2025 07:52
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@akluth
akluth / array.coffee
Created May 2, 2013 20:08
CoffeeScript: JSON-Objects, Arrays
# Considering an JSON object like this one:
#
# {
# "store": {
# "foo": {
# "value":"bar"
# }
# },
# "anotherstore": {
# "wat":{
#define flag1 1<<0
#define flag2 1<<1
#define flag3 1<<2
#define flag4 1<<3
long arg1 = flag1|flag2;
long arg2 = flag1|flag4;
printf("%i %i %i %i \n", flag1, flag2, flag3, flag4);
@SHyx0rmZ
SHyx0rmZ / gist:8549058
Created January 21, 2014 21:46
For when you miss Ruby's map_with_index
template <typename InputIt1, typename InputIt2, typename BinaryFunction>
auto map_with_index(InputIt1 first, InputIt2 last, BinaryFunction f) -> vector<typename iterator_traits<InputIt1>::value_type>
{
vector<typename iterator_traits<InputIt1>::value_type> result(distance(first, last));
size_t i = 0;
generate(begin(result), end(result), [&](){
return f(*first++, i++);
});