Skip to content

Instantly share code, notes, and snippets.

Daniel Steinberg dstein64

Block or report user

Report or block dstein64

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View smawk.cpp
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>
#include <unordered_map>
using namespace std;
typedef unsigned long ulong;
View kmeans1d.py
import kmeans1d
x = [4.0, 4.1, 4.2, -50, 200.2, 200.4, 200.9, 80, 100, 102]
k = 4
clusters, centroids = kmeans1d.cluster(x, k)
print(clusters) # [1, 1, 1, 0, 3, 3, 3, 2, 2, 2]
print(centroids) # [-50.0, 4.1, 94.0, 200.5]
View medley.py
from distutils.spawn import find_executable
import glob
import os
import random
import shutil
import subprocess
import sys
STYLE_IMAGES_PATH = 'paint-by-numbers/test'
CONTENT_IMAGE_PATH = 'boston.jpg'
View factorial.c
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
/*
* Calculates factorial.
* Overflow is not checked/handled.
*/
int factorial(int x) {
assert(x >= 0);
@dstein64
dstein64 / bezier_neural_walk.py
Last active Sep 12, 2018
Random Bézier Walk in a Random Neural Network
View bezier_neural_walk.py
#!/usr/bin/env python
from __future__ import print_function
# Images can be converted to video with ffmpeg.
# > ffmpeg -pattern_type glob \
# -i "*.png" \
# -vcodec libx264 \
# output.avi
View printenv.s
/*** printenv.s ***/
// Description
// printenv - print the environment to stdout
// Synopsis
// printenv
// Build
// $ as --32 -o printenv.o printenv.s
// $ ld -m elf_i386 -o printenv printenv.o
View printenv_partial.s
/*** printenv.s ***/
// Description
// printenv - print the environment to stdout
// Synopsis
// printenv
// Build
// $ as --32 -o printenv.o printenv.s
// $ ld -m elf_i386 -o printenv printenv.o
View echo.s
/*** echo.s ***/
// Description
// echo - print arguments to stdout
// Synopsis
// echo [STRING]...
// Build
// $ as --32 -o echo.o echo.s
// $ ld -m elf_i386 -o echo echo.o
View echo_partial.s
/*** echo.s ***/
// Description
// echo - print arguments to stdout
// Synopsis
// echo [STRING]...
// Build
// $ as --32 -o echo.o echo.s
// $ ld -m elf_i386 -o echo echo.o
@dstein64
dstein64 / helpers.s
Last active Oct 29, 2017
Helper macro and function for printenv.s and echo.s
View helpers.s
.section .text
# ************************************
# * print macro
# * Caller is responsible for setting
# * %ecx and %edx, and saving %eax and
# * %ebx if necessary.
# ************************************
.macro print
movl $4, %eax
You can’t perform that action at this time.