Skip to content

Instantly share code, notes, and snippets.

View dluman's full-sized avatar

Douglas Luman dluman

View GitHub Profile
@cbare
cbare / dynamic_object.py
Created January 31, 2013 01:07
How to get a dynamic object in Python. A dynamic object is just a bag of properties, some of which might happen to be functions, just like objects in javascript. Forget OOP. This is QDP - quick-n-dirty programming!
class Dynamic(dict):
"""Dynamic objects are just bags of properties, some of which may happen to be functions"""
def __init__(self, **kwargs):
self.__dict__ = self
self.update(kwargs)
def __setattr__(self, name, value):
import types
if isinstance(value, types.FunctionType):
self[name] = types.MethodType(value, self)
@proudlygeek
proudlygeek / nfs-tunnel.md
Last active June 28, 2025 13:28
Mount NFS Folder via SSH Tunnel

1. Install NFS on Server

Install the required packages (Ubuntu 12.04):

apt-get install nfs-kernel-server portmap

2. Share NFS Folder

Open the exports file:

vim /etc/exports
@karpathy
karpathy / gist:587454dc0146a6ae21fc
Last active May 14, 2025 00:08
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@karpathy
karpathy / min-char-rnn.py
Last active November 25, 2025 07:51
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@aparrish
aparrish / index.md
Last active December 2, 2021 13:26
Writing Poetry with Procedure: A Workshop

Writing Poetry with Procedure: A Workshop

Led by Allison Parrish

Description

Practitioners in the field of procedural writing have been using rules, procedures and computer programs to create innovative literary work since the invention of the digital computer. Far from the bland imitation evoked by the phrase "computer-generated poetry," these techniques facilitate the creation of work with aesthetic and emotional affordances sometimes difficult to achieve through conventional compositional techniques: serendipitous beauty, precisely imitative satire, vertiginous wonder at the infinite. In this workshop, participants will learn about the history of computer-generated writing and sample a range of off-the-shelf, freely-available tools on the web to create their own—without writing any actual lines of code. No previous programming experience is required.

Outline

from PyPDF2.generic import (
DictionaryObject,
NumberObject,
FloatObject,
NameObject,
TextStringObject,
ArrayObject
)
# x1, y1 starts in bottom left corner
@heyfluke
heyfluke / remap_docker_user_to_host_user.md
Last active July 9, 2025 00:10
remap docker user to host user.

Problem

When I use docker to work with the shared workspace with host under Ubuntu, I find that files created by docker user is owned by root. This is not the same with macOS.

Maybe this is becuase docker is run by root user and the default user mapping mechanism is to map container-root to host-user or host-root. So can I map the container-root or container-any-user to host-current-user?

Fortunately the latest docker supports the re-map the container user to any host user via Linux namespace. Refer to this.

Linux namespace

@aparrish
aparrish / enough-python.ipynb
Last active October 11, 2024 15:27
Just enough Python!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@s-aguado
s-aguado / arm-cheatsheet.pdf
Last active April 17, 2025 19:58
ARMv6-M Instruction Set Cheatsheet
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bitbug42
bitbug42 / OpReturn.cs
Last active June 20, 2020 12:57
Scan Bitcoin blocks, looking for OP_RETURN outputs containing text. Requires a synced fullnode and the NBitcoin library
using NBitcoin;
using NBitcoin.RPC;
using System;
using System.IO;
using System.Linq;
using System.Text;
class OpReturnScan
{