Skip to content

Instantly share code, notes, and snippets.

View diegocasmo's full-sized avatar
👨‍💻

Diego Castillo diegocasmo

👨‍💻
View GitHub Profile
@joshbeckman
joshbeckman / index.js
Created October 10, 2015 17:37
An example Node.js server that can verify a Shopify webhook's integrity. Run with `node index.js`.
const PORT = 3000;
const SECRET = 'APP_SHARED_SECRET';
var http = require('http'),
crypto = require('crypto'),
server;
function verifyShopifyHook(req) {
var digest = crypto.createHmac('SHA256', SECRET)
.update(new Buffer(req.body, 'utf8'))
@Jhony0311
Jhony0311 / tabChange
Last active November 19, 2015 17:48
Browser tab visibility control
var eventName = "visibilitychange";
if (document.webkitHidden != undefined) {
eventName = "webkitvisibilitychange";
} else if (document.mozHidden != undefined) {
eventName = "mozvisibilitychange";
} else if (document.msHidden != undefined) {
eventName = "msvisibilitychange";
} else if (document.hidden != undefined) {
} else {
@mlanett
mlanett / rails http status codes
Last active May 3, 2024 04:15
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@ndnichols
ndnichols / buildProperties.coffee
Created November 15, 2012 17:28
A function for automatically adding getter/setters to Backbone models.
buildProperties = (func) ->
buildGetter = (name) ->
-> @get name
buildSetter = (name) ->
(value) -> @set name, value
for attr in func.prototype.attributeNames
Object.defineProperty func.prototype, attr,
get: buildGetter attr
set: buildSetter attr
@zakmandhro
zakmandhro / inline_block.scss
Created May 18, 2011 18:35
Cross-browser inline block (SASS mixin)
@mixin inline-block {
display: -moz-inline-stack; // ff 2
display: inline-block;
zoom:1; *display: inline; _height: 15px; // ie 6-7
}