Skip to content

Instantly share code, notes, and snippets.

View funky-monkey's full-sized avatar

Sidney de Koning funky-monkey

View GitHub Profile
@funky-monkey
funky-monkey / meetup-raffle.js
Last active January 29, 2018 17:01
Run this JS from the console of the meetup event page to randomly select an attendee (assuming all are present). The results also include the organizer and speakers if they are in the list
var list = document.getElementsByClassName('attendees-list')[0];
list.setAttribute('id', 'random-id-list');
var test = document.getElementById('random-id-list');
var linkList = test.getElementsByTagName('a');
linkList[Math.floor(Math.random()*linkList.length -1)].innerText;

Download Udemy course videos using youtube-dl

$ youtube-dl --list-extractors | grep udemy

Steps

  1. Get link to the course to download. e.g. https://www.udemy.com/course-name/
  2. Login into udemy website, save the cookie from Firefox (cookies.txt)[1] export extension. Save it to file cookies.txt

$ youtube-dl https://www.udemy.com/course-name/ --cookies ./cookies.txt > $ youtube-dl -u username -p password -o './videos/%(playlist)s/%(chapter_number)s - %(chapter)s/%(title)s.%(ext)s' https://www.udemy.com/course-name --cookies ./cookies.txt --verbose

@funky-monkey
funky-monkey / States-v3.md
Created October 24, 2017 14:17 — forked from andymatuschak/States-v3.md
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@funky-monkey
funky-monkey / postgres-brew.md
Created October 13, 2017 11:33 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@funky-monkey
funky-monkey / letsencrypt_2017.md
Created September 16, 2017 20:21 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@funky-monkey
funky-monkey / introrx.md
Created April 5, 2017 10:49 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@funky-monkey
funky-monkey / MiniSecurityChecklist.md
Created March 30, 2017 08:52
iOS Mini Security Checklist

Mini Security Checklist

Auth Systems
  • Use HTTPS everywhere.
  • Store password hashes using Bcrypt (no salt necessary - Bcrypt does it for you).
  • Destroy the session identifier after logout.
  • Destroy all active sessions on reset password (or offer to).
  • When parsing Signup/Login input, sanitize for custom://, data://, CRLF characters.
  • In Mobile OTP based mobile verification, do not send the OTP back in the response when generate OTP or Resend OTP API is called.
  • Limit attempts to Login, Verify OTP, Resend OTP and generate OTP APIs for a particular user. Have an exponential backoff set or/and something like a captcha based challenge.
@funky-monkey
funky-monkey / DataRange.md
Last active March 30, 2017 08:43
Date Range research notes

Turns out - since Date is of type Comparable, you can use a (Closed)Range with generics to create a DateRange. I also tried with using a Set<Date>, because you can create a Set from a Range but not a ClosedRange 😞 Using a Set I ran into problems fairly quick - also tried with a NSOrderedSet but you can't init it with a Range.

Range and ClosedRange can’t be iterated over (they are not collections anymore), since a value that is merely Comparable cannot be incremented. CountableRange and CountableClosedRange require Strideable from their bound and they conform to Collection so that you can iterate over them.

TODO:

  • Make this Strideable
  • Make this a Collection
@funky-monkey
funky-monkey / mp3concat.rb
Created January 5, 2017 15:29 — forked from janpaul/mp3concat.rb
generate an ffmpeg command that converts a directory full of MP3's to one large MP3
# copy-and-paste the output of this script into a shell, and rejoice.
files=Dir.glob('*.mp3').sort.join('|')
puts "ffmpeg -i \"concat:#{files}\" -acodec copy output.mp3"
@funky-monkey
funky-monkey / nginx.conf
Created December 21, 2016 08:37 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048