Skip to content

Instantly share code, notes, and snippets.

View blakejakopovic's full-sized avatar

Blake Jakopovic blakejakopovic

View GitHub Profile
@blakejakopovic
blakejakopovic / nostr_zap_validator.rs
Last active March 2, 2023 15:58
Quick and dirty Rust Nostr ZAP Validation
// https://github.com/nostr-protocol/nips/blob/master/57.md
//
// Quick and dirty Rust Nostr ZAP Validation
//
// anyhow = "1.0.68"
// bech32 = "0.9"
// lightning-invoice = "0.21.0"
// nostr-rs-relay = "0.7.2"
// serde_json = "~1"
@blakejakopovic
blakejakopovic / script.lua
Created December 27, 2022 15:44 — forked from chanks/script.lua
Lua script to delete/trim all processed messages from a Redis stream - an updated version is maintained here: https://gist.github.com/FSX/fb86595c64751201497e2050aeb722e2
-- The goal of this script is to trim messages that have been processed by
-- all extant groups from the a given Redis stream. It returns the number
-- of messages that were deleted from the stream, if any. I make no
-- guarantees about its performance, particularly if the stream is large
-- and not fully processed (so a simple XTRIM isn't possible).
-- First off, bail out early if the stream doesn't exist.
if redis.call("EXISTS", KEYS[1]) == 0 then
return false
end
@blakejakopovic
blakejakopovic / pow.rb
Created November 29, 2022 17:05
Calculate leading zero bits for string
#!/usr/bin/env ruby
def hex_to_bytes(s)
s.scan(/.{1,2}/).map{|b| b.to_i(16)}
end
def zero_bits(b)
n = 0
if b == 0

How to download your 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 chrome using Chrome (Cookie.txt)[1] export extension. Save it to file udemy-cookies.txt
  3. Get the link of the video that you want to download. usually in format. Use the command provided below where you have to replace the {course_link} and {path_to_cookies_file} with respective paths.
$ youtube-dl {course_link} --cookies {path_to_cookies_file}
@blakejakopovic
blakejakopovic / SparkGraph.playground
Created July 2, 2014 08:57
Simple spark graph NSView example written in Swift. Open with Xcode for live preview and coding.
import Cocoa
import XCPlayground
@IBDesignable
class SparkGraph: NSView {
// Background Colour
@IBInspectable var backgroundColor:NSColor?
// Border

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
#!/usr/bin/ruby -rubygems
#
# Point appcrush at an .ipa file from the iTunes AppStore and it
# - expands the zip file
# - finds all the images
# - runs pngcrush with the revert-iphone-optimizations option on each image
#
# Requirements Xcode with iOS SDK 3.2 or higher
#
# Usage: appcrush '/Users/boctor/Music/iTunes/Mobile Applications/iBooks.ipa'
@blakejakopovic
blakejakopovic / Lircmap.xml
Created April 14, 2013 09:03
Lircmap.xml for DVICO_MCE2 and XBMC
<lircmap>
<remote device="DVICO_MCE2">
<pause>playpause</pause>
<stop>stop</stop>
<forward>ff</forward>
<reverse>rew</reverse>
<left>left</left>
<right>right</right>
<up>up</up>
<down>down</down>
source 'https://rubygems.org'
# The latest version of Ruby
ruby '1.9.3'
# The lastest version of Rails
gem 'rails', '3.2.10'
# Postgres
gem 'pg'
@blakejakopovic
blakejakopovic / tmux_iterm2.rb
Created April 15, 2012 15:09 — forked from jhuckabee/tmux_iterm2.rb
Brew script for 'Tmux for iTerm2'
require 'formula'
class TmuxIterm2 < Formula
url 'http://iterm2.googlecode.com/files/tmux-for-iTerm2-20120203.tar.gz'
md5 '59305a26bdd0245054fe719e6b2a960e'
homepage 'http://code.google.com/p/iterm2/downloads/detail?name=tmux-for-iTerm2-20120203.tar.gz&can=2&q='
depends_on 'libevent'
def install