Skip to content

Instantly share code, notes, and snippets.

View indieisaconcept's full-sized avatar

Jonathan Barnett indieisaconcept

View GitHub Profile
@alexreardon
alexreardon / drag-and-drop-notes.md
Last active March 19, 2024 23:27
An explanation of the timing of drag and drop events

Drag and drop

This is a collection of knowledge I have built up regarding browser powered drag and drop functionality

Events

dragstart

  • timing: once as drag is starting
  • event.target: draggable Element
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@brasic
brasic / clear_redis_script.rb
Last active October 13, 2020 19:52
Clear a large number of redis keys by pattern using SCAN and pipelining
#!/usr/bin/env ruby
require 'redis'
# Clear a large number of keys matching a pattern using SCAN and
# pipelining to avoid killing the server.
class ClearKeys
def initialize(pattern, host='localhost', postprocess_pattern=nil)
@redis = Redis.new(host: host)
@pattern = pattern
#!/bin/bash
usage ()
{
cat <<UsageHERE
boot2docker-fwd -- Helper function to quickly manage port forwards between the boot2docker-vm and the host
Usage: boot2docker-fwd [ -n RULE_NAME ] [ -h HOST_PORT ] [ -p {tcp|udp} ] [ -i HOST_IP ] GUEST_PORT
or boot2docker-fwd -d RULE_NAME
or boot2docker-fwd -l
or boot2docker-fwd -A
@cerebrl
cerebrl / 1-securing-express.md
Last active August 2, 2023 22:48
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@jedi4ever
jedi4ever / nodejs-cluster-zero-downtime.md
Last active February 11, 2024 13:45
nodejs clustering, zero downtime deployment solutions

Clustering: The basics

The trick? pass the file descriptor from a parent process and have the server.listen reuse that descriptor. So multiprocess in their own memory space (but with ENV shared usually)

It does not balance, it leaves it to the kernel.

In the last nodejs > 0.8 there is a cluster module (functional although marked experimental)

@durango
durango / app.js
Created December 3, 2012 15:41 — forked from katanacrimson/app.js
nodejs app - expressjs 3.0 + socket.io v9 + passport + redis
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
@miohtama
miohtama / gist:4062655
Created November 12, 2012 23:04
Migrate several SVN projects to Github using a shell script
#!/bin/zsh
#
# Install svn2git https://github.com/nirvdrum/svn2git
# Install curl: sudo apt-get install curl
#
# Create API token Github on command line before running this script
#
# curl -u 'miohtama' -d '{"scopes":["repo"],"note":"migrate.sh"}' https://api.github.com/authorizations
#
# More info https://help.github.com/articles/creating-an-oauth-token-for-command-line-use
@mlafeldt
mlafeldt / parse_cheffile.rb
Created October 23, 2012 15:08
Parse Cheffile in Ruby
#!/usr/bin/env ruby
class CookbookSource
attr_reader :name, :options
def initialize(name, options = {})
@name = name
@options = options
end
end
@michaelcox
michaelcox / SpecRunner.js
Last active January 11, 2024 06:05
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'