Skip to content

Instantly share code, notes, and snippets.

View cesarfigueroa's full-sized avatar

Cesar Figueroa cesarfigueroa

View GitHub Profile
$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 {
<!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>
body {
background-image: repeating-radial-gradient(red, red 1px, transparent 1px, transparent);
background-size: 36px 36px;
}
@cesarfigueroa
cesarfigueroa / paste.js
Created September 25, 2014 23:48
Paste onto a [contenteditable] element as plain text
document.querySelector('[contenteditable]').addEventListener('paste', function (event) {
event.preventDefault();
document.execCommand('inserttext', false, event.clipboardData.getData('text/plain'));
});
export $(cat .env)
@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];
});
};
@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 / view_directories.rb
Created January 3, 2014 22:05
Determine what directories a view lives in based on the current route (in Sinatra).
def view_directories
request.path_info.split('/').select do |path|
Dir.entries(settings.views).include?(path)
end
end
@cesarfigueroa
cesarfigueroa / uninstall.sh
Last active December 19, 2015 04:38
Uninstall all gems in Ruby < 2.0
gem list --no-versions | xargs gem uninstall -aIx
@cesarfigueroa
cesarfigueroa / uninstall.sh
Last active December 19, 2015 04:19
Uninstall all gems in Ruby 2.x
#!/usr/bin/env sh
gems=`gem list --no-versions`
default_gems=(bigdecimal io-console json minitest psych rake rdoc test-unit)
for gem in $gems; do
if [[ ${default_gems[*]} != *$gem* ]]; then
gem uninstall $gem -aIx
fi
done