Skip to content

Instantly share code, notes, and snippets.

View stephennancekivell's full-sized avatar

Stephen Nancekivell stephennancekivell

View GitHub Profile
@stephennancekivell
stephennancekivell / frame.html
Created September 1, 2012 07:15
controlling iframes with javascript
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery-1.8.0.min.js"></script>
</head>
<body>
<script type="text/javascript">
function doCall(){
$.get('foo').error(function(){
parent.afterCall();
});
@stephennancekivell
stephennancekivell / nginx.conf
Created September 4, 2012 09:25
nginx proxy_pass forwarding
# ends up at 127.0.0.1:8080
location /bla/ {
rewrite ^/bla/(.*) $1 break;
proxy_pass http://127.0.0.1:8080/;
}
# doesnt end up at 127.0.0.1:8080/woo
location /bla/ {
rewrite ^/bla/(.*) $1 break;
@stephennancekivell
stephennancekivell / app.test.html
Created September 19, 2012 11:02
The addition to app.test.html
<!-- for using mocked data while testing -->
<script type="text/javascript" src="../test/lib/angular/angular-mocks.js"></script>
<script type="text/javascript" src="../test/e2e/mocks.js"></script>
<!-- for using mocked data while testing -->
<script type="text/javascript" src="../test/lib/angular/angular-mocks.js"></script>
<script type="text/javascript" src="../test/e2e/mocks.js"></script>
#!/bin/bash
MSG=`sudo apt-get --yes dist-upgrade`
MSG_HEADING='sudo apt-get --yes dist-upgrade'
GmailSend.py -u bla@gmail.com -p bla -t bla@gmail.com -s "server update" -b "$MSG_HEADING \n\n $MSG"
@stephennancekivell
stephennancekivell / underscore-test.js
Last active October 5, 2016 09:15
A unit testable version of debounce from underscore.js I think underscore needs a flush feature so we can easily test our applications that use it. A underscore.flush method would allow you to test the different cases without having to make your unit tests slow. This could work similar to angular.js's $httpBackend.flush().
describe('underscore', function(){
it('shouldnt execute immediately', function(){
var hasHappened = false;
var fn = underscore.debounce(function(){
hasHappened = true;
}, 100);
expect(hasHappened).toBe(false);
package com.stephenn.roguelike.util
import javax.imageio.ImageIO
import java.io.File
import java.awt.image.BufferedImage
object SpriteSplitter {
def main(args: Array[String]) {
val sprites = split(loadImage("assets/nethack-3.4.3-32x32.png"), 1280/32, 960/32)
#!/bin/bash
#
# Notify of Homebrew updates via Notification Center on Mac OS X
#
# Author: Chris Streeter http://www.chrisstreeter.com
# Requires: terminal-notifier. Install with:
# brew install terminal-notifier
TERM_APP='/Applications/Terminal.app'
BREW_EXEC='/usr/local/bin/brew'
@stephennancekivell
stephennancekivell / jmap.all.sh
Created March 11, 2014 08:53
Get jvm memory stats for all java processes.
#!/bin/bash
ps aux | grep java
for PID in `pidof java`
do
echo
echo "jmap -heap $PID"
jmap -heap $PID
done
@stephennancekivell
stephennancekivell / gist:e778101317cc55b6720a
Created February 22, 2015 22:22
WS executeRecovering
import play.api.libs.ws._
def get(url: String): Future[WSResponse] = {
val split = url.split("/")
val hostname = split(0)
val path = "/"+split(1)
def getHosts = Try(InetAddress.getAllByName(hostname).map(_.getHostAddress).toSeq)
def executeRecovering(triedHosts: Seq[String] = Nil): Future[WSResponse] = {