Skip to content

Instantly share code, notes, and snippets.

Avatar
🗃️
Archiving all the things!

Nick Sweeting pirate

🗃️
Archiving all the things!
View GitHub Profile
@pirate
pirate / mysetup.sublime-keymap
Created Sep 15, 2014
My Sublime 3 Keybindings
View mysetup.sublime-keymap
[
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+super+up"], "command": "swap_line_up" },
{ "keys": ["ctrl+super+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+super+t"], "command": "transpose" },
{ "keys": ["alt+left"], "command": "move", "args": {"by": "subwords", "forward": false} }, // move & select by word
{ "keys": ["alt+right"], "command": "move", "args": {"by": "subword_ends", "forward": true} },
@pirate
pirate / tictactoe.cpp
Last active Dec 31, 2015
Early version of C tictactoe
View tictactoe.cpp
/* Nick Sweeting 2013/09/09
Tic Tac Toe in C++ (non OOP)
MIT Liscense
save as tictactoe.cpp, then run
`g++ tictactoe.cpp -o tic && ./tic` to run
*/
#include <stdlib.h>
#include <iostream>
@pirate
pirate / clojure.md
Created Jan 20, 2014 — forked from rakhmad/clojure.md
Quickstart Clojure on OS X
View clojure.md

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

Step 1: Getting Clojure (1.3)

@pirate
pirate / python_resources.md
Created Jan 21, 2014 — forked from jookyboi/python_resources.md
Python-related modules and guides.
View python_resources.md

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@pirate
pirate / css_resources.md
Created Jan 21, 2014 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.
View css_resources.md

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@pirate
pirate / javascript_resources.md
Created Jan 21, 2014 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.
View javascript_resources.md

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@pirate
pirate / .pythonrc.py
Last active Feb 26, 2016
Pythonrc with Shortcuts for ls, ll, cd, and quit
View .pythonrc.py
"""Some common helper functions to put in your ~/.pythonrc to make the python REPL behave more like a real shell."""
import os
def cd(folder):
"""e.g. cd('/bin')"""
os.chdir(folder)
def quit():
raise SystemExit(0)
@pirate
pirate / websockets.js
Created Feb 26, 2016
Websocket redux action queuer
View websockets.js
/* Socket wrapper that gracefully handles disconnects and passes messages to redux as actions. */
export default class SocketRouter {
constructor(store, notifier, loadStart, loadFinish, socket_url) {
// takes a redux store, optional functions to display notifications & loading bars, and an optional socket_url
this.ready = false
this.queue = []
this.store = store || null
this.reconnects = -1
this.socket_url = socket_url || this._detectPath(window.location)
this.notifier = notifier || ((message, pending) => console.log(message, pending && 'Pending...'))
@pirate
pirate / websocket_handlers.py
Last active Feb 26, 2016
Tornado Websocket router for receiving Redux actions
View websocket_handlers.py
def get_websocket_urls(routes):
"""Generate list of all /page/websocket routes from a list of routes"""
for route in routes:
url, handler = route[0], route[1]
if hasattr(handler, 'socket'):
ws_url = (url if url.endswith('/') else url + '/') + 'websocket'
yield (ws_url, handler.socket.Handler)
class BaseSocketHandler(BaseHandler, WebSocketHandler):
View inject css or js extension
function exec(fn) {
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = '(' + fn + ')();';
document.body.appendChild(script); // run the script
document.body.removeChild(script); // clean up
}
// with the below added to the manifest file