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
@onel0p3z
onel0p3z / passport-user-credential.js
Created April 5, 2016 14:20 — forked from ernie58/passport-user-credential.js
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){
@onel0p3z
onel0p3z / cfm_wmbd_scrapper.js
Created September 12, 2013 03:26
First draft of a scrapper for cfm's WMBD webApp To run, download both files, run 'npm install', and then 'node app.js'
var $ = require('cheerio'),
_ = require('lodash'),
request = require('request');
var url = 'http://www.themiamibikescene.com/search/label/stolen%20bike';
request(url, function(err, resp, html){
if(err){
return console.log(err);
};
@onel0p3z
onel0p3z / db.js
Created August 21, 2013 19:55 — forked from julianduque/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 }
});
@onel0p3z
onel0p3z / dates.js
Created August 19, 2013 20:28
Date helpers functions
function SendDate(date){
// Expecting date as string like '2013-08-08'
var temp;
date = date.split('-');
temp = new Date(date);
// Returns '2013-08-19T04:00:00.000Z'
return temp.toISOString();
}
@onel0p3z
onel0p3z / get-zip-info.cfm
Created August 15, 2013 21:08
Simple proof-of-concept ... how to consume API data with CFML ... yes, you read right ... C F M L ...
<cfouput>
<form method="POST">
<input name="zipcode" type="number" placeholder="ZIP CODE" size="5" value="#(StructKeyExists(FORM,"zipcode") ? '#FORM.ZIPCODE#' : '')#"/>
<input type="submit" value="Search" />
</form>
<cfif StructKeyExists(FORM,"zipcode") AND FORM.zipcode NEQ "" AND Len(FORM.zipcode) EQ 5>
<cfset theURL = "http://api.zippopotam.us/us/#FORM.zipcode#">
<cfhttp url="#theURL#" method="get" result="response"></cfhttp>
<cfset temp = #DeserializeJSON(response.filecontent)#>
@onel0p3z
onel0p3z / ColombianPride_Prompt
Last active December 20, 2015 21:09
just showing off my custom prompt :D <3
export PS1="\[$(tput setaf 3)\] \u \[$(tput sgr0)\]at\[$(tput setaf 4)\] \H \[$(tput sgr0)\]in\[$(tput setaf 1)\] \W $ \n \[$(tput sgr0)\]"
@onel0p3z
onel0p3z / Instructions for deploying to Nodejitsu
Created July 13, 2013 05:20
Simple instructions for deploying an application to Nodejitsu
sudo npm install -g jitsu
jitsu login
vim package.json
{
"name": "CHANGE_ME",
"subdomain": "CHANGE_ME",
"description": "CHANGE_ME",
@onel0p3z
onel0p3z / Deploying websites with git
Created June 27, 2013 03:30
FTP is so 90's. Let's deploy via Git instead! from https://coderwall.com/p/xczkaq?&p=1&q=
First, create a directory on your server and initialize an empty git repository. I like to serve my websites from ~/www/, so that's what I'll do in this example.
mkdir ~/www/example.com && cd ~/www/example.com
git init
Next, let's set up your server's git repo to nicely handle deployment via git push.
git config core.worktree ~/www/example.com
git config receive.denycurrentbranch ignore
Finally, we'll set up a post-receive hook for git to check out the master branch so your web server can serve files from that branch. (Remember, ^D is Control+D, or whatever your shell's EOT character is.
Module.directive('ng-blur', function() {
return {
restrict: 'A',
link: function postLink(scope, element, attrs) {
element.bind('blur', function () {
scope.$apply(attrs.ngBlur);
});
}
};
});
<html>
<head>
<link type="stylesheet" src="style.css" />
</head>
<body>
<section>
<article>
<h2>Article title</h2>
<p>some textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome textsome text </p>
</article>