Skip to content

Instantly share code, notes, and snippets.

@jhass
jhass / fix_constraints.sql
Last active December 4, 2020 13:03
Fix missing on delete cascade on foreign key constraints after migrating Diaspora to PostgreSQL
ALTER TABLE aspect_memberships
DROP CONSTRAINT aspect_memberships_aspect_id_fkey,
ADD CONSTRAINT aspect_memberships_aspect_id_fkey FOREIGN KEY (aspect_id) REFERENCES aspects(id) ON DELETE CASCADE;
ALTER TABLE aspect_memberships
DROP CONSTRAINT aspect_memberships_contact_id_fkey,
ADD CONSTRAINT aspect_memberships_contact_id_fkey FOREIGN KEY (contact_id) REFERENCES contacts(id) ON DELETE CASCADE;
ALTER TABLE aspect_visibilities
DROP CONSTRAINT aspect_visibilities_aspect_id_fkey,
ADD CONSTRAINT aspect_visibilities_aspect_id_fkey FOREIGN KEY (aspect_id) REFERENCES aspects(id) ON DELETE CASCADE;
ALTER TABLE comment_signatures
@jhass
jhass / gh-pr-status.rb
Last active June 20, 2020 11:22
Little script to list your pull requests and whether you need to take action on them
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "octokit"
gem "terminal-table"
@jhass
jhass / README.md
Last active May 14, 2020 13:16
Crystal shim to redirect malloc & pthread to bdwgc (depends on glibc and https://github.com/jhass/crystal/tree/function_pointer_fixes)
@jhass
jhass / .ssh_authorized_keys
Last active May 17, 2019 08:46
Git shell only for specific SSH key
command="/home/USER/.ssh/git-shell",no-port-forwarding,no-X11-forwarding,no-pty ssh-rsa YOUR_KEY foo
@jhass
jhass / hockeyapp_updater.rb
Last active June 9, 2017 08:20
Update all connected devices and running emulators with the latest version of your app(s) from HockeyApp (install Ruby & bundler first)
#!/usr/bin/ruby
require "bundler/inline"
gemfile(ARGV.any? {|arg| arg == "--install"}) do
source "https://rubygems.org"
gem "http", "~> 2.2"
gem "ADB", "~> 0.5.6"
gem "slop", "~> 4.5"
end
@jhass
jhass / injecting_io.cr
Last active March 30, 2017 07:29
Crystal injecting/replacing IO PoC
struct Slice(T)
def []?(start, count)
if start + count >= size
count = -1
end
if count < 0
count = size - start + (count + 1)
end
@jhass
jhass / barcode.html
Last active December 15, 2021 07:55
Simple Barcode generator
<!DOCTYPE html>
<html>
<head>
<title>Barcode generator</title>
<script src="https://cdn.jsdelivr.net/jsbarcode/3.5.8/JsBarcode.all.min.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script type="text/javascript">
window.eanHistory = [];
function loadHistory() {
@jhass
jhass / README.md
Last active December 6, 2023 06:46 — forked from yorkxin/README.md
Proxy to remote server with CORS support

cors.py for mitmproxy

Hacking CORS restriction to enable in-browser XHR to any server.

Usage

Say you are running an web app at localhost, and you want to send XHR to http://remote-server:80, but the CORS restriction forbids access because you are sending requests from an origin that remote-server:80 does not allow.

Run:

@jhass
jhass / server.cr
Created July 22, 2016 12:05
Simple debug HTTP server in Crystal
require "option_parser"
require "http/server"
require "json"
class Settings
property port = 3000
property host = "127.0.0.1"
property? show_headers = false
property? show_raw_json = false
end
@jhass
jhass / archlinux.sh
Created November 18, 2015 23:30
VMM (http://vmm.localdomain.org/) DKIM configuration (only relevant parts shown)
sudo pacman -S opendkim
sudo cp /etc/opendkim/opendkim.conf{.sample,}
sudo mkdir /var/lib/dkim
sudo chown opendkim:mail /etc/opendkim/opendkim.conf /var/lib/dkim
sudo chmod 700 /var/lib/dkim
sudo chgrp mail /var/spool/postfix/private
sudo -u opendkim opendkim-genkey -D /var/lib/dkim -b 2048 -s mail
sudo usermod -a -G mail postfix