This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function has_won(board, x, y, winning_row, winning_col) { | |
for (y = 1; y <= height; y++) { | |
winning_row = 1 | |
for (x = 1; x <= height; x++) { | |
if (board[x, y] != -1) { | |
winning_row = 0 | |
break | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN { FS="" } | |
{ | |
for (i = 1; i <= NF; i++) { | |
if ($i == 1) ones[i]++ | |
else zeroes[i]++ | |
} | |
} | |
END { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sinks=($(pacmd list-sinks | grep index | \ | |
awk '{ if ($1 == "*") print "1",$3; else print "0",$2 }')) | |
inputs=($(pacmd list-sink-inputs | grep index | awk '{print $2}')) | |
[[ ${sinks[0]} = 0 ]] && swap=${sinks[1]} || swap=${sinks[3]} | |
pacmd set-default-sink $swap &> /dev/null | |
for i in ${inputs[*]}; do pacmd move-sink-input $i $swap &> /dev/null; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
new_profile="$1" | |
if [[ -z "$new_profile" ]]; then | |
# Just list existing profiles. | |
profiles=$(cat ~/.aws/config | perl -ne 'print if s/\[profile\s+(\S+)\]/$1/') | |
default_account=$(aws configure get sso_account_id --profile default) | |
for profile in $profiles; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
#include <Wire.h> | |
const int speakerPin = 9; | |
const int lampPin = 8; | |
const int controlButtons = 3; | |
const int controlButtonPins[] = { 12, 13, 11 }; | |
const int playerButtons = 6; | |
const int playerButtonPins[] = { 5, 4, 3, 2, 1, 0 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Perlbrew — install multiple perl environments in $HOME | |
Bundle::Zoidberg — modular perl shell | |
Devel::REPL + Term::ReadLine::Perl + Term::ReadKey = handy REPL | |
Devel::Trace — print out each line before it is executed | |
use autodie | |
Module::UseFrom — use module from string | |
List::MoreUtils (List::AllUtils = List::Util + List::MoreUtils) | |
Params::Util - check parameter types properly (http://perladvent.org/2011/2011-12-23.html) | |
Try::Tiny — sugar for eval |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from collections import defaultdict | |
class LoadBalancer: | |
def __init__(self, targets, probabilities): | |
self._targets = targets.copy() | |
n = len(targets) | |
self._n = n | |
p = probabilities.copy() | |
self._alias = [0] * n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
$script = <<-SCRIPT | |
echo Provisioning... | |
sed 's/^session.*pam_motd/# &/' -i /etc/pam.d/{sshd,login} | |
sed 's/^AcceptEnv LANG/# &/' -i /etc/ssh/sshd_config | |
sudo apt update | |
SCRIPT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macserver:build_device iley$ SDK_VERSION=4.3 ../opencv_cmake.sh device ../OpenCV-2.1.0 | |
Starting cmake... | |
Target SDK = iPhoneOS | |
iOS SDK Version = 4.3 | |
iOS Deployment Target = 3.0 | |
OpenCV Root = ../OpenCV-2.1.0 | |
OpenCV Install Prefix = /Users/iley/Sources/iphone_opencv_test/build_device/../opencv_device | |
-- The C compiler identification is GNU | |
-- The CXX compiler identification is GNU |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -z "$WORKON_HOME" ]; then | |
export WORKON_HOME="$HOME/.virtualenvs" | |
fi | |
workon () { | |
virtualenv="$1" | |
if [ -z "$virtualenv" ]; then | |
echo "Usage: workon env_name" >&2 | |
return 1 | |
fi |
NewerOlder