Skip to content

Instantly share code, notes, and snippets.

@dontangg
dontangg / reverse_string.c
Created April 12, 2011 12:52
Just a simple C program that reverses a string in place.
#include <stdio.h>
#include <string.h>
void reverse(char str[]) {
int len = strlen(str);
int i;
for(i = 0; i < (len / 2); i++) {
char c = str[i];
str[i] = str[len - i - 1];
@dontangg
dontangg / default
Created April 4, 2012 16:27
My nginx configuration
# /etc/nginx/sites-available/default
upstream my_app_name {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/my_app_name.socket fail_timeout=0;
}
@dontangg
dontangg / unicorn.rb
Created April 4, 2012 16:37
Unicorn configuration
# config/unicorn.rb
# Set environment to development unless something else is specified
env = ENV["RAILS_ENV"] || "development"
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete documentation.
worker_processes 2 # amount of unicorn workers to spin up
listen "/tmp/my_app_name.socket"
@dontangg
dontangg / deploy.rb
Created April 4, 2012 17:21
Capistrano configuration
require "bundler/capistrano"
set :application, "my_app_name"
set :repository, "git://github.com/user/my_app_name.git"
set :scm, :git
# set :deploy_to "/u/apps/#{application}"
role :web, "www.my_app_name.com" # Your HTTP server, Apache/etc
@dontangg
dontangg / jsPerfTest.js
Created April 17, 2012 22:20
Simple JavaScript performance tester
/**
* This is a simple function that will test the performance of a JavaScript function.
* It should be noted that it may not be extremely accurate because it depends on your
* JavaScript runtime's implementation of getTime(). Most of the time, it works great.
*
* (For more on performance testing, see http://ejohn.org/blog/accuracy-of-javascript-time/)
*
* Here is an example of how to run a performance test:
* var result = pfTest(function () { var testAssignment = 0; }, 50);
* console.log(result);
@dontangg
dontangg / posh-git-profile.ps1
Last active October 3, 2015 08:08
My powershell setup
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
# Load posh-git module from current directory
Import-Module .\posh-git
# If module is installed in a default location ($env:PSModulePath),
# use this instead (see about_Modules for more information):
# Import-Module posh-git
function Write-Git-Branch {
@dontangg
dontangg / sudoku9.pl
Created July 30, 2012 19:37
Sudoku solver in prolog
valid([]).
valid([Head|Tail]) :- fd_all_different(Head), valid(Tail).
sudoku9(Puzzle, Solution) :-
Solution = Puzzle,
Puzzle = [S11, S12, S13, S14, S15, S16, S17, S18, S19,
S21, S22, S23, S24, S25, S26, S27, S28, S29,
S31, S32, S33, S34, S35, S36, S37, S38, S39,
S41, S42, S43, S44, S45, S46, S47, S48, S49,
@dontangg
dontangg / directiveTest.html
Created December 15, 2014 23:56
Test directive for Envelopes
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular.min.js"></script>
<script>
var app = angular.module('myModule', []);
app.directive('leftPanel', function() {
return {
restrict: 'EA', //E = element, A = attribute, C = class, M = comment
@dontangg
dontangg / openssl-build.sh
Last active September 17, 2015 06:32 — forked from foozmeat/openssl-build.sh
A shell script to build openssl for iOS and Mac. It currently builds: Mac -> i386 & x86_64 // iOS -> armv7, arm64 // iOS Simulator -> i386 & x86_64.
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
#
# Original: https://gist.github.com/foozmeat/5154962
@dontangg
dontangg / TheX
Created November 7, 2015 20:51
A game for the TI-86
ClLCD
1→NEWX
1→NEWY
21→OX
8→OY
10→NEWSX1
8→NEWSY1
15→NEWSX2
2→NEWSY2
0→TIMER