Skip to content

Instantly share code, notes, and snippets.

View pzp1997's full-sized avatar

Palmer Paul pzp1997

View GitHub Profile
@pzp1997
pzp1997 / Pong.pde
Created November 12, 2014 02:28
Pong written in Processing.
/*
Pong.pde: The classic game "Pong" written in Processing
Author: Palmer Paul
Email: pzpaul2002@yahoo.com
Twitter: @pzp1997
Version: 1.0.0 (10/29/14 07:25)
Copyright: (c) 2014, Palmer Paul
*/
float p1, p2;
@pzp1997
pzp1997 / setInterval.swift
Last active January 19, 2021 09:34
Rough implementation of the JavaScript setInterval function in Swift. Good for JavaScriptCore.
var nextTimerId = 0
var timerRegistry = [Int: Timer]()
let setInterval: @convention(block) (JSValue, Double) -> Int = { (function, interval) in
let timer = Timer.scheduledTimer(timeInterval: interval / 1000.0, repeats: true, action: { (timer) in
function.call(withArguments: [])
})
let timerId = nextTimerId
timerRegistry[timerId] = timer
javascript:(function(){document.querySelector('video').playbackRate=parseFloat(prompt('Set the playback speed')||1)})()
javascript:(function(){clearInterval(window.autoscrollerBookmarkTimerID);var s=parseFloat(prompt('Set the scroll frequency in ms'));if(s){window.autoscrollerBookmarkTimerID=setInterval(function(){window.scrollBy(0,1)},s)}})()
javascript:(function(){document.head.appendChild(document.createElement("style")).innerText="html,img,video{-webkit-filter:invert(1)hue-rotate(180deg);filter:invert(1)hue-rotate(180deg)}body{background:#000}"})()
javascript:(function(){if(window.debugBordersStyleNode){document.head.removeChild(window.debugBordersStyleNode);window.debugBordersStyleNode=undefined}else{window.debugBordersStyleNode=document.createElement("style");window.debugBordersStyleNode.innerText="*{border:1px solid red}";document.head.appendChild(window.debugBordersStyleNode)}})()
javascript:!function(d)%7Bd.head.appendChild(d.createElement(%27style%27)).innerText%3D%27html,img,video%7B-webkit-filte
module Main exposing (main)
import Html
windows : List a -> List ( a, a )
windows list =
case list of
x :: ((y :: _) as xs) ->
( x, y ) :: windows xs
data Can.Def
= Def (A.Located Name) [Pattern] Can.Expr
| TypedDef (A.Located Name) FreeVars [(Pattern, Type)] Can.Expr Type
data Can.Decls
= Declare Can.Def Can.Decls
| DeclareRec Can.Def [Can.Def] Can.Decls
| SaveTheEnvironment
data ModuleName.Canonical =
public class EuclidAglo {
// cd(x, y, z) <==> (x % z == 0) && (y % z == 0)
// gcd(x, y, z) <==> cd(x, y, z) && (\forall int k;; cd(x, y, k) ==> k <= z)
//@ requires true;
//@ ensures (x % \result == 0) && (y % \result == 0) && (\forall int k;; (x % k == 0) && (y % k == 0) ==> k <= \result);
public static int run(int x, int y) {
int n = x;
int m = y;
//@ maintaining (\forall int z;; ((x % z == 0) && (y % z == 0) && (\forall int k;; (x % k == 0) && (y % k == 0) ==> k <= z)) <==> ((n % z == 0) && (m % z == 0) && (\forall int k;; (n % k == 0) && (m % k == 0) ==> k <= z)));
@pzp1997
pzp1997 / Followers.py
Created August 19, 2014 01:51
Python script for discovering who unfollowed you on Instagram (and unfollowing those people).
#!/usr/bin/env python2.7
"""Discovers who unfollowed you on Instagram (and unfollows those people)."""
import json
from webbrowser import open_new_tab
from urllib2 import urlopen, URLError
from urlparse import urlparse
from time import time
from os import rename
// COUNTERS FOR INSTRUMENTATION
var refEqSkippedNodes, refEqSkippedDescendants;
function _VirtualDom_diff(x, y)
{
var patches = [];
refEqSkippedNodes = 0;
refEqSkippedDescendants = 0;
_VirtualDom_diffHelp(x, y, patches, 0);
var canvasWidth = 500;
var canvasHeight = 500;
var g = 0.04;
var playerWidth = 30;
var playerHeight = 50;
var gameState = "start";
var playerX, projectile, balls, numArrowsUsed, startTime, timeElapsed;
reset();