Skip to content

Instantly share code, notes, and snippets.

View fcce's full-sized avatar
🚴

Feng Ce fcce

🚴
View GitHub Profile
@fcce
fcce / diff_creds.sh
Created February 23, 2023 07:52
Rails credentials diff tools
#!/usr/bin/env ruby
require 'open3'
def branch_exists?(branch_name)
o, s = Open3.capture2("git rev-parse --verify #{branch_name}")
s.success?
end
def write_credentials_to_file(credentials_path, key_path, target_path)
@fcce
fcce / 结巴词性标记集
Created May 12, 2022 01:53 — forked from hscspring/结巴词性标记集
结巴词性对照表
- a 形容词
- ad 副形词
- ag 形容词性语素
- an 名形词
- b 区别词
- c 连词
- d 副词
- df
- dg 副语素
- e 叹词

单机多用户 JupyterLab 环境搭建

概述

在这篇短文中,我们记录了如何在使用 [Ubuntu][] 1804 LTS 操作系统的单台服务器上,建立用户隔离的 [JupyterLab][] Web 环境。

目标是:

  • 操作系统的用户可以各自不受干扰的使用独立的 [JupyterLab][]
  • 各个用户的 [Conda][] 环境可以自动的出现在 [JupyterLab][] 的 Kernel 列表中
@fcce
fcce / postgres_queries_and_commands.sql
Created November 7, 2018 05:19 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@fcce
fcce / golang-nuts.go
Created June 28, 2018 06:06 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@fcce
fcce / install-redis.md
Created December 14, 2017 03:41 — forked from hackedunit/install-redis.md
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
# Yay! High voltage and arrows!
prompt_setup_pygmalion(){
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
base_prompt='%{$fg[yellow]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
post_prompt='%{$reset_color%}%{$fg[red]%}❯%{$reset_color%}%{$fg[yellow]%}❯%{$reset_color%}%{$fg[green]%}❯%{$reset_color%}%b '
@fcce
fcce / pgsql_default_sort.rb
Created July 14, 2017 04:14
pgsql_default_sort
require 'active_record/relation.rb'
module ActiveRecord
# = Active Record \Relation
class Relation
private
def exec_queries(&block)
# 如果没有排序且没有 select 任何字段 添加默认主键排序
order(arel_attribute(primary_key)) if order_values.empty? && select_values.empty?
@fcce
fcce / postgres.sql
Created June 7, 2017 07:57
postgres 实现 partition
# postgre 实现 partition
CREATE TABLE measurement (
id int not null PRIMARY KEY,
logdate date not null,
peaktemp int,
unitsales int
);
CREATE TABLE measurement_y2006 ( ) INHERITS (measurement);
CREATE TABLE measurement_y2005 ( ) INHERITS (measurement);
@fcce
fcce / CoordConvert.rb
Created February 14, 2017 15:29
ruby 版经纬度坐标系转换
class CoordConvert
class << self
PI = 3.14159265358979324
X_PI = PI * 3000.0 / 180.0 #圆周率转换量
## Krasovsky 1940
## a = 6378245.0, 1/f = 298.3
## b = a * (1 - f)
## ee = (a^2 - b^2) / a^2
A = 6378245.0 #椭球体的长半轴半径
EE = 0.00669342162296594323 #椭球体的第一偏心率