Skip to content

Instantly share code, notes, and snippets.

View ngryman's full-sized avatar

Nicolas Gryman ngryman

View GitHub Profile
@ngryman
ngryman / css3.scss
Created November 1, 2011 11:18
SASS compact CSS3
@mixin border-radius($values) {
@include css3-prefix(3, border-radius, $values);
}
@mixin box-shadow($x, $y, $offset, $color) {
@include css3-prefix(4, box-shadow, $x $y $offset $color);
$iecolor: '#' + red($color) + green($color) + blue($color);
filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}');
-ms-filter: quote(progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}'));
@ngryman
ngryman / gist:1349521
Created November 8, 2011 22:36
Vendor prefix detection
(function() {
// Following spec is to expose vendor-specific style properties as:
// elem.style.WebkitBorderRadius
// and the following would be incorrect:
// elem.style.webkitBorderRadius
// Webkit ghosts their properties in lowercase but Opera & Moz do not.
// Microsoft foregoes prefixes entirely <= IE8, but appears to
// use a lowercase `ms` instead of the correct `Ms` in IE9
@ngryman
ngryman / binary_search.js
Created July 18, 2012 18:10
javascript binarySearch
Array.prototype.binarySearch = function(key) {
var low = 0,
high = this.length - 1;
while (low <= high) {
var mid = (low + high) >>> 1;
var midVal = this[mid];
if (midVal < key)
low = mid + 1;
@ngryman
ngryman / utf8_chars
Last active February 1, 2018 11:08
utf-8 cool chars
inspired by https://www.linkedin.com/profile/view?id=4270384
Fun Face: ᙅ•℧•ᙂ (͡๏̯͡๏)
Stars: ★ ✪ ✯ ✰
Arrows: ☛ ☚ ☜ ☝ ☞ ☟ ⇨ ► ◄ ► » → ↓
Traditional bullets: ■ ♦ ◆ ●
Ticks: ✔ ✘ ☐ ☑ ☒
Email: ✉ ✍ ✎ ✏ ✑ ⌨
Phone: ✆ ☎ ☏
Misc: ♫
@ngryman
ngryman / Jakefile
Created September 15, 2012 16:44
git deploy
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var fs = require('fs');
task('install-deps', ['setup'], function() {
console.log('\n\n > Attempting to install dependencies via npm\n'.blue);
console.log('\tExecuting command:\n\t$ npm install\n'.grey);
var npm = spawn('npm', ['install']);
@ngryman
ngryman / service.conf.sh
Created October 2, 2012 21:10
Post: Using upstart with forever to manage your node.js application
#!upstart
description "your fancy description that no one will see ;)"
author "Your Name <youremail@fqdn>"
# start on every run level, 2 is the one on Ubuntu
start on runlevel [2345]
# stop on halt, maintenance or reboot
stop on runlevel [016]
@ngryman
ngryman / random.js
Created October 3, 2012 23:13
random seed
// the initial seed
Math.seed = 6;
// in order to work 'Math.seed' must NOT be undefined,
// so in any case, you HAVE to provide a Math.seed
Math.seededRandom = function(max, min) {
max = max || 1;
min = min || 0;
Math.seed = (Math.seed * 9301 + 49297) % 233280;
@ngryman
ngryman / service.sh
Created October 4, 2012 16:50
Post: System V with forever for your node.js application
#! /bin/sh
### BEGIN INIT INFO
# Provides: your_application
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: your fancy description that no one will see ;)
@ngryman
ngryman / index.html
Created November 6, 2012 15:50
html5shiv & set(Timeout|Interval) fix
<!-- html5shiv & set(Timeout|Interval) fix -->
<!--[if lte IE 9]>
<script>
/*@cc_on(function(a,b){function r(a){var b=-1;while(++b<f)a.createElement(e[b])}if(!(!window.attachEvent||!b.createStyleSheet||!function(){var a=document.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}())){a.iepp=a.iepp||{};var c=a.iepp,d=c.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",e=d.split("|"),f=e.length,g=new RegExp("(^|\\s)("+d+")","gi"),h=new RegExp("<(/*)("+d+")","gi"),i=/^\s*[\{\}]\s*$/,j=new RegExp("(^|[^\\n]*?\\s)("+d+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),k=b.createDocumentFragment(),l=b.documentElement,m=l.firstChild,n=b.createElement("body"),o=b.createElement("style"),p=/print|all/,q;c.getCSS=function(a,b){if(a+""===undefined)return"";var d=-1,e=a.length,f,g=[];while(++d<e){f=a[d];if(f.disabled)continue;b=f.media||b,p.test(b)&&g.push(c.getCSS(f.imports,b),f.c
@ngryman
ngryman / README.md
Last active January 16, 2023 14:07
intellij javascript live templates

intellij javascript live templates

Just a dump of handy live templates I use with IntelliJ. They should also work with WebStorm.

How to

  • Go to settings.
  • Search for live templates.
  • Under the javascript section you should be able to manage your templates.