Skip to content

Instantly share code, notes, and snippets.

View vagmi's full-sized avatar

Vagmi Mudumbai vagmi

View GitHub Profile
@vagmi
vagmi / .vimrc
Last active August 29, 2015 14:13
My .vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'lambdatoast/elm.vim'
function! RandomNumber(limit)
let components = split(reltimestr(reltime()), '\.')
let microseconds = components[-1] + 0
return microseconds % a:limit
endfunction
function! RandomScheme()
let choices = []
for fname in split(globpath(&runtimepath, 'colors/*.vim'), '\n')
let name = fnamemodify(fname, ':t:r')
import Window
import Mouse
relativem : (Int,Int) -> (Int,Int) -> (Float,Float)
relativem (w,h) (x,y) = (toFloat (x-(w//2)), toFloat ((h//2)-y))
type Bullet = {posX: Float, posY: Float, vel: Float}
defaultBullet = {posX=0, posY=-180.0, vel=5}
type GameState = {bullets: [Bullet]}
import Window
logoBlue:Color
logoBlue=rgb 96 181 204
logoGrey:Color
logoGrey=rgb 90 99 120
logoYellow:Color
logoYellow=rgb 239 165 0
@vagmi
vagmi / clickndraw.elm
Created October 23, 2014 17:10
First Elm experiment
import Mouse
import Window
relativeMouse : (Int, Int) -> (Int, Int) -> (Int, Int)
relativeMouse (dimx, dimy) (x, y) = let (cx, cy) = center (dimx, dimy)
in (x - cx, cy - y)
center : (Int, Int) -> (Int, Int)
center (x, y) = ( x//2, y//2)
var guid = (function() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return function() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
};

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

var enableMultipleViewFolders = function(express) {
var eView= express.get('view');
var lookupProxy = eView.prototype.lookup;
eView.prototype.lookup = function (view) {
if (this.root instanceof Array) {
var opts = {};
var matchedView = null,
roots = this.root;
@vagmi
vagmi / .vimrc
Created July 23, 2014 08:52
My latest lean vimrc config
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required