Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Doing the things

Ben Boyter boyter

💭
Doing the things
View GitHub Profile
View gist:0cffa9ff8e2e7259d455594d744f1164
// Primitive hash function that for a string returns a positive 32 bit int
// Do not use in production, use murmur3 or fnv1
// You can improve this by changing 5 to 31
Object.defineProperty(String.prototype, 'hashCode', {
value: function() {
var hash = 0, i, chr;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
@boyter
boyter / main.go
Created Aug 19, 2018
Walk directory in Go
View main.go
package main
import (
"fmt"
"github.com/karrick/godirwalk"
"io/ioutil"
)
func main() {
godirwalk.Walk("./", &godirwalk.Options{
@boyter
boyter / main.rs
Created Aug 19, 2018
Walk directory in Rust
View main.rs
extern crate walkdir;
use walkdir::WalkDir;
use std::fs::File;
use std::io::Read;
fn main() {
let nul = 0;
let mut bytes_count: i32;
@boyter
boyter / README.md
Created Feb 14, 2018 — forked from miguelmota/README.md
Multiple accounts with Mutt E-Mail Client (gmail example)
View README.md

How to set up multiple accounts with Mutt E-mail Client

Thanks to this article by Christoph Berg

Instructions

Directories and files

~/
@boyter
boyter / Main.java
Created Dec 19, 2017
Identify Path Walking Issues in Java without Link Follow
View Main.java
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
public class Main {
public static void main(String argv[]) {
Main main = new Main();
@boyter
boyter / GCC_License.txt
Created May 1, 2017
Output of license checker against GCC project
View GCC_License.txt
This file has been truncated, but you can view the full file.
>>>>>>> gcc/COPYING GPL-2.0
>>>>>>> gcc/COPYING GPL-2.0
>>>>>>> gcc/COPYING GPL-1.0
>>>>>>> gcc/COPYING GPL-1.0
>>>>>>> gcc/COPYING.LIB LGPL-2.1
>>>>>>> gcc/COPYING3 GPL-3.0
>>>>>>> gcc/COPYING3 GPL-3.0
>>>>>>> gcc/COPYING3 GPL-2.0
>>>>>>> gcc/COPYING3 GPL-2.0
@boyter
boyter / Main.java
Last active Dec 19, 2017
Identify Path Walking Issues in Java
View Main.java
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.EnumSet;
public class Main {
public static void main(String argv[]) {
Main main = new Main();
@boyter
boyter / Puzzle.java
Last active Apr 20, 2017
Friday Quiz Solution
View Puzzle.java
/*
Three people are playing the following betting game.
Every five minutes, a turn takes place in which a random player rests and the other two bet
against one another with all of their money.
The player with the smaller amount of money always wins,
doubling his money by taking it from the loser.
For example, if the initial amounts of money are 1, 4, and 6,
then the result of the first turn can be either
2,3,6 (1 wins against 4);
1,8,2 (4 wins against 6); or
@boyter
boyter / puzzle.py
Last active Apr 9, 2017
Friday Quiz Solution
View puzzle.py
# Three people are playing the following betting game.
# Every five minutes, a turn takes place in which a random player rests and the other two bet
# against one another with all of their money.
# The player with the smaller amount of money always wins,
# doubling his money by taking it from the loser.
# For example, if the initial amounts of money are 1, 4, and 6,
# then the result of the first turn can be either
# 2,3,6 (1 wins against 4);
# 1,8,2 (4 wins against 6); or
# 2,4,5 (1 wins against 6).