Skip to content

Instantly share code, notes, and snippets.

View elenzil's full-sized avatar

orion elenzil elenzil

  • seattle, usa
View GitHub Profile
@elenzil
elenzil / digits.cpp
Last active October 5, 2020 17:22
brute force & iterative solution to the self-descriptive ten-digit base-ten number problem. generalized to N digits, base 10. (1 <= N <= 10)
#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
void printIt(uint64_t n, char s[11], size_t digits = 10) {
char format[100];
snprintf(format, 100, "%%0%dju", digits);
snprintf(s, 11, format, n);
}
@elenzil
elenzil / gist:d3af54a16c7562bfdcd19d440f9fce7c
Created May 2, 2019 17:04
command-line for viewing a repository's network graph similar to GitHub's
# GitHub recently "deprecated" the network view of repositories, which was a tool i relied on.
# merging this S.O. answer: https://stackoverflow.com/a/9074343/230851
# with some other research gets me to the command below.
# the only notable addition is setting the ordering to --date-order, to match github's network view.
#
# note!
# you'll still need to `git fetch` prior to this to view branches on the server.
git log --all --graph --date-order --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@elenzil
elenzil / BetterToggleGroup.cs
Last active May 5, 2024 20:18 — forked from jmbeach/BetterToggleGroup.cs
Improved ToggleGroup for Unity GUI
using System;
using UnityEngine;
using UnityEngine.UI;
// based on https://gist.github.com/jmbeach/78c3e46669db89628fce
public class BetterToggleGroup : ToggleGroup {
public Action<Toggle> OnChange;
protected override void Start() {
@elenzil
elenzil / brython_dict.html
Created October 9, 2018 18:10
brief demonstration of what seems like a bug in brython's handling of javascript dictionary objects.
<html>
<head>
<script type="text/javascript" src="/src/brython.js"></script>
<script type="text/python">
from browser import window
import json
def call_me():
s = json.dumps(window.my_dict_1.to_dict())
print("dict 1 serialized by python: %s" % (s))
import copy
import time
# fun from Ernest!
#
# Given two strings s and t, determine whether some anagram of t is a substring of s.
# For example: if s = "udacity" and t = "ad", then the function returns True.
# Your function definition should look like: question1(s, t) and return a boolean True or False.
def q_ernest(s, t):
import copy
# fun from Ernest!
#
# Given two strings s and t, determine whether some anagram of t is a substring of s.
# For example: if s = "udacity" and t = "ad", then the function returns True.
# Your function definition should look like: question1(s, t) and return a boolean True or False.
# approach by orion.
@elenzil
elenzil / justbytes.c
Last active November 11, 2024 07:58
super simple table of hex, decimal, binary and ascii. with source. 0 through 255 and -128 through 127 in decimal, binary, and hex.
/*
0 0x00 0b00000000
1 0x01 0b00000001
2 0x02 0b00000010
3 0x03 0b00000011
4 0x04 0b00000100
5 0x05 0b00000101
6 0x06 0b00000110
7 0x07 0b00000111
8 0x08 0b00001000
@elenzil
elenzil / git_to_ssh.sh
Created February 16, 2017 00:31
osx bash script to convert all repositories to use ssh urls. useful when moving to ssh access from http, which is good for two-factor authentication.
#!/bin/bash
# this is provided as-is, with no guarantees that it will work or not explode your computer.
# written for OSX.
#
# orion elenzil 2017
#
# Motivation:
# If you are moving to two-factor authentication,
# you may also want to move from http-access to ssh-access.
@elenzil
elenzil / gist:5c52eccc33c7f8616755
Last active August 29, 2015 14:19
orion's solution to cheryl's birthday
this is the puzzle: http://www.techworm.net/2015/04/when-the-hell-is-cheryls-birthday-a-math-problem-from-singapore-goes-viral.html
first, the puzzle is a little weird because it doesn't explain how Albert knows Bernard does not know.
but ignoring that, or assuming that before Albert spoke, Bernard said "I do not know".
it's also not explicit about who knows which:
I make the assumption that Albert knows the month and Bernard knows the day number.
Albert knows Bernard does not know, which means it's not one of the day numbers which occur only once,
which means it's not May 19 or June 18.