Skip to content

Instantly share code, notes, and snippets.

@prettymuchbryce
prettymuchbryce / gist:5542020
Last active April 29, 2021 14:50
hello TypeScript & node.js
/// <reference path="./.node-definitions/node.d.ts" />
/**
* See the node.js TypeScript definition needed for this
* example here: https://github.com/borisyankov/DefinitelyTyped
*/
import Http = module('http');
class MyServer {
@prettymuchbryce
prettymuchbryce / Dictionary.java
Created September 14, 2012 02:26
Dictionary with trie tree Java
//Dictionary implemented using a Trie Tree.
public class Dictionary {
private HashMap<Character,Node> roots = new HashMap<Character,Node>();
/**
* Search through the dictionary for a word.
* @param string The word to search for.
* @return Whether or not the word exists in the dictionary.
*/
public boolean search(String string) {
@prettymuchbryce
prettymuchbryce / gist:3768553
Created September 23, 2012 02:08
Javascript Priority Queue Implementation
//Constants
PriorityQueue.MAX_HEAP = 0;
PriorityQueue.MIN_HEAP = 1;
/**
* This is an improved Priority Queue data type implementation that can be used to sort any object type.
* It uses a technique called a binary heap.
*
* For more on binary heaps see: http://en.wikipedia.org/wiki/Binary_heap
*
@prettymuchbryce
prettymuchbryce / url2png.js
Created February 8, 2014 06:10
url2png example
var API_KEY = "XXX";
var SECRET_KEY = "XXX";
var crypto = require('crypto');
var url2png = function() {
this.generateLink = function(url) {
var options = "?url="+url + "&viewport=1480x1037&thumbnail_max_width=500";
var token = crypto.createHash('md5').update(options + SECRET_KEY).digest('hex');
return "http://api.url2png.com/v6/"+API_KEY+"/"+token+"/png/"+options;
@prettymuchbryce
prettymuchbryce / addrinuse.go
Created July 17, 2016 15:38
Close() on *net.UDPConn is not calling close syscall
package main
import "net"
const maxRecvSize = 0x2000
func main() {
for i := 0; i < 100000; i++ {
p, err := net.ListenPacket("udp", "127.0.0.1:3000")
if err != nil {

Keybase proof

I hereby claim:

  • I am prettymuchbryce on github.
  • I am prettymuchbryce (https://keybase.io/prettymuchbryce) on keybase.
  • I have a public key whose fingerprint is BF79 21A4 1364 77F0 0E48 3E19 5DE7 7775 95F5 B778

To claim this, I am signing this object:

//For node.js
if (typeof window === 'undefined' && typeof module !== 'undefined' && module.exports) {
module.exports = EasyStar;
}
function getAspectRatio() {
var ar = .8;
this.magicNumberNeverDeclaredAnywhere = 10;
ar * this.magicNumberNeverDeclaredAnywhere / 4; //divded by 4 bc why not lol. im new here u guys seem cool
var forSomeReasonAFunction = function(value) {
value = value * value / value;
this.value = value;
//Sieve of Eratosthenes
function findPrimesUpTo(value) {
var primes = [];
primes.push(false,false);
for (var i = 2; i < value; i++) {
primes.push(true);
}
for (var i = 2; i < Math.sqrt(value); i++) {
if (primes[i] == true) {
@prettymuchbryce
prettymuchbryce / gist:6471566
Created September 7, 2013 00:10
Haxe bug (HTML5/Javascript target)
package test;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
class Main extends Sprite {
private var _bitmaps:Array<Dynamic>;