Skip to content

Instantly share code, notes, and snippets.

View lytedev's full-sized avatar

Daniel Flanagan lytedev

View GitHub Profile
@lytedev
lytedev / siteroot.php
Last active August 29, 2015 14:06
Simple PHP "Get Application Root" Function
<?php
function getSiteRoot()
{
$docRoot = str_replace("\\", "/", $_SERVER['DOCUMENT_ROOT']);
$fileDir = str_replace("\\", "/", dirname(__FILE__));
$cut = explode($docRoot, $fileDir);
if (count($cut) > 1) {
return $cut[1];
}
@lytedev
lytedev / CustomElixir.php
Last active August 29, 2015 14:08
Custom Laravel elixir function
<?php
if ( ! function_exists('elixir'))
{
/**
* Get the path to a versioned Elixir file.
*
* @param string $file
* @return string
*/
@lytedev
lytedev / GoL:TW Bot.js
Last active August 29, 2015 14:08
A simple JavaScript bot that plays the multiplayer Game of Life found at the site http://gameoflifetotalwar.com/
// Create our huge, short challenge, which our current strategy happens to excel at
function create_huge_short_challenge() {
// Shortest available challende length
jQuery("#challenge_length").val("50");
// Largest map (our giant army has a huge advantage here)
jQuery("#challenge_size").val("200");
// Submit
jQuery(".btn[value='Create the Challenge']").click();
@lytedev
lytedev / GoL:TW Challenger Bot.js
Last active August 29, 2015 14:08
Another bot the plays the multiplayer Game of Life, only this one creates challenges instead of spamming every available challenge. Find the game at http://gameoflifetotalwar.com/
// http://gameoflifetotalwar.com/
// Create our huge, short challenge, which our current strategy happens to excel at
function create_huge_short_challenge() {
// Shortest available challende length
jQuery("#challenge_length").val("50");
// Largest map (our giant army has a huge advantage here)
jQuery("#challenge_size").val("200");
@lytedev
lytedev / shell_cmd_watch_description.sh
Created March 26, 2015 18:44
OSX Run arbitrary shell command on change to file(s) in given path(s)
# This quick snippet comes in very handy when writing unit tests or
# quick scripts that iterate very quickly where you need to see the
# result.
# You'll need to install fswatch with `brew install fswatch`
fswatch-run path "$PATH_1" "$PATH_2" "$PATH_N" "$COMMAND"
# Here are some examples
@lytedev
lytedev / .xinitrc
Last active August 29, 2015 14:17
Disable screen blanking on Arch
# Add these lines to your ~/.xinitrc
xset -dpms &
xset s noblank &
xset s off &
@lytedev
lytedev / makefile
Created April 28, 2015 21:13
Super basic makefile for a C project
CC=cc
LDFLAGS=
APPSLUG=app
SRCDIR=src/
BUILDDIR=build/
SOURCES=$(SRCDIR)main.c
OUTPUT=$(BUILDDIR)$(APPSLUG)

f0134cd22", "seqno": 6, "tag": "signature" }

with the key [ASCgLS-47yICiqqBofSvkJJyYTSMyB5xCr6mfolMsNv8Cwo](https://keybase.io/lytedev), yielding the signature:

hKRib2R5hqhkZXRhY2hlZMOpaGFzaF90eXBlCqNrZXnEIwEgoC0vuO8iAoqqgaH0r5CScmE0jMgecQq+pn6JTLDb/AsKp3BheWxvYWTFAup7ImJvZHkiOnsia2V5Ijp7ImVsZGVzdF9raWQiOiIwMTIwYTAyZDJmYjhlZjIyMDI4YWFhODFhMWY0YWY5MDkyNzI2MTM0OGNjODFlNzEwYWJlYTY3ZTg5NGNiMGRiZmMwYjBhIiwiaG9zdCI6ImtleWJhc2UuaW8iLCJraWQiOiIwMTIwYTAyZDJmYjhlZjIyMDI4YWFhODFhMWY0YWY5MDkyNzI2MTM0OGNjODFlNzEwYWJlYTY3ZTg5NGNiMGRiZmMwYjBhIiwidWlkIjoiM2Y5MzRjOGY4YWVhYzI5ZTZiMTAzZWQ0N2RmZTY2MTkiLCJ1c2VybmFtZSI6Imx5dGVkZXYifSwic2VydmljZSI6eyJuYW1lIjoiZ2l0aHViIiwidXNlcm5hbWUiOiJseXRlZGV2In0sInR5cGUiOiJ3ZWJfc2VydmljZV9iaW5kaW5nIiwidmVyc2lvbiI6MX0sImNsaWVudCI6eyJuYW1lIjoia2V5YmFzZS5pbyBnbyBjbGllbnQiLCJ2ZXJzaW9uIjoiMS4wLjE2In0sImN0aW1lIjoxNDcwMjQwNzkxLCJleHBpcmVfaW4iOjUwNDU3NjAwMCwibWVya2xlX3Jvb3QiOnsiY3RpbWUiOjE0NzAyNDA4OTEsImhhc2giOiIyMTAwNWQ5NDRiMTA4ZjNkODU4Mzk1MDdjYzhkMGNmMzUzYTI2ZWQ4ODRiMGYzZDc1YTNkZDUxYz

#!/usr/bin/env bash
sudo modprobe uinput
sudo killall wii-u-gc-adapter
sudo wii-u-gc-adapter --raw &
dolphin-emu
@lytedev
lytedev / advent-of-code-2017-1-solution-1.0.py
Last active December 1, 2017 21:11
Advent of Code - 2017 Day 1 Solution
#!/usr/bin/env python3
import sys
def digits(digitString):
index = 0
final = 0
while index < len(digitString):
ds1 = digitString[index]
ds2 = "-1"