Skip to content

Instantly share code, notes, and snippets.

View cesarfigueroa's full-sized avatar

Cesar Figueroa cesarfigueroa

View GitHub Profile
@cesarfigueroa
cesarfigueroa / owns.rb
Created March 15, 2014 19:56
ActiveRecord ownership helper
def owns?(object)
object.respond_to?(:user_id) && object.user_id == self.id
end
@cesarfigueroa
cesarfigueroa / mustache.js
Last active August 29, 2015 14:01
A rudimentary, Mustache-esque string interpolation syntax.
function mustache(template, data) {
return template.replace(/{{\s?(\w+)\s?}}/g, function (_, match) {
return data[match];
});
};
export $(cat .env)
body {
background-image: repeating-radial-gradient(red, red 1px, transparent 1px, transparent);
background-size: 36px 36px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="" />
<script src="" defer async></script>
$au-base-dir: 'assets' !default;
$au-default-file-dir: 'public/files' !default;
$au-file-types: (
fonts: ('eot', 'otf', 'ttf', 'woff'),
images: ('jpg', 'jpeg', 'png', 'svg')
) !default;
@function asset-url($file-name) {
@each $file-dir, $file-dir-types in $au-file-types {
(400..599).each do |status_code|
error status_code do
send_file "#{settings.public_dir}/#{status_code}.html",
:status => status_code
end
end
@cesarfigueroa
cesarfigueroa / encoder.sh
Last active October 5, 2015 14:27
Base64 Encoder with Data URIs
#!/usr/bin/env sh
read -p 'File? ' file
echo 'data:'$(file --mime-type -b $file)';base64,'$(base64 -i $file) | pbcopy
@cesarfigueroa
cesarfigueroa / gist:3610091
Created September 3, 2012 15:32
PGP Public Key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (Darwin)
mQENBFBEE/gBCACy6e3EeDEmPG97fQpzdzbU8LBGxPWaq3UVymbrQeYudlP10kvm
EfR++wFT+9F5RR0pxZiGA5RxuDWQcEDfl9W/yZhg2on/phfLSXSDAt8mmWiWR6IG
caUneLrEGe5FPiVcnAirV/3/WdkL3QFiqVdz307MvB4qPi8FfK3Ziez0mzLs939R
wZduZfHVnU4+Ll1C7TF9LsyCS0o+DN5BpUF915QXTcaBk0IQhqr0Z5DAw7VOuzyP
ljLguaJDgFviqIvljNvQc/Ju0ReGQS7uDU7LEa5sZbn/G/t8lpGr81deIfNvSWuM
9YgJACQb3foNj/zCOwpln+bsRalHqp4SfuanABEBAAG0QENlc2FyIEZpZ3Vlcm9h
IChVc2VyIEludGVyZmFjZSBEZXNpZ25lcikgPGNlc2FyLmZpZ3Vlcm9hQG1lLmNv
@cesarfigueroa
cesarfigueroa / gist:4259020
Last active October 13, 2015 21:28
Prevent DataMapper timestamps from being manually set
property :created_at, DateTime, :writer => :private
property :updated_at, DateTime, :writer => :private