Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
🕹️

Steven de Salas sdesalas

🕹️
View GitHub Profile
@sdesalas
sdesalas / run.bat
Created June 26, 2014 00:18
Batch file for parsing input characters
@if (1==1) @if(1==0) @ELSE
@echo off
@SETLOCAL ENABLEEXTENSIONS
:: CHECK IF WE NEED TO MODIFY PATH
ECHO ;%PATH%; | find /C /I ";%~dp0tools\phantomjs;" > NUL
IF %ERRORLEVEL% GTR 0 (
ECHO Adding phantom and casper to PATH
SET "path=%path%;%~dp0tools\phantomjs;%~dp0tools\casperjs\batchbin"
)
:: EXECUTE AFTER REPARSING BATCH INPUT
@sdesalas
sdesalas / run.bat
Created July 2, 2014 00:56
Run ANT with specific tools.jar
@ECHO OFF
SET targetdir=%~dp0
SET CLASSPATH=%CLASSPATH%;%~dp0tools\lib;%~dp0\tools\apache-ant-1.9.2\lib\ant-launcher.jar
ECHO java -Dant.home=tools\apache-ant-1.9.2 org.apache.tools.ant.launch.Launcher -f "%~dp0tools\run-tests.xml"
java -Dant.home=tools\apache-ant-1.9.2 org.apache.tools.ant.launch.Launcher -f "%~dp0tools\run-tests.xml"
@sdesalas
sdesalas / ignore.error.bat
Last active August 29, 2015 14:03
Ignores errors when copying a folder that doesnt exist
:: 1) Connect to remote server
net use \\fileserver\packages\myproject
:: 2) Backup previous package
move /y "\\fileserver\packages\myproject\prod\${APP_VERSION}\" "\\fileserver\packages\myproject\prod\${APP_VERSION}.#${releasetag}"
if %%errorlevel%% GEQ 1 goto filenotfound
goto okay
:: 3) Ignore errors
:filenotfound
@sdesalas
sdesalas / nant.check.version.xml
Created December 11, 2015 00:57
Uses NANT to check version info in AssemblyInfo.cs
<?xml version="1.0"?>
<project name="MyProject" default="test-all" basedir=".">
<description>
********************************************
nant.check-version.xml
********************************************
By: Steven de Salas
On: November 2015
@sdesalas
sdesalas / heroku-install-apache.sh
Last active December 22, 2015 19:49
I've been spending a bit of time trying to enable mod_proxy on heroku via the standard php buildpack (https://github.com/heroku/heroku-buildpack-php).. After much frustration I decided to compile my own binary. This is a script that sets up apache (as well as php and mysql) for compiling a binary that support mod_proxy. Its much the same as on t…
#!/bin/bash
set -uex
cd /tmp
# Heroku revision. Must match in 'compile' program.
#
# Affixed to all vendored binary output to represent changes to the
# compilation environment without a change to the upstream version,
# e.g. PHP 5.3.27 without, and then subsequently with, libmcrypt.
heroku_rev='-2'
@sdesalas
sdesalas / Queue.h
Last active September 18, 2016 14:23
/*
* Queue.h
*
* Defines a templated (generic) class for a queue of things.
* Handy for arduino projects, just #include "Queue.h"; and this file.
*
* Example Use:
*
* Queue<char> queue(10); // Max 10 chars in this queue
* queue.push('H');
@sdesalas
sdesalas / String.prototype.hashCode.js
Last active October 17, 2016 05:25
Simple high-performance hashing function, based on Java's `int` Object.hashCode()
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (var i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
const http = require('http');
var attempts = 30, complete = 0, delay = 100,
url = 'http://domain.com/path/to/entrypoint';
Array(attempts)
.fill(0)
.forEach((value, index, arr) => setTimeout(() => {
var start = new Date().getTime();
http.get(url, function(response) {
@sdesalas
sdesalas / Observable.js
Last active April 25, 2017 06:20
Simple Observable (EventEmitter) class example.
//
// Observable.js
//
// Simple JavaScript observable class to inherit from.
// Allows for event subscription using .on('event')
//
// Example:
//
// let weather = new Observable();
// weather.on('rain', () => person1.wearGumboots());
@sdesalas
sdesalas / git.log.sh
Last active May 1, 2017 13:25
git log pretty format
# output 10 lines
git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --date=short -10 | cat -
# copy 10 lines to env variable
export GIT_LOG=$(git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --date=short -10 | cat -)
# windows (needs testing)
for /f %%i in ('git log --date=short -10') do set GIT_LOG=%%i