Skip to content

Instantly share code, notes, and snippets.

@ewalk153
ewalk153 / remix_upload.tsx
Created April 18, 2024 02:36
Remix demo of a CSV file upload
import type { ActionFunctionArgs, UploadHandler } from "@remix-run/node";
import {
json,
unstable_createMemoryUploadHandler as createMemoryUploadHandler,
unstable_parseMultipartFormData as parseMultipartFormData,
} from "@remix-run/node";
import { useFetcher } from "@remix-run/react";
type ActionData = {
errorMsg?: string;
@ewalk153
ewalk153 / Dockerfile
Last active February 13, 2024 14:01
piku docker image
FROM debian:bullseye
ENV DEBIAN_FRONTEND=noninteractive
# Install the minimum amount of packages required for testing, which currently means:
# - minimal set of packages required to run Python 3
# - shipping versions of uWSGI and nginx (so that config files are put in the right places)
# Also, make sure we have a sane default locale inside the container
RUN apt-get update \
@ewalk153
ewalk153 / gist:2c6f89fa988c3916cad28b3d4564e723
Created December 20, 2023 02:54
Puma install on latest mac Sonoma 14.2
bundle config build.puma --with-pkg-config=$(brew --prefix openssl@1.1)/lib/pkgconfig
bundle install --redownload
@ewalk153
ewalk153 / nginx-rails.conf
Created January 30, 2023 02:47
Nginx conf for reverse proxying a rails app
upstream app {
# Path to Puma SOCK file, as defined previously
# server unix:/home/deploy/appname/shared/sockets/puma.sock fail_timeout=0;
server unix:/Users/ericwalker/src/github.com/ewalk153/sample-rails-app/shared/sockets/puma.sock fail_timeout=0;
}
server {
listen 4000;
server_name localhost;
@ewalk153
ewalk153 / _nginx_protect_static_assets.conf
Last active February 2, 2023 02:56
Protect static assets with a rails app
upstream backend {
server localhost:3000;
}
server {
listen 9000;
server_name localhost;
root /path_of_rails_app/public;
try_files $uri/index.html $uri @app;
@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