Skip to content

Instantly share code, notes, and snippets.

module Sass::Script::Functions
def random(max = Sass::Script::Number.new(100))
Sass::Script::Number.new(rand(max.value), max.numerator_units, max.denominator_units)
end
end
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@vojtajina
vojtajina / all-templates.html
Created August 15, 2012 00:00
AngularJS: load all templates in one file
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>
@elisechant
elisechant / _component-a.scss
Last active August 12, 2021 09:15
SCSS Design Patterns - Mixin Constructor
/*
|--------------------------------------------------------------------------
| class ComponentA
|--------------------------------------------------------------------------
|
| [long description]
|
| Example
<div class="{{ identifier }}">
<div class="component-a__element">
@elisechant
elisechant / _neat.block-grid.scss
Created November 14, 2013 04:33
Block Grid for Bourbon's Neat
/*
|--------------------------------------------------------------------------
| Block Grid for Neat
|--------------------------------------------------------------------------
|
| An Automatic Rows type grid layout with no margins
|
| Overcomes a limitation of Bourbons's flex-grid(), where you can't set a
| value for $fg-gutter, impacting the width of the elements
|
function text_contrast(hexcolor) {
//parse hex
var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(color);
// Convert to RGB value between 0 and 1, and retrieve luminance
// Alternative methods: (0.2126*R) + (0.7152*G) + (0.0722*B) or (0.299*R + 0.587*G + 0.114*B)
var L = (0.3 * parseInt(rgb[1], 16)/255) + (0.59 * parseInt(rgb[2], 16)/255) + (0.11 * parseInt(rgb[3], 16)/255);
console.log(L);
return L > 0.5 ? "#000": "#FFF";
}
@pixelhandler
pixelhandler / transforms.js
Last active October 3, 2016 06:54
Raw object and array tranforms for Ember Data
/*
DS.attr('object')
*/
App.ObjectTransform = DS.Transform.extend({
deserialize: function(value) {
if (!$.isPlainObject(value)) {
return {};
} else {
return value;
}
@elisechant
elisechant / application.js
Last active August 29, 2015 14:02
Ember data - exploration in mult-dimensional model relationships. Also read this: http://emberjs.com/blog/2014/03/18/the-road-to-ember-data-1-0.html and this http://www.toptal.com/emberjs/a-thorough-guide-to-ember-data. Things to remember: don't think of client data modelling as 1:1 with database tables, so read this too http://discuss.emberjs.c…
/**
* Application code which demonstrates how to define multi-dimensional
* Ember-data relationships.
*
* The example uses the following Model concepts:
* - Issue (representing an Issue)
* - User (representing a User)
* - Vote (representing a User's vote for an Issue; a Pivot Model for
* Issue and User )
*