Skip to content

Instantly share code, notes, and snippets.

View twe4ked's full-sized avatar
🐦
just setting up my twttr

Odin Dutton twe4ked

🐦
just setting up my twttr
View GitHub Profile
use std::collections::HashSet;
use std::sync::{Arc, RwLock, RwLockReadGuard};
/// A HashSet that allows controlling when items are actually removed from the list.
/// This can be helpful if you need to keep track of items being added over time
/// and ensuring that they don't get added _and_ removed before you've read them.
struct LockedHashSet {
values: Arc<RwLock<HashSet<u64>>>,
values_marked_for_removal: Arc<RwLock<HashSet<u64>>>,
}
use crate::entities::player::Player;
use bevy::input::{keyboard::KeyCode, Input};
use bevy::prelude::*;
use bevy::render::camera::Camera;
const PLAYER_SPEED: f32 = 500.0;
const PADDING: f32 = 100.0;
pub fn player_movement_system(
time: Res<Time>,

A User Manual for NAME

Working practices:

What does your perfect working day look like?

What’s your favourite method of communication?

What are your quirks?

What qualities do you particularly value in the people you work with?

What things do people sometimes misunderstand about you?

What stresses you out / frustrates you at work?

# frozen_string_literal: true
class SchemaDump
VERSION_REGEX = /
^--\sDumped\sfrom\sdatabase\sversion.*$\n
^--\sDumped\sby\spg_dump\sversion.*$\n
^\n
/x
def self.call(database_url, filename:)
#!/usr/bin/env ruby
#
# Lazy sources:
#
# - https://stackoverflow.com/a/6018744
# - https://stackoverflow.com/a/4179491
require 'time'
def ranges_overlap?(a, b)
module Sequel
class Dataset
alias_method :execute_orig, :execute
def execute(*args, &block)
SequelNotifications.subscribers.each do |subscriber|
subscriber.call(*args, &block)
end
execute_orig(*args, &block)
end
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
h = Hash.new { |hash, key| hash[key] = hash.fetch(key) { hash.values.max.to_i + 1 } }
# > h['foo']
# 1
# > h['foo']
# 1
# > h['bar']
# 2
require 'securerandom'
@twe4ked
twe4ked / ruby-ascii-table.rb
Created September 15, 2016 04:03
Ruby ASCII table
# [
# {
# 'foo' => 'bar',
# 'baz' => 'qux',
# },
# {
# 'foo' => true,
# 'baz' => 1,
# },
# ]
@twe4ked
twe4ked / tmux-last-output
Created March 26, 2015 17:20
Grab the last output from tmux
#!/usr/bin/env ruby
#
# The maximum length of a multiplexed packet is 32,768 bytes
#
# Unfortunately this works best (only works) if you have an uncommon character
# in your prompt to split on. I use "»".
FILE = '/tmp/tmux-pane'
PROMPT = '»'