Skip to content

Instantly share code, notes, and snippets.

@juanvallejo
juanvallejo / node-server-with-mysql.js
Created February 11, 2015 02:00
Node server example with a mysql library
// define server constants
var SERVER_PORT = 8000; // port at which to have server listen for connections
// define libraries we'll end up using
var mysql = require('mysql');
// define default mysql constants
var MYSQL_DEFAULT_HOST = 'localhost'; // define address of mysql server
var MYSQL_DEFAULT_PASS = ''; // define password for mysql server
var MYSQL_DEFAULT_DB = 'mydb'; // define default mysql database name
@juanvallejo
juanvallejo / NodeJSModuleImporter.js
Last active August 29, 2015 14:17
script to import all of the "module items" or .js files inside a "modules" directory
#!/usr/local/bin/node
/**
* This hook is to execute pre-commit. It retrieves a list of
* files about to be commited, reads those files, and adds their
* contents to a mysql database.
*
* @author juanvallejo
*
* Note: pwd = root dir, not .git dir
// define runtime constants
var PORT = 8000;
// import modules needed to make the server (http and filesystem modules for now)
var http = require('http');
var fs = require('fs');
var server = http.createServer(requestHandler);
function requestHandler(request, response) {
/**
* Implementation of the problem above.
* Note: to run this file, simply open a
* new tab in Chrome, open the developer
* console (F12 in Windows) and paste the
* this code into it. Press Enter. Magic.
* @file main.js
* @author juanvallejo
 */
var total = 5; // total number of nodes in sequence
/**
* Implementation of the problem above.
* Note: to run this file, simply open a
* new tab in Chrome, open the developer
* console (F12 in Windows), and paste
* this code into it. Press Enter. Magic.
* Tip: For non-manual copy/pasting wizardry
* find this code at the url below.
*
* @url https://gist.github.com/juanvallejo/1fe342b02d1460d5e1bd
/**
* Gulpfile for generic project. Uses browserify for
* clientside Node.js style dependency support. Uses
* Watchify for live change tracking and bundling.
* Local development server listens on port 9000.
* See attached package.json file for required dev
* dependencies. Use `npm install` to init template.
*
* @author juanvallejo
* @date 6/15/15
@juanvallejo
juanvallejo / mav_wrapper.py
Created June 17, 2015 13:01
Setup instructions for mavlink wrapper startup script for the auvsi suas competition
#!/usr/bin/python
import os
import re
import sys
from tempfile import mkstemp
from shutil import move
# This script acts as a wrapper for invoking mavproxy. It performs two key functions:
# 1) Read the value stored in a configuration file, increment the value by 1 and use that for logging. We need this as the BBBK has no concept of date.
# 2) Start the mavproxy with a list of IP addresses (read from another file) as --out.
@juanvallejo
juanvallejo / git-pre-commit.js
Last active August 29, 2015 14:25
pre-commit hook for blog
#!/usr/local/bin/node
/**
* This hook is to execute pre-commit. It retrieves a list of
* files about to be commited, reads those files, and adds their
* contents to a mysql database.
*
* @author juanvallejo
*
* Note: pwd = root dir, not .git dir
@juanvallejo
juanvallejo / theme.terminal
Created July 30, 2015 15:18
Theme for OSX terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw
LjI0ODUwNjQ5ODEgMC41NzAyOTA2OTYzIDAuNzY1MjI2NDAzMQAQAYAC0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
@juanvallejo
juanvallejo / .i3_config
Created July 31, 2015 05:17
i3 dotfile
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!