Skip to content

Instantly share code, notes, and snippets.

View cgiacomi's full-sized avatar
🎧
The music must flow...

Christian Giacomi cgiacomi

🎧
The music must flow...
View GitHub Profile
@cgiacomi
cgiacomi / func_arg
Created July 3, 2012 14:21
Set a function as a value in a Hash, and how to call it with arguments
def myfunc(arg)
puts arg
end
dict = {}
dict['greet'] = method(:myfunc)
f = dict['greet']
f.call('Hello World')
@cgiacomi
cgiacomi / Greeter.cs
Created July 5, 2012 08:48
Hello World
public class Greeter
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}
require 'simplecov'
SimpleCov.start
require 'r2do'
@cgiacomi
cgiacomi / .travis.yml
Created July 19, 2012 17:58
Travis configuration for Ruby
rvm: # the Ruby environments you want to test against
- 1.8.7
- 1.9.2
- 1.9.3
- jruby
- rbx
script: "bundle exec rake test" # your test command!
@cgiacomi
cgiacomi / passport.js
Last active February 20, 2018 05:05
BearerStrategy using a JWT token
/*
* Bearer strategy for token authentication when accessing API endpoints
*/
passport.use(new BearerStrategy(
function(token, done){
try {
//we attempt to decode the token the user sends with his requests
var decoded = jwt.decode(token, tokenSecret);
//TODO: must check the token expiry and ensure the token is still valid
@cgiacomi
cgiacomi / gist:926cf6a02ec16d08423c
Created May 9, 2015 10:45
Find Matching String in Javascript and adorning it with span and class
/*
* Taken from https://github.com/ghiden/angucomplete-alt/blob/master/angucomplete-alt.js
*/
function findMatchString(target, str) {
var result, matches, re;
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
// Escape user input to be treated as a literal string within a regular expression
re = new RegExp(str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'i');
if (!target) { return; }
matches = target.match(re);
@cgiacomi
cgiacomi / gist:9e8a58f78763f2492bfb
Created May 10, 2015 08:25
SSH, not having to do ssh-add every time? (Mac OS)
Run
ssh-add -K ~/.ssh/privateKey
It'll prompt for your passphrase if necessary, then add it to your Keychain.
@cgiacomi
cgiacomi / docker-compose.yml
Created November 23, 2016 09:53
jenkins docker-compose sample
jenkins:
build: ./jenkins/
ports:
- 8080:8080
container_name: jenkins
php:
build: ./php/
volumes_from:
#!/bin/sh
exec < /dev/tty
./.git/hooks/commit-msg.py $1
@cgiacomi
cgiacomi / five_minutes.yml
Created July 26, 2017 13:39 — forked from ryane/five_minutes.yml
five_minutes.yml
---
- hosts: all
vars:
UBUNTU_COMMON_ROOT_PASSWORD: 'xxxxx'
UBUNTU_COMMON_DEPLOY_PASSWORD: 'xxxxx'
UBUNTU_COMMON_LOGWATCH_EMAIL: user@example.com
ubuntu_common_deploy_user_name: deploy
ubuntu_common_deploy_public_keys:
- ~/.ssh/id_rsa.pub