Skip to content

Instantly share code, notes, and snippets.

@ttesmer
ttesmer / AD.hs
Last active July 22, 2024 05:21
Automatic Differentiation in 38 lines of Haskell using Operator Overloading and Dual Numbers. Inspired by conal.net/papers/beautiful-differentiation
{-# LANGUAGE TypeSynonymInstances #-}
data Dual d = D Float d deriving Show
type Float' = Float
diff :: (Dual Float' -> Dual Float') -> Float -> Float'
diff f x = y'
where D y y' = f (D x 1)
class VectorSpace v where
zero :: v
@sk8terboi87
sk8terboi87 / index.html
Last active May 11, 2022 06:37
JavaScript Web Worker Example: Fetching Random Content from Wikipedia using Web Workers. http://codelikeapoem.com/2017/03/web-workers-beginners-guide.html
<!DOCTYPE html>
<html>
<head>
<title>Polling Example</title>
<style type="text/css">
.title, .result {
display: inline-block;
padding: 10px;
background-color: #fffeee;
}
@inversion
inversion / fdupes_delete_by_directory.py
Last active April 23, 2022 21:38
Delete fdupes duplicates by directory
#!/usr/bin/env python
import fileinput
import os.path as path
import re
class Processor(object):
def __init__(self):
self.condemnedFiles = []
@tgarc
tgarc / save_user_variables.md
Last active December 20, 2021 08:25
automatically save ipython sessions

I often like to start my ipython session from where I last left off - similar to saving a firefox browsing session. IPython already automatically saves your input history so that you can look up commands in your history, but it doesn't save your variables. Here are the steps to save the state of your variables on exit and have them loaded on startup:

  1. Add the save_user_variables.py script below to your ipython folder (by default $HOME/.ipython). This script takes care of saving user variables on exit.

  2. Add this line to your profile's ipython startup script (e.g., $HOME/.ipython/profile_default/startup/startup.py):
    get_ipython().ex("import save_user_variables;del save_user_variables")

  3. In your ipython profile config file (by default $HOME/.ipython/profile_default/ipython_config.py) find the following line:
    # c.StoreMagics.autorestore = False
    Uncomment it and set it to true. This automatically reloads stored variables on startup. Alternatively you can use reload the last session manually us

@kdabir
kdabir / README.md
Created August 27, 2012 14:07
Calculate space wasted because of duplicate files

Calculate the space wasted by duplicate files on your Hard Drive

Sometimes (rather always), duplicate files eat up space on hardrive. If you want to compute the total space wasted by such duplicate files this utility script may come handy. fdupes is a nice utility that finds the duplicate files in the given directories. This script consumes the fdupes output and calculates the space wasted.

These steps assume *nix flavor OS (OS X/Linux) but this might work on Windows+Cygwin as well

  1. Install fdupes on your machine (verify by doing fdupes --version on Terminal)