Skip to content

Instantly share code, notes, and snippets.

View bgourlie's full-sized avatar

W. Brian Gourlie bgourlie

View GitHub Profile
@bgourlie
bgourlie / .vimrc
Last active August 29, 2015 14:08
Brian's vim config
" # Vundle config {{{
set nocompatible
filetype off
if has('win32') || has('win64')
if $HOME == 'K:\' " stupid workaround for cuna remapping my home location
set rtp+=C:\Users\wgi7748\vimfiles\bundle\vundle\
call vundle#rc('C:\Users\wgi7748\vimfiles\bundle')
else
set rtp+=~/vimfiles/bundle/vundle/
call vundle#rc('$HOME/vimfiles/bundle')
@bgourlie
bgourlie / Main.java
Last active August 29, 2015 14:00
A couple years back I got a weird urge to write some entirely procedural code, so I made this text-based sheepshead game.
import java.util.Random;
import java.util.Scanner;
public class Main {
private static final String[] card_labels =
{"Q CLUBS ","Q SPADES ","Q HEARTS ","Q DIAMONDS ","J CLUBS ",
"J SPADES ","J HEARTS ","J DIAMONDS ","A DIAMONDS ","10 DIAMONDS","K DIAMONDS ","9 DIAMONDS ",
"8 DIAMONDS ","7 DIAMONDS ","A CLUBS ","10 CLUBS ","K CLUBS ","9 CLUBS ","8 CLUBS ",
"7 CLUBS ","A SPADES ","10 SPADES ","K SPADES ","9 SPADES ","8 SPADES ","7 SPADES ",
"A HEARTS ","10 HEARTS ","K HEARTS ","9 HEARTS ","8 HEARTS ","7 HEARTS " };
@bgourlie
bgourlie / structs_and_traits.rs
Last active December 21, 2015 06:39
messing around with structs and traits in rust
trait Pet {
fn make_noise(&self);
}
struct Dog {
name: ~str,
age: int,
breed: ~str
}
@bgourlie
bgourlie / ellipses.dart
Last active December 13, 2015 20:48
Truncates texts that would otherwise be hidden due to overflow: hidden and adds an ellipses (…). This only works for multi-line text and not single-line text since any browser that Dart targets should support the text-overflow CSS property that has built-in support for single-line auto-ellipses.
void ellipses(Element el){
final tempElement = el.clone(true);
if(el.getComputedStyle().overflow == 'hidden'){
tempElement.style.position = 'absolute';
tempElement.style.overflow = 'visible';
tempElement.style.width = '${el.clientWidth}px';
tempElement.style.height = 'auto';
tempElement.style.maxHeight = 'none';
el.insertAdjacentElement('afterEnd', tempElement);
@bgourlie
bgourlie / gist:1695855
Created January 28, 2012 21:46
A solution I wrote to the Dining Philosophers problem (http://en.wikipedia.org/wiki/Dining_philosophers_problem) using C#.
/*
* Solves the dining philosphers problem using manual syncronization. Also solves for any arbitrary number of philosophers,
* which can be changed by altering the NUM_PHILOSPHERS constant.
*
* Besides solving the original problem, this solution also implements fairness.
*
* http://en.wikipedia.org/wiki/Dining_philosophers_problem
*/
using System.Threading;