Skip to content

Instantly share code, notes, and snippets.

@luiselizondo
luiselizondo / app.js
Created February 10, 2012 23:59 — forked from aaronksaunders/app.js
Develop a RESTful API Using Node.js With Express and Mongoose
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@luiselizondo
luiselizondo / Model.js
Created February 11, 2012 00:02 — forked from Pradeek/Model.js
NodeJS + MongoDB via Mongoose
var mongoose = require('mongoose');
mongoose.connect('YOUR_MONGODB_PATH');
var Schema = mongoose.Schema;
var ArticleSchema = new Schema({
id : String,
title : String,
body : String,
date : Date
@luiselizondo
luiselizondo / nagios-client-script.sh
Created May 18, 2012 08:35
Configure Nagios Client
#!/bin/bash
function ask {
echo -n "Allowed IP to access NRPE: "
# read -e ALLOWEDIP
}
function system_primary_ip {
# returns the primary IP assigned to eth0
echo $(ifconfig eth0 | awk -F: '/inet addr:/ {print $2}' | awk '{ print $1 }')
@luiselizondo
luiselizondo / async.js
Created August 22, 2012 17:00
nodejs-async-blocks-example-async
async.series({
somedata: function(callback){
// query the database to get "somedata" and pass the result to callback
},
someextradata: function(callback){
// query the database to get the "someextradata" and pass the result to callback
},
},
function(err, results) {
// results is now equal to: {somedata: yourData, someextradata: yourExtraData}
// Simple debug output helper
function debug(message) {
Ti.API.info(message);
}
/**
*
* @param thisControl The control you wish to dump
* @param goDeep boolean Do you want deep introspection
* @param incFuncs boolean Do you want to include functions in the output when going deep
@luiselizondo
luiselizondo / gist:5515058
Last active December 16, 2015 23:39
Software to download
VM Software
VirtualBox (Just if you want to create a VM)
-- https://www.virtualbox.org/
OS
Ubuntu or Fedora
-- http://www.ubuntu.com
-- http://fedoraproject.org/
IDE
@luiselizondo
luiselizondo / HTML_To_Markdown.php
Created February 26, 2015 00:28
Drupal module to migrate to Ghost
<?php
/**
* Class HTML_To_Markdown
*
* A helper class to convert HTML to Markdown.
*
* @version 2.1.1
* @author Nick Cernis <nick@cern.is>
* @link https://github.com/nickcernis/html2markdown/ Latest version on GitHub.
* @link http://twitter.com/nickcernis Nick on twitter.
#!/bin/bash
############################################################################
# Note: Special network 192.162.50.3 to use Cisco Anyconnect Split tunnel.
#
# On OX X host you need to add a line (and file) /etc/exports:
# /Users -mapall=[youruser]:[yourgroup] [boot2dockerip]
# See: https://quip.com/EDYLAAfuup5M (no login needed)
# See also: https://github.com/boot2docker/boot2docker/issues/587#issuecomment-66935011
# See also: http://support.apple.com/en-us/HT202243
@luiselizondo
luiselizondo / sails-mock
Created March 27, 2015 08:51
How to mock a service in Sails, found at https://github.com/fdvj/wolfpack/issues/2
var sinon = require('sinon'),
wolfpack = require('wolfpack');
// Mock EmailSender
global.EmailSender {
sendEmailToUser: sinon.stub()
};
// Instantiate you model
global.User = wolfpack('path_to_models/User');
@luiselizondo
luiselizondo / Model.js
Last active August 29, 2015 14:19
Sails.js Testing
'use strict';
var assert = require("assert");
var should = require("should");
var include = require("include");
var bootstrap = include("test/bootstrap.test");
var Factory = require("sails-factory").load();
var Chance = require("chance");