Skip to content

Instantly share code, notes, and snippets.

@blue0513
blue0513 / eslint-auto.el
Last active January 3, 2020 15:50 — forked from ustun/eslint-auto.el
run eslint --fix on emacs file save
;; forked from https://gist.github.com/ustun/73321bfcb01a8657e5b8
(defun eslint-fix-file ()
(interactive)
(call-process-shell-command
(concat "eslint --fix " (buffer-file-name)) nil 0))
(defun eslint-fix-file-and-revert ()
(interactive)
(eslint-fix-file)
@dblock
dblock / mongoid_criteria.rb
Created May 24, 2012 19:38
Mongoid::Criteria each_by iterator
module Mongoid
class Criteria
def each_by(by, &block)
idx = 0
total = 0
set_limit = options[:limit]
while ((results = ordered_clone.limit(by).skip(idx)) && results.any?)
results.each do |result|
return self if set_limit and set_limit >= total
@masainox
masainox / wordpress-heroku-ja-install.sh
Last active October 3, 2015 08:28
日本語環境のwordpressをherokuにセットアップするスクリプト
#!/bin/sh
git clone git://github.com/masainox/wordpress-heroku.git -b language-ja
cd wordpress-heroku
heroku create -b git://github.com/iphoting/heroku-buildpack-php-tyler.git
heroku addons:add heroku-postgresql:dev
heroku pg:promote `heroku config | grep 'HEROKU_POSTGRESQL_' | sed -e "s/\:.*//"`
@garyharan
garyharan / _mixins.scss
Created May 5, 2011 15:46
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}
@jcxplorer
jcxplorer / uuid.js
Created February 12, 2011 16:58
UUID v4 generator in JavaScript (RFC4122 compliant)
function uuid() {
var uuid = "", i, random;
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i == 8 || i == 12 || i == 16 || i == 20) {
uuid += "-"
}
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
}