Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"os"
"golang.org/x/sys/unix"
"strings"
)
type cache struct {
MAGIC_NUMBER = bytes.fromhex('a1b2c3d4')
REVERSED_MAGIC_NUMBER = bytes.fromhex('d4c3b2a1')
def parse_packet_length(raw):
return int.from_bytes(raw[8:12], 'little') + 16 # add header size
class Packet:
def __init__(self, raw):
length = int.from_bytes(raw[8:12], 'little') + 16 # add header size
untruncated_length = int.from_bytes(raw[12:16], 'little') + 16 # add header size
@arlandism
arlandism / set_config.sql
Created August 17, 2021 15:25
Example of set_config expiring after current transaction is over
arlandis=# begin transaction;
BEGIN
arlandis=*# select set_config('my.random.key', 'blahblah', true);
set_config
------------
blahblah
(1 row)
arlandis=*# select current_setting('my.random.key');
current_setting
// Unoptimized
// `0.81s to run 10000 tests (80750.60ns per test)`
// Method call 1x refactor
// `0.71s to run 10000 tests (70700.00ns per test)`
// Removing use of `get_vec_element` and fetching data upfront
// `0.22s to run 10000 tests (21686.00ns per test)`
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/stat.h>
#include <string.h>
#define GRN "\e[0;32m"
#define BLU "\e[0;34m"
#define reset "\e[0m"

Keybase proof

I hereby claim:

  • I am arlandism on github.
  • I am bookmagnet (https://keybase.io/bookmagnet) on keybase.
  • I have a public key ASDlqD3pt4Xn6iqmzzMN42S3QZYN3jhR73NslnwMdvoLxwo

To claim this, I am signing this object:

def a
@a
end
@a = "a"
a = a + "b"
#=> NoMethodError: undefined method `+' for nil:NilClass
# from (irb):6
# from /Users/arlandis/.rvm/rubies/ruby-2.3.5/bin/irb:11:in `<main>'
# Usage
# 1) Switch to the branch you want to look at locally
# 2) Make sure you have the version of wip that you want to compare against. You may need to fetch first.
# 3) Run the script
GREEN = 32
YELLOW = 33
BLUE = 34
class Match
attr_reader :owner, :changed_line, :best_match
def sum_with(list, &block)
  result = block.call(list)
  result.reduce(0) {|acc, n| acc += n}
end
def sum_doubles(list)
sum_with(list) {|n| n * 2}
end
def sum_triples(list)

Below, "run pry" means executing :! ruby assembler/main.rb from Vim.

My directory structure is:

╰─$ ls assembler
code.rb         main.rb         parser.rb       symbol_table.rb
# DOES NOT RUN PRY