Skip to content

Instantly share code, notes, and snippets.

View eduramirezh's full-sized avatar

Eduardo Ramírez eduramirezh

  • Adevinta
  • Barcelona
View GitHub Profile
@eduramirezh
eduramirezh / scp.sh
Last active December 25, 2015 02:29
Useful Linux Commands. I'll be adding new commands as I use them.
#send files through ssh
scp /path/to/my.file me@serverB:/path/to/destination/my.file
@eduramirezh
eduramirezh / mongo.sh
Created October 9, 2013 17:15
Useful Mongo related commands
#Mongo Console
#see all available db's
show dbs
#change current db to database "db_name"
use db_name
#see all collections in current db
db.getCollectionNames()
#see content of "collection_name"
db.collection_name.find()
@eduramirezh
eduramirezh / bfs.js
Created October 10, 2013 13:04
Standard algorithms implemented with JavaScript
function bfs(graph, start){
var queue = [];
var visited = new Set();
var current_node;
queue.push(start);
visited.add(start);
while(queue.length > 0){
current_node = queue.shift();
var child;
for (var i = 0; i < current_node["adjacency_list"].length; i++) {
@eduramirezh
eduramirezh / Set.js
Created October 10, 2013 23:33
Data structures in Javascript
var Set = function() {};
Set.prototype.add = function(o) { this[o] = true; }
Set.prototype.remove = function(o) { delete this[o]; }
Set.prototype.has = function(o) {return (o in this)}
@eduramirezh
eduramirezh / create_github_pages.sh
Created October 21, 2013 23:47
Create github page manually
cd repository
git checkout --orphan gh-pages
# Creates our branch, without any parents (it's an orphan!)
# Switched to a new branch 'gh-pages'
git rm -rf . # Remove all files from the old working tree # rm '.gitignore'
echo "My GitHub Page" > index.html
git add index.html
git commit -a -m "First pages commit"
git push origin gh-pages
@eduramirezh
eduramirezh / ng-enter.js
Created October 29, 2013 18:48
Angular directives
angular.module('mean').directive('ngEnter', function() {
return function(scope, element, attrs) {
element.bind("keydown keypress", function(event) {
if(event.which === 13) {
scope.$apply(function(){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
# Ubuntu 12.04
# Goal: Setting up Production Environment for Ruby On Rails
# First Step: Create new user
# sudo useradd nameOfNewUser
# sudo passwd PASSWORD
# sudo adduser nameOfNewUser sudo
# su nameOfNewUser
# chsh (/bin/bash)
# sudo chown nameOfNewUser /home/nameOfNewUser
import math
def recurrent(n):
global counter
counter+=1
if(counter%10000 == 0):
print(counter)
if n == 1:
return 0
elif n < 1:
# Chile
# From Paul Eggert (2015-04-03):
# Shanks & Pottenger says America/Santiago introduced standard time in
# 1890 and rounds its UTC offset to 70W40; guess that in practice this
# was the same offset as in 1916-1919. It also says Pacific/Easter
# standardized on 109W22 in 1890; assume this didn't change the clocks.
#
# Dates for America/Santiago from 1910 to 2004 are primarily from
# the following source, cited by Oscar van Vlijmen (2006-10-08):
##
# The IncludedResourceParams class is responsible for parsing a string containing
# a comma separated list of associated resources to include with a request. See
# http://jsonapi.org/format/#fetching-includes for additional details although
# this is not required knowledge for the task at hand.
#
# Our API requires specific inclusion of related resourses - that is we do NOT
# want to support wildcard inclusion (e.g. `foo.*`)
#
# The IncludedResourceParams class has three public methods making up its API.