Skip to content

Instantly share code, notes, and snippets.

View endorama's full-sized avatar
:shipit:

Edoardo Tenani endorama

:shipit:
View GitHub Profile
@endorama
endorama / setup_load_paths.rb
Created July 1, 2013 17:04
Rails 3 setup file for Passenger + Nginx + RVM integration. Place it in `config/`. See more at: http://everydayrails.com/2010/09/13/rvm-project-gemsets.html#sthash.Wzk2ZGsr.dpuf
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
#$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
@endorama
endorama / setup_load_paths.rb
Created September 4, 2013 16:36
Update RVM loading for Passenger 4, Rails 3 and newer RVM versions ( >= 1.20.11 ). Reference here: http://joncairns.com/2013/06/using-project-specific-gemsets-with-rails-rvm-and-passenger/
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
end
end
@endorama
endorama / bash-file.sh
Last active September 19, 2022 21:47
Bash template file
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
SCRIPT="$(readlink --canonicalize-existing "$0")"
SCRIPTPATH="$(dirname "$SCRIPT")"
SCRIPTNAME="$(basename "$SCRIPT")"
# Thanks https://dev.to/thiht/shell-scripts-matter :)
# set -x if DEBUG env var is set - any value suffice
[ -z "${DEBUG:-}" && set -x
@endorama
endorama / angular-loadscript.js
Last active October 11, 2018 07:28
AngularJS 1.2.0 lazy load script in partials
/*
* Angular LoadScript
*
* Let angular load and execute lazy javascript from partials!
*
* This module is the result of this issue: "1.2.0rc1 regression: script tags not loaded via ngInclude"
* Issue url: https://github.com/angular/angular.js/issues/3756
*
* As of Angular 1.2.0 the ngInclude scripts does not permit execution of javascript from included partials.
* This little module execute code inside script tags with "javascript-lazy" attribute after partial loading,
@endorama
endorama / factory.js
Last active August 29, 2015 14:00
AngularJS class design pattern
(function() {
"use strict";
var module = angular.module('foo');
module.factory('fooFactory', [
function() {
// Define the constructor function.
function FooClass() {}
@endorama
endorama / class.js
Last active August 29, 2015 14:02
Namespace JavaScript class prototype pattern
// define application namespace ( this is window )
this.Namespace = this.Namespace || {};
(function() {
"use strict";
function Foobar() {};
var p = Foobar.prototype; // = new Object(); // to extend Foobar
@endorama
endorama / FilterLog
Last active August 29, 2015 14:06
FilterLog example
{
[...]
addWithData: function(msg, data) {
var copy = angular.copy(data);
this.maskReserved(copy);
$log.debug(msg + ' :: ' + copy, type);
},
maskReserved: function(obj) {
@endorama
endorama / bash-header.sh
Last active March 17, 2017 11:11
Quick bash header
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# SCRIPT="$(readlink --canonicalize-existing "$0")"
# SCRIPTPATH="$(dirname "$SCRIPT")"
# SCRIPTNAME="$(basename "$SCRIPT")"
@endorama
endorama / keybase.md
Created February 23, 2017 19:07
keybase.md

Keybase proof

I hereby claim:

  • I am endorama on github.
  • I am endorama (https://keybase.io/endorama) on keybase.
  • I have a public key ASAKweB5myH-17sUIf-UoqlzUNopDTCLTcUzK4hV3tW7kgo

To claim this, I am signing this object:

@endorama
endorama / argv.cr
Last active April 28, 2017 10:49
Crystal lang TCS presentation
# Demo of command line arguments
# ARGV[0]: First command line argument
# (not the executable name)
# ARGV is an array of strings
puts "Number of command line arguments: #{ARGV.size}"
ARGV.each_with_index {|arg, i| puts "Argument #{i}: #{arg}"}
# The executable name is available as PROGRAM_NAME
puts "Executable name: #{PROGRAM_NAME}"