bin/rails g migration AuthlogicToDevise- (see the file below for the actual migration,
authlogic_to_devise.rb) bin/rake db:migrate
gem "devise", "~> 2.2.0"bundle install
| # Simple Recommendation Engine in Ruby | |
| # Visit: http://otobrglez.opalab.com | |
| # Author: Oto Brglez <[email protected]> | |
| class Book < Struct.new(:title) | |
| def words | |
| @words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort | |
| end |
| #!/bin/bash | |
| #This script is best used if modified for each person | |
| #The install can quickly completed if there is a local mirror. | |
| #on an existing arch install, run: darkhttpd /var/cache/pacman/pkg/ | |
| #then set LOCALMIRROR to point to that machine | |
| #It's okay if errors come up, pacman will resolve them. | |
| export LOCALMIRROR="Server = http://192.168.1.1:8080" | |
| export MIRRORLIST="/etc/pacman.d/mirrorlist" |
| class Dog | |
| attr_writer :name | |
| def initialize(name) | |
| @name = name | |
| end | |
| def bark | |
| puts "patrick" | |
| end |
| # arch uefi dm-crypt zfsroot install (archiso) | |
| # modified to work with current repos as of 2016-06-16 and with hints from | |
| # comments by larskotthoff | |
| # uses only one boot partition for EFI and initramfs | |
| # partition disk | |
| # start at 1MB (sector 2048) | |
| 512Mib EFI |
| #!/bin/bash | |
| # Check before running, may need intervention | |
| # Pass in the following to the script, or hardcode it. | |
| # Uncomment if hardcoding input. | |
| BOOT_PARTITION="/dev/sdg1" | |
| DISK_1="ata-SanDisk_SDSSDXPS480G_152271401093" | |
| DISK_2="ata-SanDisk_SDSSDXPS480G_154501401266" | |
| POOL="vault" |
| Let /dev/sdb be the disk. | |
| # Create partition | |
| sudo cfdisk /dev/sdb -> cerate partition /dev/sdb1 | |
| # Initialize disk data with random bits | |
| sudo shred --verbose --random-source=/dev/urandom --iterations=3 /dev/sdb1 | |
| # Create the cryptographic device (leave hash and iter-time to default values if the drive will be mounted on a slow device) | |
| sudo cryptsetup --verbose --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 luksFormat /dev/sdb1 | |
| # Open device | |
| sudo cryptsetup open --type luks /dev/sdb1 DEVSDB1 |
| var str = 'class ಠ_ಠ extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' + | |
| 'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' + | |
| 'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' + | |
| ': "42".repeat(0o10)}));}).then(bi => new ಠ_ಠ(bi.rd));'; | |
| try { | |
| eval(str); | |
| } catch(e) { | |
| alert('Your browser does not support ES6!') | |
| } |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.