Skip to content

Instantly share code, notes, and snippets.

View gnepud's full-sized avatar

Peng Du gnepud

  • Grenoble, France
View GitHub Profile
@gnepud
gnepud / gist:98da812130ec79bf942e4e038b0ab02e
Created October 23, 2019 14:12
[Postgresql docker] PANIC: could not locate a valid checkpoint record
mkdir {pg_commit_ts,pg_dynshmem,pg_tblspc,pg_twophase,pg_stat,pg_stat_tmp,pg_replslot,pg_snapshots,pg_logical}
mkdir pg_logical/{snapshots,mappings}
mkdir pg_xlog/archive_status
docker run -it -v /path/to/postgres_data:/var/lib/postgres/data postgres:9.6 /bin/bash
gosu postgres pg_resetxlog -f /var/lib/postgres/data
0453ebc067acdd2ce302c02e2313eed7452651d6b45074bc1d34596ee1c3ead6a79d89095cf391c79c6fcf24d10d638aaaae22ec66d639335862dd3ce72250a1fc c-darwin
@gnepud
gnepud / shuffle.js
Created March 16, 2017 12:23
shuffle array in javascript
// http://stackoverflow.com/a/962890/642670
function shuffle(array) {
var tmp, current, top = array.length;
if(top) while(--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
@gnepud
gnepud / main.js
Created February 9, 2017 11:36
Example: User Promise and Generator for handle async in Javascript
function run(generator, res) {
const ret = generator.next(res);
if (ret.done) return;
ret.value.then(function (res) {
run(generator, res);
});
}
let count = 1;
function tick(time) {
@gnepud
gnepud / shadowsocks_ssh
Last active April 30, 2018 20:42
shadowsocks / ssh proxy
----- shadowsocks ------
server
easy_install pip
pip install shadowsocks
vi /etc/shadowsocks.json
{
"server":"server_ip",
"server_port":8388,
"local_address": "127.0.0.1",
"local_port":1080,
@gnepud
gnepud / gist:968915ec49e61a951bde
Created March 7, 2016 13:45
Bash One Liner - Compose Music From Entropy in /dev/urandom
# http://blog.robertelder.org/bash-one-liner-compose-music/
cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | awk '{ split("0,2,4,5,7,9,11,12",a,","); for (i = 0; i < 1; i+= 0.0001) printf("%08X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' | xxd -r -p | aplay -c 2 -f S32_LE -r 16000
@gnepud
gnepud / gist:4cac79b5e5f5053c1fd6
Last active September 4, 2022 10:09
docker elasticsearch / kibana install plugin
# elasticsearch
docker run --rm -v "$PWD/esdata":/usr/share/elasticsearch/data -v "$PWD/esdata/plugins":/usr/share/elasticsearch/plugins elasticsearch /usr/share/elasticsearch/bin/plugin install marvel-agent
docker run -d -v "$PWD/esdata":/usr/share/elasticsearch/data -v "$PWD/esdata/plugins":/usr/share/elasticsearch/plugins -p 9200:9200 -p 9300:9300 --name=elasticsearch elasticsearch
# kibana
mkdir -p kibana/installedPlugins
chmod 777 -R kibana
docker run --rm -v "$PWD/kibana/installedPlugins":/opt/kibana/installedPlugins --link some-elasticsearch:elasticsearch kibana kibana plugin --install elasticsearch/marvel/latest
docker run -d --name kibana -v "$PWD/kibana/installedPlugins":/opt/kibana/installedPlugins --link some-elasticsearch:elasticsearch -p 5601:5601 kibana
@gnepud
gnepud / gist:7e4166f3141173c28ee9
Created October 23, 2015 14:25
用 git submodule 同步 vim-plugins
首先,你的 vim 配置文件得先有一个 git repository。
当我们为vim安装插件时,我们需要复制不同的文件到不同的目录,这让更新插件操作非常困难。
但现在很多vim的插件都有一个github repository。我们可以使用git submodule和pathogen插件来让这个操作变得容易点。
为 Vim 添加 bundle 支持
Tim Pope写了一个 vim 插件名叫 pathogen 。这个插件可以让事情变得容易点。
@gnepud
gnepud / all.js
Created July 23, 2015 10:24
select2 3.5.2 + twitter Bloodhound
$(document).ready(function () {
var engine = new Bloodhound({
local: [
'Andorra',
'Unitéd Arab Emirates',
'Antarctica'
],
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
@gnepud
gnepud / nl.sh
Last active August 29, 2015 14:15 — forked from yyx990803/nl.sh
alias ng="npm list -g --depth=0 2>/dev/null"
alias nl="npm list --depth=0 2>/dev/null"