Skip to content

Instantly share code, notes, and snippets.

@ttesmer
ttesmer / AD.hs
Last active June 7, 2024 03:56
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
@moyix
moyix / killbutmakeitlooklikeanaccident.sh
Created February 5, 2022 22:51
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@corupta
corupta / aws-pricing.js
Created October 19, 2020 08:57
AWS EC2 Pricing Sort By Price
// go to https://aws.amazon.com/ec2/pricing/on-demand/ and run this in console
(() => {
let table = document.querySelector('div.js-active').children[0];
let bodies = table.getElementsByTagName('tbody');
bodies = Array.from(bodies);
bodies = bodies.map((b) => Array.from(b.children));
let rows = bodies.reduce((acc, x) => [...acc, ...Array.from(x.slice(1)).map((r) => [x[0].children[0].innerText, ...Array.from(r.children).map((c) => c.innerText)])], []);
let data = rows.map(([type, name, vcpu, ecu, memory, storage, price]) => ({ name, vcpu, ecu, memory, storage, price, type }));
data.sort(({ price: priceA }, { price: priceB }) => parseFloat(priceB.substr(1)) - parseFloat(priceA.substr(1)));
data.forEach(({name, vcpu, ecu, memory, storage, price, type }) => console.log(`price: ${price} name: ${name} - vcpus: ${vcpu} - ecu: ${ecu} - memory: ${memory} - storage: ${storage} - type: ${type}`));
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 20, 2024 05:29
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@bobbygrace
bobbygrace / trello-css-guide.md
Last active May 15, 2024 16:01
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

@jiaaro
jiaaro / installing_pyaudio.md
Last active May 2, 2024 10:15
How to install PyAudio into a VirtualEnv on Mac OS X 10.10

Install portaudio using homebrew (or method of your choice)

brew install portaudio

create $HOME/.pydistutils.cfg using the include and lib directories of your portaudio install:

[build_ext]
@jdelibas
jdelibas / index.html
Last active September 5, 2021 17:32
TouchSpin directive for Angular.js
<html>
<body>
//Note the value attribute rather than ng-model
<spin value="someScopeValue" min="1" max="{{someOtherScopeValue}}" step="2" />
$scope.someScopeValue = 2;
$scope.someOtherScopeValue = 20;
</body>
@emrecelikten
emrecelikten / Application.scala
Last active February 9, 2017 12:47
Sample upload testing in Play Framework 2.3.1
package controllers
import play.api.mvc._
object Application extends Controller {
def upload = Action(parse.multipartFormData) {
request =>
if (request.body.files.isEmpty) BadRequest("Invalid file!")
else if (request.body.asFormUrlEncoded.isEmpty) BadRequest("Invalid data!")
else Ok("Everything is okay!")
@staltz
staltz / introrx.md
Last active July 19, 2024 22:21
The introduction to Reactive Programming you've been missing