Skip to content

Instantly share code, notes, and snippets.

View coolmenu's full-sized avatar

Coolmenu coolmenu

View GitHub Profile
@coolmenu
coolmenu / rails-jsonb-queries
Created August 8, 2020 04:07 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@coolmenu
coolmenu / profiles.json
Created June 6, 2020 10:55 — forked from symant233/profiles.json
Windows Terminal Settings <v0.10.781.0> 2020-04-03
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"alwaysShowTabs": true,
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols": 100,
"initialRows": 30,
"requestedTheme": "dark",
"showTabsInTitlebar": true,
"showTerminalTitleInTitlebar": true,
"tabWidthMode": "equal",
@coolmenu
coolmenu / install.sh
Created February 4, 2020 03:49 — forked from chuyik/install.sh
Bandwagon(搬瓦工) CentOS 7 安装 shadowsocks-libev 和 kcptun
######################
## shadowsocks-libev
######################
# install dependencies
yum install epel-release -y
yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto udns-devel libev-devel -y
# install shadowsocks-libev
cd /etc/yum.repos.d/

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

@coolmenu
coolmenu / x1c6.md
Created August 12, 2018 12:05 — forked from JZfi/x1c6.md
Lenovo ThinkPad X1 Carbon 6th gen (X1C6) and openSUSE Tumbleweed notes

Model 20KH-006MMX (with NFC & HDR) notes for stuff I've done this far to get the machine to an usable state.

openSUSE Tumbleweed works ok and touchpad & trackpoint & hibernation works out-of-the-box (not the case with Ubuntu 18.04 LTS).

To test out hibernation just type (after this it will appear in the GNOME menus):

# systemctl hibernate

BIOS

@coolmenu
coolmenu / tokenizer.mll
Created April 10, 2017 11:00 — forked from lindig/tokenizer.mll
Some Scanning Recipes for OCamlLex
{
(* short names for important modules *)
module L = Lexing
module B = Buffer
type token =
| STR of string
| INT of int
| ID of string
| PLUSEQ
@coolmenu
coolmenu / etcd_cluster.sh
Created December 22, 2016 23:31 — forked from jolestar/etcd_cluster.sh
Run etcd cluster by docker with custom network
docker network create etcd --subnet 172.19.0.0/16
docker run -d --name etcd0 --network etcd --ip 172.19.1.10 quay.io/coreos/etcd etcd \
-name etcd0 \
-advertise-client-urls http://172.19.1.10:2379,http://172.19.1.10:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://172.19.1.10:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://172.19.1.10:2380,etcd1=http://172.19.1.11:2380,etcd2=http://172.19.1.12:2380 \
@coolmenu
coolmenu / new_gist_file_0
Created December 7, 2016 11:36 — forked from jwkfreedom/new_gist_file_0
A simple Netty Http server sample. Netty是一套高性能的通讯架构,这里我用netty实现http服务器实现信息采集功能。主要是利用他现有的hander处理器,解析出request头,做信息采集使用,重写了他自己的hander.
package io.netty.example.http.snoop;
import static io.netty.handler.codec.http.HttpHeaders.getHost;
import static io.netty.handler.codec.http.HttpHeaders.isKeepAlive;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpHeaders.Names.COOKIE;
@coolmenu
coolmenu / cx_oracle.md
Created December 7, 2016 07:57 — forked from kimus/cx_oracle.md
Installing python cx_oracle on Ubuntu

First of all, it just seems like doing anything with Oracle is obnoxiously painful for no good reason. It's the nature of the beast I suppose. cx_oracle is a python module that allows you to connect to an Oracle Database and issue queries, inserts, updates..usual jazz.

Linux

Step 1:

sudo apt-get install build-essential unzip python-dev libaio-dev

Step 2. Click here to download the appropriate zip files required for this. You'll need:

@coolmenu
coolmenu / huberflores_example.xml
Created November 18, 2016 09:13 — forked from huberflores/huberflores_example.xml
Tsung Configuration File
<!--
author Huber Flores
-->
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<!-- Client side setup -->
<clients>