Skip to content

Instantly share code, notes, and snippets.

@tsubery
tsubery / phoenix_session_test.md
Last active May 17, 2022 21:50
How to set session in phoenix controller tests

If you are reading this, you probably tried to write code like this

test "testing session" do
  build_conn()
  |> put_session(:user_id, 234)
  |> get("/")
  ...
  end

And got this exception:

@gbaman
gbaman / HowToOTGFast.md
Last active May 1, 2024 08:26
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@remojansen
remojansen / class_decorator.ts
Last active September 14, 2023 14:54
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
#RUN the following to kick off script-> START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/ytechie/9467867/raw/35bbd968b79f52b3e540c3203e8c8f611028eee9/boxstarter
#So Meta!
choco install chocolatey
choco install boxstarter
choco feature disable --name=checksumFiles
choco feature enable --name=allowGlobalConfirmation
#run the rest in the boxstarter shell
@LukasKnuth
LukasKnuth / README
Created February 15, 2012 22:18
This Python script can be used as a "pre-commit"-hook, to check if a huge binary file got accidentally added to the staging area (and is about to be committed). Because deleting those afterwards is a huge pain in the ass...
-- DESCRIPTION --
If you accidentally commit a huge file, you have a problem. Sure, you can remove it from the working tree and commit,
but the file is still reachable from your history and therefore causes every clone to be as huge as the commented
binary file.
Fixing this can be very ugly, time consuming and might not even work as you wish. Luckily, this script can protect
you from committing such monsters in the first place.
It looks through the staged files (the ones that are added with the "git add"-command) and checks for their file-size.
If they are larger then the given size, the commit is aborted and you get a message telling you what file takes so