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
#install essential stuff | |
sudo apt-get install build-essential autoconf locate | |
sudo apt-get install git guake zsh curl vim vim-gtk3 postgresql-client \ | |
postgresql postgresql-contrib redis golang direnv tmux bat ripgrep fzf | |
curl -L http://install.ohmyz.sh | sh | |
chsh -s /bin/zsh | |
zsh | |
#edit pg_hba.conf |
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 deadpool_postgres::tokio_postgres::NoTls; | |
use deadpool_postgres::{Config, ManagerConfig, Pool, PoolError, RecyclingMethod}; | |
use once_cell::sync::Lazy; | |
use std::sync::Arc; | |
static DB_POOL: Lazy<Arc<Pool>> = Lazy::new(|| { | |
let mut cfg = Config::new(); | |
cfg.dbname = Some( | |
std::env::var("DATABASE_URL") | |
.map_err(|_| String::from("Environment variable Database URL could not be read")) |
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 tokio::sync::mpsc::{self, Receiver, Sender}; | |
use tokio_stream::wrappers::ReceiverStream; | |
use tokio_util::sync::{PollSendError, PollSender}; | |
use std::pin::Pin; | |
use std::task::{Poll, Context}; | |
pub struct Duplex<T: Send + 'static> { | |
channel1: Channel<T>, | |
channel2: Channel<T>, | |
} |
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 'benchmark/ips' | |
class Foo | |
def bar; end | |
end | |
foo = Foo.new | |
Benchmark.ips do |x| | |
x.config(:time => 5, :warmup => 2) |
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::{error::Error as StdError, fmt}; | |
#[derive(Debug)] | |
pub struct Error { | |
pub kind: ErrorKind, | |
pub context: ErrorContext, | |
} | |
#[derive(Debug)] | |
pub enum ErrorKind { |
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 TimingBenchmark | |
def measure(label, &block) | |
@label_times ||= {} | |
start = Time.now | |
result = block.call | |
@label_times[label] = Time.now - start | |
return result | |
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
require 'benchmark/ips' | |
require 'faker' | |
_hash = 100.times.inject({}){|hash, i| | |
hash[Faker::Lorem.word] = Faker::Lorem.word | |
hash | |
} | |
_hash[:aaa] = 'a' | |
HASH = _hash |
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 'bundler/setup' | |
Bundler.require(:default) | |
class Serializer | |
def user_path(id) | |
"/user/#{id}" | |
end | |
end | |
class User |
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
#ENV: Ruby 2.4.1, a i7-6700HQ CPU, 16GB RAM | |
require 'benchmark' | |
require 'delegate' | |
require 'forwardable' | |
class Person | |
def initialize(name) | |
@name = name | |
end |
NewerOlder