Skip to content

Instantly share code, notes, and snippets.

View ivanovaleksey's full-sized avatar

Aleksey Ivanov ivanovaleksey

View GitHub Profile
@huytd
huytd / .travis.yml
Last active November 24, 2017 16:03
Travis CI config for Rust/Diesel project
language: rust
rust:
- nightly
cache: cargo
services:
- postgresql
before_script:
- psql -c 'create database build_db;' -U postgres
- echo "DATABASE_URL=postgres://postgres@localhost/build_db" > .env
- cargo install diesel_cli --no-default-features --features=postgres
@sergeylukin
sergeylukin / post-receive
Last active April 27, 2018 13:38
Git hook (post-receive): update working tree on PUSH
#!/bin/sh
#
# This hook is placed in Bare repository and it updates Working tree whenever a PUSH
# is executed
#
# Assuming following file structure:
# .
# |-- myproject
# |-- myproject.git
# set WORKTREE=../myproject
@carlosantoniodasilva
carlosantoniodasilva / post-receive
Created February 9, 2011 01:28
Basic git post-receive hook file to deploy a Rails app.
#!/bin/bash
APP_NAME="your-app-name-goes-here"
APP_PATH=/home/deploy/${APP_NAME}
# Production environment
export RAILS_ENV="production"
# This loads RVM into a shell session. Uncomment if you're using RVM system wide.
# [[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm"

Looking into the Future

futures-rs is the library which will hopefully become a shared foundation for everything async in Rust. However it's already become renowned for having a steep learning curve, even for experienced Rustaceans.

I think one of the best ways to get comfortable with using a library is to look at how it works internally: often API design can seem bizarre or impenetrable and it's only when you put yourself in the shoes of the library author that you can really understand why it was designed that way.

In this post I'll try to put down on "paper" my understanding of how futures work and I'll aim to do it in a visual way. I'm going to assume you're already somewhat familiar with Rust and why futures are a useful tool to have at one's disposal.

For most of this post I'll be talking about how things work today (as of September 2017). At the end I'll touch on what's being proposed next and also make a case for some of the changes I'd like to see.

If you're interested in learning more ab

@nruth
nruth / tests_spec.rb
Created July 30, 2010 20:48
how not to loop/nest rspec example groups (where you want to iterate diferent let/before variable values)
class Tests
SUBTESTS = %w(Abstract Decision Quantitative Verbal)
end
describe Tests do
describe "before assigning @ - " do
describe "this doesn't work because the loops are all at the same describe level (the befores override one another)" do
Tests::SUBTESTS.each do |test|
before(:each) do
@maleficarum
maleficarum / aliasip.sh
Created February 15, 2012 19:46
Add/Remove alias for a given IP to localhost
ifconfig lo0 alias <IP>
ifconfig lo0 -alias <IP>
# this scrubs emoji sequences from a string - i think it covers all of them
def strip_emoji ( str )
str = str.force_encoding('utf-8').encode
clean_text = ""
# emoticons 1F601 - 1F64F
regex = /[\u{1f600}-\u{1f64f}]/
clean_text = str.gsub regex, ''
@heipei
heipei / docker-compose.yml
Created June 18, 2016 08:00
Docker Compose for nsqd, nsqlookupd and nsqadmin, all linked
nsqlookupd:
image: nsqio/nsq
ports:
- "4160:4160"
- "4161:4161"
command: /nsqlookupd
nsqd:
image: nsqio/nsq
ports:
@patshaughnessy
patshaughnessy / gist:7104128
Last active April 13, 2023 20:20
Resources for learning about MRI Ruby's internal C source code
Recently someone asked me for online resources about MRI's internal C source
code. Here are a few - if there are more to add please leave a comment! - pat
1. Ruby Hacking Guide - The definitive resource for people who want to learn
the C programming details of how Ruby works internally. Intended for C hackers.
It was just recently translated into English from the original Japanese.
http://ruby-hacking-guide.github.io
2. Various presentations by Koichi Sasada - he often does public presentations
on Ruby internals and they're always fascinating and full of technical details.
@silkeh
silkeh / grace.go
Created June 4, 2018 07:27
Golang graceful restart with TCP connections
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"net"
"os"
"os/signal"