Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

gembin

🎯
Focusing
  • Seattle, WA
View GitHub Profile
@gembin
gembin / rust_code_snippets.md
Last active May 5, 2022
Rust: code snippets
View rust_code_snippets.md

Convert a Vec to Vec<&str>

let v: Vec<&str> = v.iter().map(AsRef::as_ref).collect();

Convert a collection of characters into a String

  1. chars.iter().collect::()
@gembin
gembin / color-conversion-algorithms.js
Created Nov 16, 2021 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
View color-conversion-algorithms.js
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@gembin
gembin / diff2html.sh
Created Sep 21, 2021 — forked from stopyoukid/diff2html.sh
Script that takes a git diff and outputs an html file in GitHub style
View diff2html.sh
#!/bin/bash
#
# Convert diff output to colorized HTML.
# (C) Mitch Frazier, 2008-08-27
# http://www.linuxjournal.com/content/convert-diff-output-colorized-html
# Modified by stopyoukid
#
html="<html><head><meta charset=\"utf-8\"><title>Pretty Diff</title><style>body {text-align: center;}#wrapper {display: inline-block;margin-top: 1em;min-width: 800px;text-align: left;}h2 {background: #fafafa;background: -moz-linear-gradient(#fafafa, #eaeaea);background: -webkit-linear-gradient(#fafafa, #eaeaea);-ms-filter: \"progid:DXImageTransform.Microsoft.gradient(startColorstr='#fafafa',endColorstr='#eaeaea')\";border: 1px solid #d8d8d8;border-bottom: 0;color: #555;font: 14px sans-serif;overflow: hidden;padding: 10px 6px;text-shadow: 0 1px 0 white;margin: 0;}.file-diff {border: 1px solid #d8d8d8;margin-bottom: 1em;overflow: auto;padding: 0.5em 0;}.file-diff > div {width: 100%:}pre {margin: 0;font-family: \"Bitstream Vera Sans Mono\", Courier, monospace;font-size: 12px;line-height: 1.4em;text-indent: 0.5em;}.file {color:
@gembin
gembin / mysql_waiting_for_table_metadata_lock.md
Last active Jun 30, 2022
MySQL - Waiting for table metadata lock
View mysql_waiting_for_table_metadata_lock.md
SHOW ENGINE INNODB STATUS \G

Look for the Section -

TRANSACTIONS
@gembin
gembin / rust-chrono.md
Created Jul 12, 2020
Notes: Chrono - Date and Time for Rust
View rust-chrono.md

Notes for chrono

use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};

fn main() {
    // ************************************************
    // RFC2822 = Date + Time + TimeZone
    // ************************************************
    let date_str = "Tue, 1 Jul 2003 10:52:37 +0200";
@gembin
gembin / rust_email_with_lettre.md
Last active Apr 21, 2020
Send email with lettre
View rust_email_with_lettre.md

Introduction

https://github.com/lettre/lettre is a library to send emails over SMTP from our Rust applications.

Cargo.toml

lettre = "0.9.2"
lettre_email = "0.9.2"
native-tls = "0.2"
@gembin
gembin / install_mysql_on_mac.md
Last active Apr 16, 2020
Install MySQL on MacOS
View install_mysql_on_mac.md

Install

brew install mysql
brew tap homebrew/services
brew services start mysql

Configuration

If you run into this error using GUI tools, e.g. Sequel Pro:

Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found
View postgres-export-data-to-csv.md
export PGPASSWORD=xxxx
psql -h xxx_host -U xxx_user -p xxx_port -d xxx_db -q -A -F ',' -f xxx_query.sql > xxx_output.csv
@gembin
gembin / Tensorflow_Build_GPU.md
Created Nov 28, 2018 — forked from smitshilu/Tensorflow_Build_GPU.md
Tensorflow 1.4 Mac OS High Sierra 10.13 GPU Support
View Tensorflow_Build_GPU.md

Tensorflow

System information

  • OS - High Sierra 10.13
  • Tensorflow - 1.4
  • Xcode command line tools - 8.2 (Download from here: Xcode - Support - Apple Developer & Switch to different clang version: sudo xcode-select --switch/Library/Developer/CommandLineTools & check version: clang -v)
  • Cmake - 3.7
  • Bazel - 0.7.0
@gembin
gembin / 词性标记.md
Created Nov 25, 2018 — forked from luw2007/词性标记.md
词性标记: 包含 ICTPOS3.0词性标记集、ICTCLAS 汉语词性标注集、jieba 字典中出现的词性、simhash 中可以忽略的部分词性
View 词性标记.md

词的分类

  • 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
  • 虚词:副词、介词、连词、助词、拟声词、叹词。

ICTPOS3.0词性标记集

n 名词

nr 人名