Skip to content

Instantly share code, notes, and snippets.

@kluzny
kluzny / konami.rs
Created May 7, 2023 20:05
A bevy system for the konami code
use bevy::input::keyboard::KeyboardInput;
use bevy::prelude::{EventReader, KeyCode, ResMut, Resource};
use std::process::exit;
#[derive(Resource)]
pub struct KonamiCombo(pub usize);
pub fn keyboard_events(
mut key_evr: EventReader<KeyboardInput>,
mut konami_combo: ResMut<KonamiCombo>,
@kluzny
kluzny / matchers.rb
Last active October 12, 2023 14:47
Some custom rspec matchers for inspecting json responses
require 'rspec/expectations'
# expect(response).to be_json_success
RSpec::Matchers.define :be_json_success do |_expected|
match do |actual|
actual.status == 200 && actual.content_type.match("application/json")
end
failure_message do |actual|
"expected status: 200, content_type: 'application/json', got status: #{actual.status}, content_type: '#{actual.content_type}'"
@kluzny
kluzny / factories_spec.rb
Created April 8, 2023 23:32
automatically test every factory build/create
require 'rails_helper'
FactoryBot.factories.map(&:name).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
expect(build(factory_name)).to be_valid
end
it 'creates without error' do
expect { create(factory_name) }.to_not raise_error
# Kickstart file for failing graphical installation based on anaconda output from Qubes R2
install
auth --enableshadow --passalgo=sha512
cdrom
firstboot --enable
keyboard --vckeymap=us --xlayouts=''
lang en_US.UTF-8
network --hostname=dom0 --bootproto=dhcp
timezone America/Chicago --isUtc
@kluzny
kluzny / psql.sql
Created September 29, 2017 17:12
psql cheat sheet
--search and replace vars
--Database=some_db
--User=some_user
-- show roles, and db level permissions
\du
--show permissions on table
\z *.*
@kluzny
kluzny / similarity_search.rb
Last active February 12, 2021 17:14
simple class that takes an active record model and generates pg's similarity based searches
# frozen_string_literal: true
# Uses pg's trigram extension to enable multi column searches
#
# add a search method to your model
# def self.search(query)
# SimilaritySearch.new(self, over: [:name, :email, :nickname]).search(query)
# end
#
# Then call it with Foo.search("bar")
@kluzny
kluzny / gist:c1adc44aecdb78798f489fe082abdca0
Created February 7, 2017 19:41
cs50 basic makefile using gcc on ubuntu
CC = /usr/bin/gcc
CFLAGS = -g -Wall
LFLAGS = -lcs50
BIN = hello
all: $(BIN)
$(BIN):
$(CC) $(CFLAGS) -o $(BIN) $(BIN).c $(LFLAGS)
@kluzny
kluzny / postgis.sh
Created February 11, 2016 21:13 — forked from osxi/postgis.sh
Installing postgis from source on OS X because I have to use Postgres 9.4
# Adjust paths/versions as necessary (this was just my experience)
wget http://download.osgeo.org/postgis/source/postgis-2.2.1.tar.gz
tar zxvf postgis-2.2.1.tar.gz
cd postgis-2.2.1
./configure --with-pgconfig=/usr/local/bin/pg_config --with-geosconfig=/usr/local/Cellar/geos/3.5.0/bin/geos-config --with-projdir=/usr/local/Cellar/proj/4.9.2
make
make install