Skip to content

Instantly share code, notes, and snippets.

View ryankurte's full-sized avatar
🥔

ryan ryankurte

🥔
View GitHub Profile
@ryankurte
ryankurte / gitversion.js
Created March 24, 2015 01:36
Node.js git version module
var exec = require('child_process').exec;
var semver = require('semver');
function update() {
var child = exec('git describe --dirty', function (error, stdout, stderr) {
exports.string = stdout.replace('\n', '').replace('\r', '');
if(error) {
@ryankurte
ryankurte / arraycompare.js
Last active August 29, 2015 14:17
Javascript array of objects comparison
exports.compareArrays = function(one, two) {
assert.equal(one.length, two.length);
for(var i in one) {
for(var j in one[i]) {
assert.equal(one[i][j], two[i][j]);
}
for(var j in two[i]) {
assert.equal(one[i][j], two[i][j]);
@ryankurte
ryankurte / compressor.js
Created March 25, 2015 01:45
Javascript data compressor and decompressor
var winston = require('winston');
var compressjs = require('compressjs');
var algorithm = compressjs.Bzip2;
exports.compressString = function(string) {
var bufferedString = new Buffer(string, 'utf8');
var compressedString = algorithm.compressFile(bufferedString);
var encodedString = new Buffer(compressedString).toString('base64');
return encodedString;
}
@ryankurte
ryankurte / version.js
Created March 30, 2015 23:49
node.js version module
//Grabs the version from package.json to use in your application
var semver = require('semver');
var pkg = require('../package.json');
module.exports = {
string: pkg.version,
clean: semver.clean(pkg.version),
major: semver.major(pkg.version),
minor: semver.minor(pkg.version),
@ryankurte
ryankurte / rename.js
Created March 31, 2015 03:37
Quick rename script to strip the suffix from files in a directory
var fs = require('fs');
if(!process.argv[3]) {
console.log("directory argument required");
process.exit(0);
}
var dir = process.argv[3];
var files = fs.readdirSync(dir);
@ryankurte
ryankurte / armenv.sh
Last active October 28, 2021 02:23
Project local arm toolchain (gcc-arm-none-eabi) install script for immutable build environments
#!/bin/bash
# Immutable Project-Local Toolchain Setup
# Inspired by Python's virtualenv and npm
# See http://wp.me/pZZvH-an for more
# Run with `source ./armenv.sh`
# TODOs:
# Add upgrade option
# Cleaner toolchain versioning
# Detect different toolchain versions and warn if installing new?
@ryankurte
ryankurte / README.md
Last active August 29, 2015 14:20
SSH using GPG as an authentication agent
@ryankurte
ryankurte / gcc-arm-none-eabi.rb
Last active August 29, 2015 14:20
Homebrew formula for precompiled gcc-arm-none-eabi from launchpad
class GccArmNoneEabi < Formula
homepage "https://launchpad.net/gcc-arm-embedded/"
version "4.9-2015-q1"
url "https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q1-update/+download/gcc-arm-none-eabi-4_9-2015q1-20150306-mac.tar.bz2"
sha1 "da07fd4edc09da8748b3a61252eed793059c138f"
revision 1
def install
binaries = [
@ryankurte
ryankurte / nodeenv.sh
Last active March 10, 2016 08:27
Project local node.js installer
#!/bin/bash
# Setup a project local environment for a nodejs project
# This installs and links a local node instances so that node and application versions can be coupled.
# Installation is both local to the project, and does not require superuser permissions.
# Inspired by Python's virtualenv. For more information, see http://wp.me/pZZvH-an
#
# Usage:
# 1. Add this file to your node project
# 2. Run with `source ./setup.sh` to setup a local node.js instance
#
@ryankurte
ryankurte / app.init.d
Last active August 29, 2015 14:23
Node.js init.d script
#!/bin/bash
### BEGIN INIT INFO
# Provides: [APP_NAME_HERE]
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Forever running [APP_NAME_HERE]
# Description: Forever running [APP_NAME_HERE]
### END INIT INFO