Skip to content

Instantly share code, notes, and snippets.

@3dd13
3dd13 / Gemfile
Created November 27, 2012 08:38
Runing single ruby file on heroku
source 'https://rubygems.org'
@kenzie
kenzie / _error_messages.html.erb
Created September 13, 2011 12:47
Rails 3 form error partial
<% if target.errors.any? %>
<div class="error_explanation">
<h2><%= pluralize(target.errors.count, "error") %> prevented this record from being saved:</h2>
<ul>
<% target.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
@pch
pch / watermark.rb
Created January 18, 2011 13:43
Paperclip Watermark processor
class User
has_attached_file :photo,
:processors => [:watermark],
:styles => {
:medium => {
:geometry => "300x300>",
:watermark_path => "#{Rails.root}/public/images/watermark.png"
},
:thumb => "100x100>",
}
@carolina-vallejo
carolina-vallejo / lock-unlock-scroll.js
Last active August 27, 2016 17:44
lock/unlock scroll
function lock_scroll(){
// lock scroll position, but retain settings for later
var scrollPosition = [
self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
];
var html = jQuery('html'); // it would make more sense to apply this to body, but IE7 won't have that
html.data('scroll-position', scrollPosition);
html.data('previous-overflow', html.css('overflow'));
html.css('overflow', 'hidden');
@ursuleacv
ursuleacv / gist:20ac531649f76f123ca6
Last active August 31, 2016 06:09
JavaScript modules
//Object Literal
var app = app || {};
//object literal
app = {
init: function(){
this.cache();
this.bind();
},
@etiennetalbot
etiennetalbot / App.Module.js
Last active August 31, 2016 06:34
Javascript Module
/*jslint nomen: true */
window.App = window.App || {};
window.App.ModuleName = (function (document, $) {
'use strict'; //OPTIONAL if you don't want your code to be strict
var _vars, _els, _privateMethod, init;
@mopsled
mopsled / color.rb
Last active December 23, 2016 05:36
Simple Sinatra/ActiveRecord RESTful API
require 'active_record'
class Color < ActiveRecord::Base
end
@james2doyle
james2doyle / keyup-debouce-timeout.js
Created October 5, 2016 19:29
A debounce timeout trigger for typing in an input. The example is in jQuery, but this works with any event/listener.
$('#input').on('keyup', function() {
// do an ajax save when this input is changed
var val = this.value;
// clear the timeout so we dont fire in succession
clearTimeout(this.delayer);
this.delayer = setTimeout(function () {
console.log(val);
}, 500);
});
@Jelby-John
Jelby-John / glyphicons.files.css
Last active December 22, 2017 15:02
Glyphicons Pro in Twitter Bootstrap 3
@font-face { font-family: 'Glyphicons files'; src: url('../fonts/glyphicons-filetypes-regular.eot'); src: url('../fonts/glyphicons-filetypes-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-filetypes-regular.woff') format('woff'), url('../fonts/glyphicons-filetypes-regular.ttf') format('truetype'), url('../fonts/glyphicons-filetypes-regular.svg#glyphicons-filetypes-regular') format('svg'); } .glyphfiles { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons files'; font-style: normal; font-weight: normal; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }.glyphfiles-txt:before {content: "\e001"; }.glyphfiles-doc:before {content: "\e002"; }.glyphfiles-rtf:before {content: "\e003"; }.glyphfiles-log:before {content: "\e004"; }.glyphfiles-tex:before {content: "\e005"; }.glyphfiles-msg:before {content: "\e006"; }.glyphfiles-text:before {content: "\e007"; }.glyphfiles-wpd:before {content: "\e008"; }.glyphfiles-wps:before {con
//
// <button> reset
//
// 1. Remove default browser appearance for buttons.
// 2. Remove margins.
// 3. Remove borders for IE.
// 4. Normalize font and color not inherited by `button`.
// 5. Address `overflow` in IE
// 6. Normalize cursor style