Skip to content

Instantly share code, notes, and snippets.

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

Juan Lopez onel0p3z

🏠
Working from home
View GitHub Profile
@domenic
domenic / .bashrc
Last active September 1, 2015 17:50
.bashrc with GitHub PR function
pr () {
git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1 --force
git checkout -b pr/$1 origin/pr/$1
git rebase master
git checkout master
git merge pr/$1 --ff-only
}
@max-mapper
max-mapper / readme.md
Last active October 12, 2015 10:17
introduction to node
@buritica
buritica / jshangouts-pruebas.md
Last active December 16, 2015 07:49
Vinculos sobre lo que hablamos en #JShangouts de pruebas el 16 de Abril
@onel0p3z
onel0p3z / image-getter.js
Created April 24, 2013 23:12
Parses HTML files in folder "Templates", looks for IMG tags, gets SRC attribute, and downloads images to current folder. Not the best way but it worked for me. Also can create a file with links of images. //TIPS from http://maxogden.com/scraping-with-node.html
var $ = require('cheerio'),
_ = require('underscore'),
request = require('request'),
// If you want to create a file
images = [],
path = require('path'),
dir = path.join(__dirname,'\Templates'),
fs = require('fs'),
GetImage = function(file){
var HtmlFile = fs.readFileSync(file).toString(),
@julianduque
julianduque / db.js
Last active December 21, 2015 11:29 — forked from anonymous/db.js
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/app');
var usrSchema = new mongoose.Schema({
user: { type: String, required: true },
password: { type: String, required: true },
DLU: { type: Date }
});
@frytaz
frytaz / gist:7037771
Last active December 25, 2015 20:49
Ghost node.js blogging platform password reset script
var bcrypt = require('bcrypt-nodejs'),
sqlite3 = require('sqlite3').verbose();
var file = 'content/data/ghost-dev.db';
var db = new sqlite3.Database(file);
var password = 'YOUR_NEW_PASSWD';
bcrypt.hash(password, null, null, function(err, hash) {
db.serialize(function() {
db.run("UPDATE users SET password = ? WHERE id = ?", hash, 1);
@tj
tj / config.js
Last active December 27, 2015 14:49
/**
* Module dependencies.
*/
var pkg = require('../package');
var env = process.env.NODE_ENV || 'development';
/**
* Return setting `name`.
*
@bmeck
bmeck / chatting.js
Last active April 1, 2017 00:48
a chat server using generators to manage connection state.
'use strict';
/*::
type Client = Object;
type Channel = string;
*/
const channels/*: Map<Channel, Set<Client>> */ = new Map;
const clients/*: Map<Client, Set<Channel>> */ = new WeakMap;
const join = (name, client) => {
if (!channels.has(name)) {
@magnetikonline
magnetikonline / README.md
Last active August 9, 2017 21:53
Creating a remote Git repository.
@ernie58
ernie58 / passport-user-credential.js
Last active May 7, 2018 08:12
Loopback Passport Component: keep UserIdentity in sync with UserCredentials
module.exports = function (PassportUserCredential) {
/*
* Check if credentials already exist for a given provider and external id
* Enable this hook if credentials can be linked only once
*
* @param Loopback context object
* @param next middleware function
* */
PassportUserCredential.observe('before save', function checkPassportUserCredentials(ctx, next){