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
class User | |
def self.authenticate(email, password) | |
user = find_by_email(email) | |
if user && BCrypt::Password.new(user.password_hash) == password | |
user | |
else | |
nil | |
end | |
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
#!/bin/bash | |
# Source: https://bbs.archlinux.org/viewtopic.php?pid=853603#p853603 | |
# Author: falconindy | |
DIFF=${DIFF:-diff} | |
if [[ ! -f PKGBUILD ]]; then | |
echo "error: No PKGBUILD found in working directory." | |
exit 1 | |
fi >&2 |
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
require 'bcrypt' | |
class User | |
include DataMapper::Resource | |
attr_accessor :password, :password_confirmation | |
timestamps :at | |
property :id, Serial |
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
require 'fedora' | |
Fedora.map.each do |route, app| | |
map(route) { run app } | |
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
class Folder | |
include DataMapper::Resource | |
has n, :subfolders, 'Folder' | |
has n, :messages | |
belongs_to :parent, :model => 'Folder', :required => false | |
belongs_to :owner, :model => 'User', :key => true | |
property :id, String, :key => true | |
property :name, String |
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
<html> | |
<head> | |
<title>zxcvbn</title> | |
</head> | |
<body> | |
<h1>pass</h1> | |
<input /> | |
<dl> | |
<dt>Entropy</dt> | |
<dd id='e'>0</dd> |
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/ruby | |
# Now with a hacky outline too, generated after: http://blog.steveklabnik.com/posts/2011-12-21-redcarpet-is-awesome | |
filename = ARGV.first | |
filename = File.basename(filename) if filename | |
require 'redcloth' | |
require 'redcarpet' | |
require 'yaml' | |
require 'mustache' |
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 ruby | |
# | |
# Example of friendships and retriving all records. | |
require 'rubygems' | |
require 'dm-core' | |
require 'dm-migrations' | |
# setup the logger | |
DataMapper::Logger.new($stdout, :debug) |
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/ruby | |
# ruby script to create a directory structure from indented data. | |
# Three ways to use it: | |
# - Pipe indented (tabs or 2 spaces) text to the script | |
# - e.g. `cat "mytemplate" | planter.rb | |
# - Create template.tpl files in ~/.planter and call them by their base name | |
# - e.g. Create a text file in ~/.planter/site.tpl | |
# - `planter.rb site` | |
# - Call planter.rb without input and it will open your $EDITOR to create the tree on the fly | |
# You can put %%X%% variables into templates, where X is a number that corresponds to the index |
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
class Webapp | |
include Reel::App | |
get '/' do | |
rooms = Actor[:rooms].list_rooms | |
# serialize and stuff here | |
end | |
post '/:room' do | |
# do some stuff |