Skip to content

Instantly share code, notes, and snippets.

@ewalk153
ewalk153 / ruby_yjit_test.sh
Created January 18, 2023 03:09
Verify if YJIT is running for ruby
> RUBY_YJIT_ENABLE=1 ruby -e "puts RubyVM::YJIT.enabled?"
true
> ruby -e "puts RubyVM::YJIT.enabled?"
false
@ewalk153
ewalk153 / static_path_test.py
Last active January 10, 2023 14:19
Extracted static path method to test behavior from piku static path mapper.
import unittest
from re import sub, match
from os.path import join, relpath
def echo(message):
# print(message)
pass
PIKU_INTERNAL_NGINX_STATIC_MAPPING = """
location $static_url {
# Google docs query command-line sample.
require 'google/apis/drive_v2'
require 'google/api_client/client_secrets'
require 'google/api_client/auth/installed_app'
require 'google/api_client/auth/storage'
require 'google/api_client/auth/storages/file_store'
require 'logger'
require 'json'
@ewalk153
ewalk153 / foo_test.rb
Last active December 5, 2022 21:32
Demonstrate mocha and minitest behavior with stubs
# ❯ ruby foo_test.rb
# Run options: --seed 44288
# # Running:
# F.
# Finished in 0.000679s, 2945.5069 runs/s, 2945.5069 assertions/s.
# 1) Failure:
@ewalk153
ewalk153 / run_sqlite3_deserialize.c
Last active November 2, 2022 13:01
Example of how to run sqlite3_deserialize
#include <sqlite3.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_FILE_SIZE 1000000
// build with
// cc run_sqlite3_deserialize.c -lsqlite3 -o sqlite3_deserialize
// create db with:
// echo "create table pizza(name, color); insert into pizza(name, color) values ('margarita', 'red');" | sqlite3 pizza.db
@ewalk153
ewalk153 / sqlite_deserialize.py
Created October 17, 2022 17:40
Small script to demonstrate sqlite3 serialize/deserialize interface in python (>3.11rc1)
# requires python > 3.11rc1 for sqlite3.{serialize, deserialize}
import sqlite3
def serialize():
con = sqlite3.connect(":memory:")
cur = con.cursor()
cur.execute("CREATE TABLE movie(title, year, score)")
cur.execute("""
INSERT INTO movie VALUES
('Monty Python and the Holy Grail', 1975, 8.2),
sudo apt-get install -y build-essential certbot git \
libjpeg-dev libxml2-dev libxslt1-dev zlib1g-dev nginx \
python3-certbot-nginx python3-dev python3-pip python3-virtualenv \
python3-dev python3-pip python3-click python3-virtualenv \
uwsgi uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python3 \
uwsgi-plugin-python3 uwsgi-plugin-tornado-python3 \
uwsgi-plugin-lua5.1 uwsgi-plugin-lua5.2 uwsgi-plugin-luajit
@ewalk153
ewalk153 / development.rb
Created August 3, 2022 23:59
Proxying a rails app through the cloudflared tunnel
Rails.application.configure do
config.hosts << /[a-z\-]+\.trycloudflare\.com/
end
@ewalk153
ewalk153 / webauthn
Created August 2, 2022 01:57
A few notes on the web authn flow (incomplete)
sequenceDiagram
Browser->>+Server: Generate and store the WebAuthn User ID
Server->>+Server: generate challenge, and store in session
Server-->>+Browser: options
Browser->>+User: create (local call to device)
User-->+Browser: PublicKeyCredential
@ewalk153
ewalk153 / commands.bash
Last active July 29, 2022 00:46
Mpy setup for Micropython
# https://docs.micropython.org/en/v1.18/develop/natmod.html
# python env setup
pyenv local 3.10.2 #version doesn't matter so much
python -m venv venv # setup venv
source venv/bin/activate
# install python build tools
pip install 'pyelftools>=0.25'
# setup micropython env