Skip to content

Instantly share code, notes, and snippets.

View blakejakopovic's full-sized avatar

Blake Jakopovic blakejakopovic

View GitHub Profile
@blakejakopovic
blakejakopovic / firmata-test-server.ino
Created September 23, 2014 07:52
Spark Core Sketch for testing Firmata over TCP server
#include "firmata-spark/firmata-spark.h"
TCPServer server = TCPServer(5678);
TCPClient client;
bool new_client = true;
void setup()
{
// start listening for clients
@blakejakopovic
blakejakopovic / translation_process.md
Created December 3, 2014 00:28
Bitcoin Revised doc/translation_process.md

Translations

Summary

  • The Bitcoin Core GUI can be easily translated into other languages
  • We use Transifex to manage all translations (Bitcoin Project)
  • The languages manifest file can be found at src/qt/bitcoin.qrc
  • Translation source files are located in src/qt/locale/
  • .ts files are generated translation source files
  • .qm files are compiled binary translation files

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 / 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
@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 / nostr_client_anti_patterns.md
Last active March 22, 2023 09:15
Nostr Client App Anti-Patterns

Nostr Client App Anti-Patterns

With Nostr being an open protocol, and client apps being able to be developed by anyone, it's important that the client apps design around best supporting relays by minimising their client app impact. Remember, if your app has 10,000+ users, and the app's relay interaction code makes relays slower - everyone suffers.

Below are some anti-patterns (things not to do), that can help with relay performance, and ultimately make your client apps faster!

Please help build upon this list - we can move to a repo.. just add comments for now.

  • Updating a subscription too often (triggers new SQL queries)
  • Connecting to a relay multiple times (use a single websocket)
@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 / NIP-XX.md
Last active March 9, 2023 11:02
NIP-XX - Nostr Proof of Work Service Provider

NIP-XX

Proof of Work Service Provider

draft optional author:wakoinc

This NIP defines a way for clients to request a target proof of work calculation for an event prior to publishing.

@blakejakopovic
blakejakopovic / app.rb
Last active March 17, 2023 15:33
Nostr NIP-42 Website Login Example
require 'sinatra'
require 'json'
# class App < Sinatra::Application
configure do
enable :sessions
end
get '/' do
@blakejakopovic
blakejakopovic / nip19.rs
Created March 21, 2023 17:53
Nostr NIP-19 Rust TLV decode
#[macro_use]
extern crate log;
use anyhow::Result;
use bech32::FromBase32;
use secp256k1::hashes::hex::ToHex;
use std::convert::TryFrom;
fn parse_tlv(data: &[u8]) -> Vec<(u8, &[u8])> {
let mut result = vec![];