#Rails Girls Things
This file contains hidden or 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
| // Wrote this to try bruteforcing a hash key in part of the Stripe CTF game. | |
| // I realise it would take something like 100 million years to find it, but I'd never written a hash generator before. | |
| // Putting this on GitHub in case anyone's interested. | |
| package main | |
| import ( | |
| "math/rand" | |
| "strings" | |
| "bytes" |
This file contains hidden or 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
| require "celluloid/zmq" | |
| Celluloid::ZMQ.init | |
| class Client | |
| include Celluloid::ZMQ | |
| def initialize(address) | |
| @socket = PushSocket.new |
This file contains hidden or 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
| switchLabelClass = (el) -> | |
| if $(el).attr("checked") == "checked" | |
| $(el).parent().addClass("checked") | |
| else | |
| $(el).parent().removeClass("checked") | |
| # Obviously change the form target here | |
| checkbox_groups = $("form").find("input[type = 'checkbox']").each -> | |
| $(this).hide() | |
| switchLabelClass(this) |
This file contains hidden or 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
| ... | |
| def create | |
| flash[:alert] = "You created a thing!" | |
| redirect_to "/somepath" | |
| end | |
| ... |
This file contains hidden or 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
| DS.Model.reopenClass | |
| modelName: -> | |
| model = this | |
| parts = model.toString().split('.') | |
| name = parts[parts.length - 1] | |
| name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1) | |
| getChannelPrefix: (callback) -> | |
| @channelPrefix || $.get "/accounts/current.json", (data) -> | |
| @channelPrefix = data['account']['pusher_channel'] |
This file contains hidden or 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
| Kuiper.Pusher = (opts = {}) -> | |
| @init(opts) | |
| this | |
| $.extend Kuiper.Pusher.prototype, | |
| options: {} | |
| activeChannels: [] | |
| init: (@options) -> | |
| @pusher = new Pusher(@options.key) |
Add the following to your Gemfile:
gem 'heroku-api'
Put heroku.rb in your jobs folder and add the contents of heroku.html into your layout.
This file contains hidden or 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
| # To run git bisect looking for the first spec suite to exceed 1000MB of RAM: | |
| # git bisect run ruby memory_usage.rb 'rake spec' 1000000 | |
| require 'open3' | |
| command = ARGV[0] | |
| threshold = ARGV[1].to_i || 500000 | |
| cmd = "/usr/bin/time -v #{command}" | |
| Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| |
This file contains hidden or 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
| unbind C-b | |
| set -g prefix C-a | |
| bind -n M-Left select-pane -L | |
| bind -n M-Right select-pane -R | |
| bind -n M-Up select-pane -U | |
| bind -n M-Down select-pane -D | |
| set -g default-terminal "screen-256color" | |
| set -sg escape-time 0 |