Skip to content

Instantly share code, notes, and snippets.

View blakejakopovic's full-sized avatar

Blake Jakopovic blakejakopovic

View GitHub Profile
@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 / 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 / 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
@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 / message-parse.cljs
Created September 11, 2014 05:58
Clojurescript node.js firmata message parser (incomplete)
(defn parse-message
"Parses incoming data and emits valid messages"
[]
(let [data (js/Buffer 0)]
(fn [emitter buffer]
;; Append new data to buffer
(set! data (.concat js/Buffer [data buffer]))
;; Remove incomplete messages (ie. not control charactors)
@blakejakopovic
blakejakopovic / SparkFloatToByteTest.ino
Created August 27, 2014 07:59
Spark Core Float to Byte Test
float a = 6.7;
float b = 14.6;
float c = 26.3;
byte* method1(float num)
{
byte buff[sizeof(float)];
memcpy(buff, &num, sizeof(float));
return buff;
@blakejakopovic
blakejakopovic / adapter-example.cljs
Created August 14, 2014 08:31
Clojurescript clj-firmata WIP adapter
(ns testdrive.example
(:require [firmata.core :refer [open-board event-channel]]
[firmata.stream :refer [FirmataStream]]
[cljs.nodejs :as nodejs])
(def net (nodejs/require "net"))
(defrecord SocketStream [host port]
FirmataStream
@blakejakopovic
blakejakopovic / firmata-spark-example.ino
Created August 12, 2014 00:41
Spark Core Firmata Example
#include "firmata-spark/firmata-spark.h"
TCPServer server = TCPServer(5678);
TCPClient client;
bool new_client = true;
void setup()
{
// start listening for clients