Skip to content

Instantly share code, notes, and snippets.

View dented's full-sized avatar
🎯
Focusing

Gram dented

🎯
Focusing
View GitHub Profile
@dented
dented / circle.yml
Created November 18, 2016 03:17
RethinkDB for circle ci
machine:
ruby:
version: 2.2.3
general:
branches:
only:
- master
- develop
@dented
dented / nginx.conf
Created July 26, 2016 17:11
Nginx Upload Module Chunked
# See http://wiki.nginx.org/HttpUploadModule
location = /upload-restore-archive {
# if resumable uploads are on, then the $upload_field_name variable
# won't be set because the Content-Type isn't (and isn't allowed to be)
# multipart/form-data, which is where the field name would normally be
# defined, so this *must* correspond to the field name in the Rails view
set $upload_field_name "archive";
# location to forward to once the upload completes
@dented
dented / gist:dff4f412d0d3a9b9c40f
Created November 4, 2015 07:55 — forked from linickx/gist:3692156
hubot init script for RHEL / CENTOS
#!/bin/bash
# hubot
# chkconfig: 345 20 80
# description: hubot
# processname: hubot
# REFERENCE: http://werxltd.com/wp/2012/01/05/simple-init-d-script-template/
# This script assumes you have a user called "hubot" on your system and that hubot is installed in /opt/hubot
@dented
dented / jquery.extend.data-grouping.js
Last active September 15, 2015 03:22
Retrieve Groups of prefixed data attributes (data-options-id, data-options-name, etc)
function camelize(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (letter, index) {
return index == 0 ? letter.toLowerCase() : letter.toUpperCase();
}).replace(/\s+/g, '');
}
$.fn.extend({
dataGrouping: function (attributeName) {
var regExp = new RegExp('^' + attributeName),
attributesFound = {};
@dented
dented / factory.js
Created September 8, 2015 10:11
Factory
(function (factory) {
if (typeof define === "function" && define.amd) {
define( ["jquery"], factory );
} else {
factory( window.jQuery );
}
}(function ($) {
}));
@dented
dented / custom_errors.js
Created September 8, 2015 10:09
Custom Error Constructor
Error.custromConstructor = (function() {
function define(obj, prop, value) {
Object.defineProperty(obj, prop, {
value: value,
configurable: true,
enumerable: false,
writable: true
});
}
@dented
dented / application_controller.rb
Last active September 6, 2015 07:52
Rails Redirect Old to New
class ApplicationController
before_filter :redirect_if_old
# before_action :redirect_if_old # if Rails 4+
protected
def redirect_if_old
if request.host == 'old.com'
redirect_to "#{request.protocol}new.io#{request.fullpath}", :status => :moved_permanently
end
@dented
dented / my_error.js
Created September 2, 2015 08:44
Custom Error in JavaScript
function MyError(code, msg) {
this.message = msg;
this.statusCode = code;
this.name = 'HttpError';
const err = Error(msg);
this.stack = err.stack;
}
MyError.prototype = Object.create(Error.prototype);
MyError.prototype.constructor = MyError;
@dented
dented / fatty-images.js
Last active September 2, 2015 08:17
Lazy Load Images trials
var images = document.querySelectorAll('img[data-src]'),
imageLength = images.length;
Array.prototype.forEach.call(images, function(image) {
image.setAttribute('src', image.getAttribute('data-src'));
image.onload = function() {
image.removeAttribute('data-src');
};
});
@dented
dented / needle.js
Created August 31, 2015 03:41
Find Value in Array
var indexOf = function(needle) {
if(typeof Array.prototype.indexOf === 'function') {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(needle) {
var i = -1,
index = -1;
for(i = 0; i < this.length; i++) {
if(this[i] === needle) {
index = i;