Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
🕹️

Steven de Salas sdesalas

🕹️
View GitHub Profile
@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 / restart-iis-remote.bat
Last active July 14, 2020 18:44
This script restarts IIS and configures it on a remote server. Needs Sysinternals PsExec (http://technet.microsoft.com/en-au/sysinternals/bb897553.aspx)
:: Stop IIS
PsExec.exe \\LDNSERV01 -s -i C:\windows\system32\inetsrv\appcmd.exe stop site OnlineXCart
:: Recycle App Pool (removes lock on file system)
PsExec.exe \\LDNSERV01 -s -i C:\windows\system32\inetsrv\appcmd.exe recycle apppool OnlineXCart
:: Wait 4 Seconds
:: This is useful if you have a command straight after that executes file operations on IIS App Directory
ping -n 5 127.0.0.1 > nul
@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 / TwitterClient.cs
Last active May 26, 2023 03:34
An ultra-lightweight Twitter client in C# using OAuth
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Cryptography;
using System.Linq;
using System.Text.RegularExpressions;
using System.Net;
using System.Web;
@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 / 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;
}
@sdesalas
sdesalas / jwt.server.js
Created March 9, 2017 03:59
Node JSON Web Token API authentication
// @see https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens
// =======================
// get the packages we need ============
// =======================
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var morgan = require('morgan');
var mongoose = require('mongoose');