This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>>>, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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:) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Lazy sources: | |
# | |
# - https://stackoverflow.com/a/6018744 | |
# - https://stackoverflow.com/a/4179491 | |
require 'time' | |
def ranges_overlap?(a, b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_source(:github) do |repo_name| | |
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") | |
"https://github.com/#{repo_name}.git" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [ | |
# { | |
# 'foo' => 'bar', | |
# 'baz' => 'qux', | |
# }, | |
# { | |
# 'foo' => true, | |
# 'baz' => 1, | |
# }, | |
# ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 = '»' |
NewerOlder