Skip to content

Instantly share code, notes, and snippets.

View donaldducky's full-sized avatar
🎄
It's the time of year for Advent of Code!

Don Chea donaldducky

🎄
It's the time of year for Advent of Code!
View GitHub Profile
@donaldducky
donaldducky / get_title_and_url.applescript
Last active March 1, 2021 13:45 — forked from dongyuwei/get_title_and_url.applescript
Applescript to get frontmost tab’s url and title of various browsers.
# Keep in mind that when asking for a `return` after another, only the first one will be output.
# This example is meant as a simple starting point, to show how to get the information in the simplest available way.
# Google Chrome
tell application "Google Chrome" to return URL of active tab of front window
tell application "Google Chrome" to return title of active tab of front window
tell application "Google Chrome" to return {title, URL} of active tab of front window
# Google Chrome Canary
tell application "Google Chrome Canary" to return URL of active tab of front window
@donaldducky
donaldducky / field_of_view.rs
Created August 9, 2020 01:45 — forked from sbowman/field_of_view.rs
Replacement for Rust rltk::field_of_view
use super::Map;
use super::rltk::{BaseMap, Point};
// Transform represents a sector to shadow cast.
struct Transform {
xx: i32,
xy: i32,
yx: i32,
yy: i32,
}

Keybase proof

I hereby claim:

  • I am donaldducky on github.
  • I am donaldchea (https://keybase.io/donaldchea) on keybase.
  • I have a public key whose fingerprint is 098E C37E 2FAC AC64 67E5 F51C 454E F436 3F50 4D25

To claim this, I am signing this object:

{
"meta": {
"X-RateLimit-Limit": "60",
"X-RateLimit-Remaining": "55",
"X-GitHub-Media-Type": "github.beta",
"Link": [
[
"https://api.github.com/repos/discourse/discourse/commits?_=1362659396461&callback=jQuery19105219535573851317_1362659396460&last_sha=5f9093f21d3d861b9bdfc0f7ea768f756f88aed9&per_page=10&top=master",
{
"rel": "next"
function git_branch() {
git branch 2> /dev/null | grep ^* | cut -c 3-
}
function git_remote() {
if [ -z "$1" ]; then
return 0
fi
local git_repo=$1
@donaldducky
donaldducky / csu.sh
Created December 5, 2012 16:20
Cut Sort Uniq
#!/bin/bash
# simple script to cut / sort / uniq
# ie.
# a.txt: a3wr
# z.txt: wra3
# s.txt: a3r2
# a.txt: a;kljf
# m.json: adf
#
@donaldducky
donaldducky / autocomplete.sh
Created June 27, 2012 14:06
Simple auto complete for git in bash
# get all available git commands
GIT_COMMANDS=$(ls -1 $(git help -a | grep 'available git' | cut -d "'" -f 2) | cut -c 5- | awk "{ print $1 }")
# autocomplete branches in git
_gitcomplete() {
COMPREPLY=( $(compgen -W "$(git branch 2> /dev/null | cut -c 3-)" -- ${COMP_WORDS[COMP_CWORD]}) )
return 0
}
complete -o default -o nospace -F _gitcomplete -W "$(echo $GIT_COMMANDS)" git
@donaldducky
donaldducky / ValidatorTest.php
Created March 20, 2012 01:29
Set template test
<?php
// tests/library/Respect/Validation/ValidatorTest.php
namespace Respect\Validation;
class ValidatorTest extends \PHPUnit_Framework_TestCase
{
function test_static_create_should_return_new_validator()
{
$this->assertInstanceOf('Respect\Validation\Validator', Validator::create());
}
@donaldducky
donaldducky / .vim_dir
Created July 10, 2011 04:00
Don's vimrc
install pathogen
autoload/pathogen.vim
plugins installed:
ctrlp.vim
mustache.vim
snipMate
vim-colors-solarized
vim-fugitive
vim-surround
@donaldducky
donaldducky / newbranch.sh
Created July 8, 2011 17:23
Create a new git branch based off the current branch
#!/bin/bash
# Find the current branch
function git_branch() {
git branch 2> /dev/null | grep ^* | cut -c 3-
}
# Find the current remote
function git_remote() {
if [ -z "$1" ]; then