Skip to content

Instantly share code, notes, and snippets.

/// 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 = _>>,
}
}
#!/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
%text
class: "branding"
value: "todos"
%vbox
%hbox
%button
image: chevron-down
action: `select_all()`
// Comment
/* Block comment */
type Type uint8
type Ptr *Type
type Vec []Type
type Arr [5]Type
type Attrs u8 [ x = 1, y = "x" ]
@lann
lann / test.rb
Created September 28, 2015 20:04
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

Keybase proof

I hereby claim:

  • I am lann on github.
  • I am lann (https://keybase.io/lann) on keybase.
  • I have a public key whose fingerprint is 4AB3 17BB D5A2 E837 3161 AD52 7DEF EE0C 340C 16E6

To claim this, I am signing this object:

@lann
lann / tmx
Created September 30, 2013 22:05
#!/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
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
@lann
lann / .gitconfig
Last active December 16, 2015 15:29
[alias]
g = !env GIT_PAGER='gawk -f ~/file-alias-pager.awk | less' git grep
@lann
lann / gist:5446934
Last active December 16, 2015 14:09
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