Skip to content

Instantly share code, notes, and snippets.

View kaixiang-li's full-sized avatar
🌴
On vacation

kaixiang kaixiang-li

🌴
On vacation
View GitHub Profile
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@primaryobjects
primaryobjects / m3u8.md
Last active November 16, 2024 19:44
How to download m3u8 and ts video movie streams.

m3u8 Downloading

  1. Open Chrome Developer tools and click the Network tab.
  2. Navigate to the page with the video and get it to start playing.
  3. Filter the list of files to "m3u8".
  4. Find master.m3u8 or index.m3u8 and click on it.
  5. Save the file to disk and look inside it.
  6. If the file contains a single m3u8 master url, copy that one instead.
  7. Run the program m3u8x.
  8. Paste the same m3u8 url in both textboxes (URL and Quality URL) and click "Headers" and set the referral url and user-agent from the request as found in Chrome.
@joepie91
joepie91 / random.md
Last active November 16, 2024 19:07
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@byronhe
byronhe / modern_crypto.md
Last active March 28, 2022 07:51
现代密码学实践指南[2015年]

现代密码学实践指南[2015年]

标签(空格分隔): 密码学


本文介绍目前现代密码学的最先进技术, 前半部分主要翻译自 《Cryptographic Right Answers》,附上收集的资料,和byron个人的理解。

# Copyright (c) 2014 Lukas Fittl <[email protected]>
#
# Released in the public domain - fork as you wish.
require 'rubygems'
require 'mixlib/cli'
require 'pg'
require 'pg_query'
require 'curses'
@Kartones
Kartones / postgres-cheatsheet.md
Last active November 15, 2024 21:14
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@nsmaciej
nsmaciej / sweet.js
Created February 27, 2014 23:53
Messing around with sweet.js (sweetjs.org)
macro $ttos {
case {_ $x} => {
var pattern = #{$x};
var tokenString = pattern[0].token.value.toString();
var stringValue = makeValue(tokenString, #{$here});
return withSyntax($val = [stringValue]) {
return #{$val};
}
}
}
require "thread"
class BoundedQueue
def initialize(max_size = :infinite)
@lock = Mutex.new
@items = []
@item_available = ConditionVariable.new
@max_size = max_size
@space_available = ConditionVariable.new
end
@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active July 4, 2024 13:00
Backend Architectures Keywords and References
@davidaurelio
davidaurelio / partial.js
Created April 30, 2013 10:15
Simple higher-order partial function that takes advantage of sparse arrays to make parameters skippable.
function partial(fn, fixedArgs) {
return function() {
var args = fixedArgs.slice(), skipped = 0;
for (var i = 0, n = arguments.length; i < n; i++) {
while (i + skipped in args) { skipped++; }
args[i + skipped] = arguments[i];
}
return fn.apply(this, args);
};
}