Skip to content

Instantly share code, notes, and snippets.

View wezm's full-sized avatar

Wesley Moore wezm

View GitHub Profile
@jamiecobbett
jamiecobbett / notifier.js
Created August 2, 2011 11:12
Patched Hoptoad/Airbrake notifier.js to avoid an error when jQuery.Event hits window.onerror
var Hoptoad = {
VERSION : '0.1.0',
NOTICE_XML : '<?xml version="1.0" encoding="UTF-8"?><notice version="2.0"><api-key></api-key><notifier><name>hoptoad_notifier_js</name><version>0.1.0</version><url>http://hoptoadapp.com</url></notifier><error><class>EXCEPTION_CLASS</class><message>EXCEPTION_MESSAGE</message><backtrace>BACKTRACE_LINES</backtrace></error><request><url>REQUEST_URL</url><component>REQUEST_COMPONENT</component><action>REQUEST_ACTION</action></request><server-environment><project-root>PROJECT_ROOT</project-root><environment-name>production</environment-name></server-environment></notice>',
ROOT : window.location.protocol + '//' + window.location.host,
BACKTRACE_MATCHER : /^(.*)\@(.*)\:(\d+)$/,
backtrace_filters : [/notifier\.js/],
notify: function(error) {
var xml = escape(Hoptoad.generateXML(error));
var host = Hoptoad.host || 'hoptoadapp.com';
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
#!/usr/bin/ruby
# Must install libusb library via your favorite package manager
# Then install libusb ruby gem, via $ sudo gem install libusb
require 'libusb'
# Call provided blocks when key is pressed or released
def handle_pedal(device, onpress, onrelease)
device.open do |h|
@marcedwards
marcedwards / high-dpi-media.css
Last active November 19, 2023 12:56
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
@maciekish
maciekish / UINavigationBar+CustomHeight.h
Created September 10, 2014 08:48
Custom UINavigationBar height working in iOS 7 and 8. To use, find your navigation bar reference and just setHeight:200 etc.
//
// UINavigationBar+CustomHeight.h
//
// Copyright (c) 2014 Maciej Swic
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@PurpleBooth
PurpleBooth / README-Template.md
Last active May 27, 2024 04:25
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

#!/usr/bin/perl
# This filter changes all words to Title Caps, and attempts to be clever
# about *un*capitalizing small words like a/an/the in the input.
#
# The list of "small words" which are not capped comes from
# the New York Times Manual of Style, plus 'vs' and 'v'.
#
# 10 May 2008
# Original version by John Gruber:
@mattweldon
mattweldon / up-and-running-with-edeliver-on-do.md
Last active September 3, 2021 16:48
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys
@MaskRay
MaskRay / compiler.ml
Last active November 2, 2022 07:18
Implementing Functional Languages: a tutorial, Template instantiation
open Syntax
module IntMap = Map.Make(struct type t = int let compare = compare end)
module List = struct
include List
let zip xs ys =
let rec go acc = function
| [], _ | _, [] -> List.rev acc
| x::xs, y::ys -> go ((x,y)::acc) (xs,ys)
@cyberang3l
cyberang3l / extract-git-folder-with-history.md
Created April 12, 2016 14:55
GIT: How to extract a specific folder from a git repository branch, including the folder's related git history only

GIT: How to extract a specific folder from a git repository branch, including the folder's related git history only

NOTE: If you want to keep the history for a specific folder in the master branch, just skip steps in lines 3,4,5,6,7

git clone <git-repository-url>
cd <git-repository-dir>

git checkout <branch-name>              # line 3; Checkout the branch of interest
git merge --strategy=ours master        # line 4; keep the content of this branch only and record a merge
git checkout master                     # line 5; Go back to the master branch