Skip to content

Instantly share code, notes, and snippets.

View forivall's full-sized avatar
๐Ÿ•ด๏ธ
levitating

Emily Marigold Klassen forivall

๐Ÿ•ด๏ธ
levitating
View GitHub Profile
@devster31
devster31 / example.html
Last active January 12, 2025 10:23
Bookmark parser for the NETSCAPE-Bookmark-file-1 format in node. Don't hesitate to comment with feedback.
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><A HREF="https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html#//apple_ref/doc/-%20uid/TP40014508" ADD_DATE="1414706885" PRIVATE="0" TAGS="javascript,mac,osx,yosemite">JavaScript for Automation Release Notes</A>
<DD>This article describes JavaScript for Automation, a new feature in OS X Yosemite.
@eevee
eevee / perlin.py
Last active February 25, 2025 13:47
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.
var h = require('hyperscript');
var CronJob = require('cron').CronJob;
var nodemailer = require('nodemailer');
var craigslist = require('node-craigslist');
var options = {
category : 'cta',
maxAsk : '9000',
minAsk : '1000'
};
{
init: function(elevators, floors) {
var floorButtons = new Array(floors.length);
var floorTime = new Array(floors.length);
var UP = 1;
var DOWN = 2;
var DISABLED = 4;
for (var i = 0; i < floorButtons.length; i++) {
floorButtons[i] = 0;
floorTime[i] = 0;
@murbanski
murbanski / api_clients_controller_spec.rb
Last active February 27, 2024 19:53
RSpec 3.1 and Rails 4 HTTP Digest Auth testing
# spec/controllers/api_clients_controller_spec.rb
RSpec.describe APIClientsController, type: :controller do
let(:api_client) { mock_model(APIClient) }
context "when HTTP Digest auth credentials are invalid" do
before do
authenticate_with_http_digest("invalid_login", "invalid_password") do
get :index
end
end
@Weegee
Weegee / hl2.sh
Created June 14, 2014 13:58
Left 4 Dead 2 hl2.sh
#!/bin/bash
# figure out the absolute path to the script being run a bit
# non-obvious, the ${0%/*} pulls the path out of $0, cd's into the
# specified directory, then uses $PWD to figure out where that
# directory lives - and all this in a subshell, so we don't affect
# $PWD
GAMEROOT=$(cd "${0%/*}" && echo $PWD)
@ianklatzco
ianklatzco / Zelda Chest Noise
Last active September 12, 2019 09:03
Plays the chest noise from Legend of Zelda to a speaker or piezoelectric. Should be used with arduino; also works with a 1MHz attiny if you use the second script.
/* This code is derived from:
* http://www.arduino.cc/en/Tutorial/Melody
* This plays the chest noise from the Legend of Zelda on a piezo buzzer connected to pin 9 and ground. It has been tuned to a buzzer I had on hand, but you may want to adjust the values, testing against a tuner.
*/
int speakerPin = 0;
const int switchPin = 1;
char notes[] = "gabygabyxzCDxzCDabywabywzCDEzCDEbywFCDEqywFGDEqi azbC"; // a space represents a rest
int length = sizeof(notes); // the number of notes
@brianarn
brianarn / maths.js
Last active January 22, 2025 18:42
Module to wrap `console.group` around all methods
// A simple object with some methods,
// which throw errors when bad arguments are passed.
var maths = {
square : function (value) {
// Validity checking
if (arguments.length !== 1) {
throw new Error('square: Requires one and only one argument');
}
if (typeof value !== 'number') {
throw new Error('square: Requires numeric argument');
@bripkens
bripkens / event-loop-nashorn.js
Last active August 21, 2021 06:18
Java 8 Nashorn event loop "polyfill". javax.script.ScriptEngine#eval calls should immediately call window.main to enter the event loop and thus to avoid concurrency issues. The XMLHttpRequest simulation is not yet finished.
(function(context) {
'use strict';
var Timer = Java.type('java.util.Timer');
var Phaser = Java.type('java.util.concurrent.Phaser');
var TimeUnit = Java.type('java.util.concurrent.TimeUnit');
var AsyncHttpClient = Java.type('com.ning.http.client.AsyncHttpClient');
var timer = new Timer('jsEventLoop', false);
var phaser = new Phaser();
@joshkunz
joshkunz / vlcwrap.c
Last active December 22, 2015 03:29
Wrapper that will close VLC on OSX with a SIGKILL when it receives a SIGINT (useful if you want to terminate it from the command-line with Control-C).
/* Build, (with your favorite compiler) run:
* cc -o vlcwrap vlcwrap.c */
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define VLC_BIN "/Applications/VLC.app/Contents/MacOS/VLC"