Skip to content

Instantly share code, notes, and snippets.

View jpillora's full-sized avatar
👶

Jaime Pillora jpillora

👶
View GitHub Profile
@jpillora
jpillora / unix-to-tcp.go
Last active April 10, 2024 00:55
Forward unix socket to tcp socket
package main
import (
"io"
"log"
"net"
"os"
)
const (
@jpillora
jpillora / test.js
Last active April 6, 2024 01:27
async javascript test
const MAX_INFLIGHT = 4;
const TOTAL = 100;
// the given dummy api supports a maximum of 4 of inflight requests.
// the given code is correct, but it is slow because it processes elements serially.
// your task is to process 100 elements as fast as possible.
// run this code with "node/bun test.js".
// it should print "pass".
// no external dependencies are allowed.
async function run(elements) {
// ============
@jpillora
jpillora / icloud-dl.sh
Created February 7, 2021 06:47
Download iCloud link from Terminal
#!/bin/bash
# given "https://www.icloud.com/iclouddrive/<ID>#<Filename>
ID="...."
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \
--data-raw '{"shortGUIDs":[{"value":"$ID"}]}' --compressed \
jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')
curl "$URL" -o myfile.ext
@jpillora
jpillora / smtp-gmail-send.go
Last active March 5, 2024 21:26
Send email using Go (Golang) via GMail with net/smtp
package main
import (
"log"
"net/smtp"
)
func main() {
send("hello there")
}
@jpillora
jpillora / install.sh
Last active January 24, 2024 13:56
Install Microsoft's VS code-server
#!/bin/bash
set -euf -o pipefail
if [ ! -f code-server ]; then
ARCH=$(uname -m)
OS="unknown-linux-gnu"
echo "downloading code-server ($ARCH-$OS)"
URL="https://vscodeserverlauncher.blob.core.windows.net/builds/latestbin/$ARCH-$OS/$ARCH-$OS"
curl -L "$URL" >code-server
chmod +x code-server
@jpillora
jpillora / rdiff-example.sh
Created July 6, 2017 06:41
rdiff file example
# $ apt install rdiff
# $ rdiff --help
# Usage: rdiff [OPTIONS] signature [BASIS [SIGNATURE]]
# [OPTIONS] delta SIGNATURE [NEWFILE [DELTA]]
# [OPTIONS] patch BASIS [DELTA [NEWFILE]]
# Options:
# -v, --verbose Trace internal processing
# -V, --version Show program version
# -?, --help Show this help message
@jpillora
jpillora / join-api-async.coffee
Last active December 22, 2023 22:57
Join API
"use strict"
api1 =
a: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+1), 500
b: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+2), 500
api2 =
b: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+3), 500
c: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+4), 500
@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@jpillora
jpillora / INSTALL.md
Last active October 25, 2023 05:03
Headless Transmission on Mac OS X
  1. Go to https://developer.apple.com/downloads/index.action and search for "Command line tools" and choose the one for your Mac OSX

  2. Go to http://brew.sh/ and enter the one-liner into the Terminal, you now have brew installed (a better Mac ports)

  3. Install transmission-daemon with

    brew install transmission
    
  4. Copy the startup config for launchctl with

    ln -sfv /usr/local/opt/transmission/*.plist ~/Library/LaunchAgents
    
@jpillora
jpillora / s3get.sh
Last active August 23, 2023 12:07
S3 signed GET in plain bash (Requires openssl and curl)
#!/bin/bash
#set these in your environment/profile (NOT HERE)
AWS_ACCESS_KEY=""
AWS_SECRET_KEY=""
function s3get {
#helper functions
function fail { echo "$1" > /dev/stderr; exit 1; }
#dependency check