Skip to content

Instantly share code, notes, and snippets.

@jammie
jammie / rails http status codes
Created March 4, 2022 14:29 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@jammie
jammie / snippets.js
Created January 30, 2022 07:49 — forked from beautyfree/snippets.js
Solana Web3 Snippets - getBalance and History
import {
Account,
clusterApiUrl,
Connection,
PublicKey,
sendAndConfirmTransaction,
SystemProgram,
Transaction,
} from '@solana/web3.js';
curl http://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getProgramAccounts",
"params": [
"cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ",
{
"encoding": "jsonParsed",
"filters": [ ]
}
@jammie
jammie / index.html
Created August 27, 2021 18:38 — forked from peerreynders/index.html
"use initializer" custom hook
<!doctype html>
<html lang="eng">
<head>
<meta charset="utf-8"/>
<title>useInitializer</title>
</head>
<body>
<script type="module">
import { html, render, useState } from '//unpkg.com/htm/preact/standalone.mjs';
@jammie
jammie / subdomain-localhost-rails-5.md
Created April 19, 2021 09:48 — forked from indiesquidge/subdomain-localhost-rails-5.md
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@jammie
jammie / distance_away_report.rb
Created December 3, 2020 07:33 — forked from matthutchinson/distance_away_report.rb
Ruby script for the find distance between two points using haversine formula
MAX_DISTANCE_AWAY_IN_KM = 100.0
RAD_PER_DEG = 0.017453293
Rmiles = 3956 # radius of the great circle in miles
Rkm = 6371 # radius in kilometers, some algorithms use 6367
Rfeet = Rmiles * 5282 # radius in feet
Rmeters = Rkm * 1000 # radius in meters
def haversine_distance( lat1, lon1, lat2, lon2 )
dlon = lon2 - lon1
@jammie
jammie / image-to-v4l2loopback.py
Created July 4, 2020 00:15 — forked from TimSC/image-to-v4l2loopback.py
Send image data to v4l2loopback using python. Remember to do "sudo modprobe v4l2loopback" first! Released under CC0 by Tim Sheerman-Chase, 2013
#Send image data to v4l2loopback using python
#Remember to do sudo modprobe v4l2loopback first!
#Released under CC0 by Tim Sheerman-Chase, 2013
import fcntl, sys, os
from v4l2 import *
import time
import scipy.misc as misc
import numpy as np
@jammie
jammie / homebrew-permissions-issue.md
Created September 20, 2019 10:32 — forked from irazasyed/homebrew-permissions-issue.md
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*

@jammie
jammie / concatenate_binary_files.rb
Created March 11, 2019 03:54 — forked from ferryzhou/concatenate_binary_files.rb
concatenate binary files with ruby
# given a directory or a set of files
# concatenate the binary files
# output a single binary file
# usage:
# ruby concatenate_binary_files "/xxx/xx/*.bin" "/xxx/xx.bin"
infiles = ARGV[0]
outpath = ARGV[1]
File.open(outpath, 'wb') do |outfile|
@jammie
jammie / 01_postfix_installer.md
Created November 12, 2018 04:50 — forked from baronkis/01_postfix_installer.md
Postfix + Dovecot + Postgresql + Postfixadmin + Roundcube + Opendkim

Postfix Installer

Following script may be used for configuring complete and secure email server on fresh install of Ubuntu 18.04 LTS. It will probably work on other distributions using apt-get. After minor changes you'll be able to use it on other Linux distros.

What it does?

02_postfix.sh:

  • Install Postfix and configure it with TLS support.
  • Install Dovecot and configure it's transport on Postfix.
  • Download, extract and correct permissions for Postfixadmin.
  • Download, extract and correct permissions for Roundcube.