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
// Example generated bindings | |
mod bindings { | |
pub trait Host { | |
fn host_func(&mut self); | |
} | |
pub trait GetHost<T>: Send + Sync + 'static { | |
fn get_host<'a>(&self, data: &'a mut T) -> impl Host; | |
} |
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
/// Gets the missing content of the record. | |
pub fn missing_content(&self) -> impl Iterator<Item = (&AnyHash, &MissingContent)> { | |
match &self.state { | |
PackageRecordState::Sourcing { | |
missing_content, .. | |
} => Box::new(missing_content.iter()) as Box<dyn Iterator<Item = _>>, | |
_ => Box::new(std::iter::empty()) as Box<dyn Iterator<Item = _>>, | |
} | |
} |
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 bash | |
set -eu | |
case "${1:-now}" in | |
now) ;; | |
log) git reflog 'AUTOSAVE@{now}'; exit 0 ;; | |
expire) git reflog expire AUTOSAVE; exit 0 ;; | |
*) echo "git autosave [now,log,expire]"; exit 1 ;; | |
esac |
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
%text | |
class: "branding" | |
value: "todos" | |
%vbox | |
%hbox | |
%button | |
image: chevron-down | |
action: `select_all()` | |
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
// Comment | |
/* Block comment */ | |
type Type uint8 | |
type Ptr *Type | |
type Vec []Type | |
type Arr [5]Type | |
type Attrs u8 [ x = 1, y = "x" ] |
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
#!/bin/bash | |
SOCK_SYMLINK=~/.ssh/ssh_auth_sock | |
[ -r $SSH_AUTH_SOCK ] && ln -sf $SSH_AUTH_SOCK $SOCK_SYMLINK | |
env SSH_AUTH_SOCK=$SOCK_SYMLINK tmux $@ attach |
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
Class.new(ActiveSupport::LogSubscriber) do | |
def sql(event) | |
query = event.payload[:sql] | |
if query.length > 10_000 | |
Rails.logger.info "Large query: #{query}" | |
Rails.logger.info '!stacktrace!begin' | |
Rails.logger.info Rails.backtrace_cleaner.clean(caller).join("\n") | |
Rails.logger.info '!stacktrace!end' | |
end | |
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
[alias] | |
g = !env GIT_PAGER='gawk -f ~/file-alias-pager.awk | less' git grep |
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 Reqtrace | |
@trace_file = File.open('/tmp/reqtrace.txt', 'w') | |
@name_stack = [nil] | |
@time_stack = [0] | |
def self.trace(name, &blk) | |
@name_stack << name | |
@time_stack << 0 | |
start = Time.now |
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
require 'tcp_timeout' | |
server = 'stackoverflow.com' | |
begin | |
socket = TCPTimeout::TCPSocket.new(server, 80, read_timeout: 1) | |
socket.read(100) | |
rescue TCPTimeout::SocketTimeout => e | |
puts "[!] #{server} Timeout" | |
end |
NewerOlder