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
var rows = $("table.paginated tbody tr").filter(function(i, row){ return $(row).find("td:nth-child(5)").text() == "3-Rm";}); | |
var rents = $.map(rows, function(row) {return parseInt($(row).find("td:nth-child(6)").text())}) | |
var sum = rents.reduce(function(a, b) { return a + b; }); | |
// Average | |
sum/rents.length | |
// Max | |
Math.max(...rents) | |
// Min | |
Math.min(...rents) |
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
# this is apt-mirrors.sh to make all apt sources pick the closest mirrors. | |
# this works very well and inline does not, perhaps more escaping needed | |
config.vm.provision "shell", path: "https://gist.githubusercontent.com/ktaragorn/81496cb4f8ff4bfddb00/raw/50b2d5530ef39aab958d067c00404de6f212c254/apt-mirrors.sh" | |
config.vm.provision "ansible" do |ansible| | |
ansible.playbook = "ansible/setup.yml" | |
ansible.groups = { "vagrant" => "all"} | |
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
import yaml | |
from awesome_print.awesome_print import format as frmt | |
class AttrDict(object): | |
def __init__(self, dct): | |
self.dict = dct | |
def __repr__(self): | |
return repr(self.dict) | |
def __str__(self): |
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
from invoke import run, task | |
from invoke.exceptions import Failure | |
@task | |
def test(): | |
run("python -m unittest discover test") | |
@task | |
def freeze(): | |
run("pip freeze > requirements.txt") |
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
--- | |
- name: Deploy Code | |
hosts: all | |
tasks: | |
- name: Deploy latest code from git | |
git: | |
repo: <<repo>> | |
dest: <<dest>> | |
accept_hostkey: true | |
version: master |
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
[defaults] | |
#this should be hostfile if ur ansible version < 1.9 | |
#this means you dont have to manually specify it in command line | |
inventory = inventory.ini | |
[ssh_connection] | |
ssh_args = -o ForwardAgent=yes | |
#http://www.ansible.com/blog/2014/01/15/ssh-connection-upgrades-coming-in-ansible-1-5 | |
pipelining=True |
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
#http://askubuntu.com/a/9035/92812 | |
sudo sed -i 's/http\:\/\/security.ubuntu.com\/ubuntu/mirror\:\/\/mirrors.ubuntu.com\/mirrors.txt/' /etc/apt/sources.list | |
sudo sed -i 's/http\:\/\/extras.ubuntu.com\/ubuntu/mirror\:\/\/mirrors.ubuntu.com\/mirrors.txt/' /etc/apt/sources.list | |
sudo sed -i 's/http\:\/\/archive.ubuntu.com\/ubuntu/mirror\:\/\/mirrors.ubuntu.com\/mirrors.txt/' /etc/apt/sources.list |
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/sh | |
num=$(pactl load-module module-loopback channels=2) | |
echo $num | |
pactl set-source-port alsa_input.pci-0000_00_1e.2.analog-stereo analog-input-linein | |
pactl set-source-volume alsa_input.pci-0000_00_1e.2.analog-stereo 45% | |
zenity --info --title="Line In Active" --text="Press ok after Game Session" | |
pactl set-source-port alsa_input.pci-0000_00_1e.2.analog-stereo analog-input-microphone\;input-microphone-1 | |
pactl set-source-volume alsa_input.pci-0000_00_1e.2.analog-stereo 100% |
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
files = Dir.entries(".") | |
sub_dir = "clowns_as_many" | |
(files - [".", "..", ".git", ".gitignore", "lib", ".DS_Store", "move.rb"]).each do |file| | |
cmd = "git filter-branch -f --tree-filter \'if [ -e #{file} ]; then mkdir -p #{sub_dir} && mv #{file} #{sub_dir}/; fi\' HEAD" | |
p cmd | |
system cmd | |
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
# implementing http://www.w3schools.com/tags/tag_datalist.asp | |
class DatalistInput | |
include Formtastic::Inputs::Base | |
include Formtastic::Inputs::Base::Stringish | |
include Formtastic::Inputs::Base::Collections | |
def to_html | |
@name = input_html_options[:id].gsub("_id", "") | |
input_wrapping do | |
label_html << |