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
/** | |
* Changes value to past tense. | |
* Simple filter does not support irregular verbs such as eat-ate, fly-flew, etc. | |
* http://jsfiddle.net/bryan_k/0xczme2r/ | |
* | |
* @param {String} value The value string. | |
*/ | |
Vue.filter('past-tense', function(value) { | |
// Slightly follows http://www.oxforddictionaries.com/us/words/verb-tenses-adding-ed-and-ing | |
var vowels = ['a', 'e', 'i', 'o', 'u']; |
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
function Animal (name) { | |
console.log("Animal constructor is called " + name); | |
} | |
Animal.prototype.sleep = function () { | |
console.log(this.name + ' is sleeping'); | |
}; | |
// extending the parent classe |
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 ActiveRecord::Base | |
class << self | |
def inherited_yolo(klass) | |
old_inherited(klass) | |
klass.attr_accessible(*klass.column_names.map(&:to_sym)) unless klass.abstract_class? | |
end | |
alias_method :old_inherited, :inherited | |
alias_method :inherited, :inherited_yolo | |
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
module Freckle | |
module Date | |
class << self | |
def parse(string) | |
raw = string.to_s.strip | |
return nil if raw.empty? | |
begin | |
# reverse order if we encounter "European" formatting |
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
// -------------------------------------------------- | |
// Flexbox LESS mixins | |
// The spec: http://www.w3.org/TR/css3-flexbox | |
// -------------------------------------------------- | |
// Flexbox display | |
// flex or inline-flex | |
.flex-display(@display: flex) { | |
display: ~"-webkit-@{display}"; | |
display: ~"-ms-@{display}box"; // IE10 uses -ms-flexbox |
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
window.NR = window.NR || {}; | |
window.NR.myModule = (function () { | |
"use strict"; | |
function initialize() { | |
// your initialization code here | |
} | |
function anotherMethod() { | |
// its function body here |
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
img.grayscale.disabled { | |
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale"); | |
-webkit-filter: grayscale(0%); | |
} |
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 'nokogiri' | |
require 'open-uri' | |
namespace :bookmarks do | |
desc '-- Import bookmarks in Netscape Bookmark format' | |
task :import => :environment do | |
doc = Nokogiri::HTML(open(File.join(Rails.root, "lib/dump/bookmarks_5_8_12.html"))) | |
# Ensure we're dealing with the correct format |
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
/ A simplistic way of loading and rendering HAML partials (header.haml, footer.haml, nav.haml... you name it) without Rails | |
/ Useful when using tools like LiveReload http://livereload.com/ | |
/ but don't want to configure a web server just to use PHP include/require constructs (discussion http://help.livereload.com/discussions/questions/22-haml-partials) | |
/ It could be improved/simplified using a helper http://stackoverflow.com/questions/5436769/partial-haml-templating-in-ruby-without-rails/5436973#5436973 | |
/ Check out the Jade version https://gist.github.com/2593727 | |
%html | |
%body | |
%header | |
= Haml::Engine.new(File.read('/path/to/your/partial.haml')).render |
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
# Public: generates a mixable singleton implementation dependent on a model key. | |
# Once you mix it into a model, your model gains an .instance method that will | |
# generate an object and cache it. Further calls to the .instance methods will | |
# return the same object. | |
# | |
# key - The name of the attribute we use to index instances. Defaults to "id". | |
# | |
# Example | |
# | |
# # Called without arguments uses the "id" as key. |
NewerOlder