Skip to content

Instantly share code, notes, and snippets.

View wchristian's full-sized avatar

Christian Walde (Mithaldu) wchristian

View GitHub Profile

Squad spawn rules:

  • vehicles eligible for Squad Spawn are:
    • Galaxy
    • undeployed Sunderer (!!!)
    • Valkyrie
  • a vehicle becomes Squad Spawn by being piloted by any squad mate
  • any squad member can deploy into any Squad Spawn
  • driver's squad leader status does not matter
  • location of Squad Spawn does not matter
<script type="text/javascript">
// This is a workaround for using jquery-validation-engine with select2 for 'required' validation
// Since the _required validator for jquery-validation-engine uses .val() to see
// if there's anything in the input, we can hijack .val() for the container created by select2\
// and redirect it to the value of the hidden element
// jquery-validation-engine throws an error if the thing we're validating doesn't have an id
// so we'll put one on the container created by select2 (that way, the positioning of the prompts
// will be correct)
$('#mySelector').select2('container').attr('id', 'mySelectorValidate');
@wchristian
wchristian / gist:f6a41314be966b957193
Created October 26, 2014 18:35
quoting myself from elsewhere on paths
(Mithaldu) first off, you need to differentiate between paths in your program, and objects representing actual file system objects on your machine
(Mithaldu) and then you have code portable between machines, so both classes need to carry around attributes marking which OS the path is for
(Mithaldu) and then you can have volumes with different file systems mounted to the same machine
(Mithaldu) and then you can have different configurations for the same file system type
(Mithaldu) and nothing gets all of these right
@wchristian
wchristian / git-size.pl
Created April 29, 2014 12:49
git-size.pl - size of each commit in a git repository
#!/usr/bin/perl
use strictures;
for my $rev ( `git rev-list --all --pretty=oneline` ) {
my $tot = 0;
$rev =~ s/\s+$//;
( my $sha = $rev ) =~ s/\s.*$//;
( my $msg = $rev ) =~ s/^$sha //;
for my $blob ( `git diff-tree -r -c -M -C --no-commit-id $sha` ) {
$blob = ( split /\s/, $blob )[3];
next if $blob eq "0000000000000000000000000000000000000000"; # Deleted
use v5.10;
use strict;
use warnings;
system(1, $^X, '-e', 'sleep 5; print qq[not ok 1 - blah blah\n]');
@wchristian
wchristian / gist:8154428
Created December 28, 2013 00:21
A cat-readable Haskell summary

Haskell tries to be a pure functional language, for which these rules apply:

  1. All functions only does this: Take input, produce output from it; whenever input is the same, output needs to be the same, nothing else may happen. No exceptions.
  2. All functions take only a single argument. No exceptions.

This forbids things like printing to the screen, passing 1 and 1 to the plus function and other useful things. But since Haskell only tries to be pure it allows itself to be a little bit impure and has constructs that are excempt from these rules, so Haskell can be useful. Monads are these constructs.

Monads are the house rules you bring to your Monopoly game to make it fun.

use strictures;
use lib 'lib';
use PPI;
use File::Find::Rule;
use 5.010;
$|++;
my @files = File::Find::Rule->file->name( '*.pm' )->in( "c:/Perl" );
say "found ".@files." files";
for my $file (@files) {
use DDP;
use Win32::DriveInfo;
for my $func (qw(DriveType VolumeInfo)) {
for my $drv (qw(a c)) {
$res{$func . "-" . $drv} = [ Win32::DriveInfo->can($func)->($drv) ];
}
}
$res{GetVersionEx} = Win32::DriveInfo::GetVersionEx();
p(%res);
@wchristian
wchristian / gist:7083923
Last active December 26, 2015 03:09 — forked from brianmed/gist:7083904
sub hash_password {
my ($self, $plain_text, $settings_str) = @_;
return Crypt::Eksblowfish::Bcrypt::bcrypt($plain_text, $settings_str) if $settings_str;
my $salt = join '', map { chr int rand(256) } 1 .. 16;
my %settings = (key_nul => 1, cost => 10, salt => $salt);
return Crypt::Eksblowfish::Bcrypt::bcrypt_hash(\%settings, $password);
}
@wchristian
wchristian / twitter.css
Last active December 23, 2015 16:29
a user css file to make twitter.com more compact
.promoted-tweet {
display: none;
}
.wrapper {
width: 95% !important;
}
.content-main {
width: 75% !important;