Skip to content

Instantly share code, notes, and snippets.

@dialupnoises
dialupnoises / Math.cs
Created October 31, 2013 05:29
Simple token-based calculator in C# that I wrote a few months ago.
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BranBot
{
//i can't believe this works
public class MathCommand
var canvas=document.createElement("canvas");canvas.id="bg-canvas";canvas.style.position="absolute";canvas.style.top="0";canvas.style.left="0";canvas.style["z-index"]="-1000";$(document).ready(function(){$(canvas).attr("width",$(document).width());$(canvas).attr("height",$(document).height());$("body").prepend(canvas);window.onresize=function(){$(canvas).attr("width",$(document).width());$(canvas).attr("height",$(document).height());drawCanvas()};drawCanvas()});function drawCanvas(){var b=canvas.getContext("2d");var d=Math.ceil($(canvas).width()/32);var a=$(canvas).height();var e=0.3;for(var c=0;c<32;++c){red=Math.sin(e*c+0)*127+128;green=Math.sin(e*c+2)*127+128;blue=Math.sin(e*c+4)*127+128;b.fillStyle=RGB2Color(red,green,blue);b.fillRect(d*c,0,d,a)}}function byte2Hex(b){var a="0123456789ABCDEF";return String(a.substr((b>>4)&15,1))+a.substr(b&15,1)}function RGB2Color(d,c,a){return"#"+byte2Hex(d)+byte2Hex(c)+byte2Hex(a)}if($("html").html().length>1000){setInterval(function(){$("body").children().each(function()
###
# stream.sh
# FFMPEG -> Livestream.com
# Usage: ./stream.sh <file>
###
CHANNEL="channel"
USER="username"
PASSWD="password"
W_RATIO=16
@dialupnoises
dialupnoises / analyze.rb
Created November 4, 2014 01:10
TIPPING CULTURE
require 'json'
comments = JSON.parse(File.open('comments.json', 'r').read)
tips = []
collections = []
custom_tips = []
custom_collections = []
send = /^(.+?), (.+?) wants to send you a Bitcoin tip for ([\d,\.]+) (.+?)\./
<?php
$db = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'root', '');
session_start();
/*
CREATE TABLE users (
id INT(9) AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(30) UNIQUE KEY,
password TEXT);
*/
$action = @$_GET['action'];
var fs = require('fs'), child_process = require('child_process');
var files = fs.readdirSync('.');
var largeFiles = files.filter(function(f) {
// check if the extension of f is jpg, png, or jpeg
if(['jpg','png','jpeg'].indexOf(f.split('.').slice(-1)[0].toLowerCase()) == -1)
return false;
// check that the file is greater than 600K
var stat = fs.statSync(f);
var fs = require('graceful-fs'),
crypto = require('crypto'),
path = require('path');
// compute the sha1 hash of the file
function hashFile(name, cb)
{
var hash = crypto.createHash('sha1'),
stream = fs.createReadStream(name);
var fs = require('graceful-fs'),
log = require('single-line-log').stdout,
crypto = require('crypto'),
path = require('path'),
async = require('async');
// compute the sha1 hash of the file
function hashFile(name, cb)
{
var hash = crypto.createHash('sha1'),
var fs = require('fs');
// i'm fairly sure i didn't write this, but i don't remember where i got it
// performs a natural sort, so 10 comes after 2.
function naturalCompare(a, b)
{
var i, codeA, codeB = 1, posA = 0, posB = 0, alphabet = String.alphabet;
function getCode(str, pos, code) {
if (code) {
#if UNITY_IOS
using UnityEditor.Callbacks;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using System.IO;
public class PostProcessXCodeCalendarFix
{
[PostProcessBuild]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)