Skip to content

Instantly share code, notes, and snippets.

View neomadara's full-sized avatar
🏠
Working from home

Cristian Gutiérrez neomadara

🏠
Working from home
View GitHub Profile
@neomadara
neomadara / gist:592b51d7339e54316ebd
Created October 29, 2015 14:41
cambiar la hoja de estilo en base al controlador
<%= stylesheet_link_tag "welcome" if controller_name == "welcome" %>
@neomadara
neomadara / ruby_setup.md
Created October 30, 2015 05:05 — forked from julionc/ruby_setup.md
Deploy Ruby On Rails on Ubuntu 14.04

Deploy Ruby On Rails on Ubuntu 14.04

Server: Nginx with Phusion Passenger

Ruby Version: 2.1.3

User System: deploy

User System

Download and Install Vagrant http://www.vagrantup.com/ and VirtualBox https://www.virtualbox.org/ or VMware before beginning

#Set up Vagrant *this guide assumes the use of Mac OS X Mountain Lion on local machine and Ubuntu 12.04 LTS x64 on Vagrant box. It is compatible with many other distros but hasn't been tested.

##Step 1: Make and run box

vagrant init
vagrant box add <path to box directory or name according to https://vagrantcloud.com/>
vagrant up
@neomadara
neomadara / doctors.js
Created January 11, 2016 16:55 — forked from elijahmanor/doctors.js
Reducing Filter and Map with Reduce
var doctors = [
{ number: 1, actor: "William Hartnell", begin: 1963, end: 1966 },
{ number: 2, actor: "Patrick Troughton", begin: 1966, end: 1969 },
{ number: 3, actor: "Jon Pertwee", begin: 1970, end: 1974 },
{ number: 4, actor: "Tom Baker", begin: 1974, end: 1981 },
{ number: 5, actor: "Peter Davison", begin: 1982, end: 1984 },
{ number: 6, actor: "Colin Baker", begin: 1984, end: 1986 },
{ number: 7, actor: "Sylvester McCoy", begin: 1987, end: 1989 },
{ number: 8, actor: "Paul McGann", begin: 1996, end: 1996 },
{ number: 9, actor: "Christopher Eccleston", begin: 2005, end: 2005 },
@neomadara
neomadara / up.js
Created January 25, 2016 01:58 — forked from joemccann/up.js
upload express example
app.post('/upload/photo', function(req, res, next){
var json_response = {}
req.form.complete(function (err, fields, files){
if (err){
next(err)
}
else{
// temporary filename
@neomadara
neomadara / file.jade
Created January 25, 2016 02:52 — forked from kparkov/upload.jade
Multer uploads
doctype html
html
head
title File uploads
body
form(method="post", action="/file", enctype="multipart/form-data")
input(type="file", name="file")
input(type="submit", value="Upload")
@neomadara
neomadara / rubyup.md
Created February 22, 2016 13:45 — forked from denpatin/rubyup.md
Ruby hacks

Smart hacks for Ruby

Interpolate arrays

pets = %w[dog cat rabbit]
puts "My first pet is a %s, my second one a %s and my third is a %s" % pets
@neomadara
neomadara / Passport.js
Created March 16, 2016 02:21 — forked from Thingyiot/Passport.js
Passport gist
var express = require('express')
, passport = require('passport')
, LocalStrategy = require('passport-local').Strategy
, mongodb = require('mongodb')
, mongoose = require('mongoose')
, bcrypt = require('bcrypt')
, SALT_WORK_FACTOR = 10;
mongoose.connect('localhost', 'test');
var db = mongoose.connection;
@neomadara
neomadara / server.js
Created March 16, 2016 02:21 — forked from reecer/server.js
PassportJS Usage
var passport = require('passport'),
FacebookStrategy = require('passport-facebook').Strategy,
TwitterStrategy = require('passport-twitter').Strategy,
GithubStrategy = require('passport-github').Strategy,
GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
/* ...server setup... */
// Setup passport auth
app.use(passport.initialize());
@neomadara
neomadara / encriptar-desencriptar.php
Last active March 30, 2021 04:57
encriptar y desencriptar MD5
<?php
function encriptar($texto){
$key='palabraclaveparalacodificacionydecodificacion'; // Una clave de codificacion, debe usarse la misma para encriptar y desencriptar
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $cadena, MCRYPT_MODE_CBC, md5(md5($key))));
return $encrypted;
};
function desencriptar($texto){