Skip to content

Instantly share code, notes, and snippets.

@yijia2413
yijia2413 / read_write.go
Created December 26, 2017 12:42
go read write example
package main
import (
"fmt"
"os"
"bufio"
"io/ioutil"
)
type Page struct {
jupyter notebook --allow-root --ip 0.0.0.0 --port 1024
@yijia2413
yijia2413 / install_node.sh
Created January 6, 2018 07:54
install node and npm
#!/bin/bash
set -ex
yum update -y
yum install gcc-c++ make -y
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
yum install -y nodejs
@yijia2413
yijia2413 / tf_serving.sh
Created January 19, 2018 05:56 — forked from jarutis/tf_serving.sh
Install Tensorflow Serving on Centos 7 (CPU)
sudo su
# Java
yum -y install java-1.8.0-openjdk-devel
# Build Esentials (minimal)
yum -y install gcc gcc-c++ kernel-devel make automake autoconf swig git unzip libtool binutils
# Extra Packages for Enterprise Linux (EPEL) (for pip, zeromq3)
yum -y install epel-release
Try setting C_INCLUDE_PATH (for C header files) or CPLUS_INCLUDE_PATH (for C++ header files).
As Ciro mentioned, CPATH will set the path for both C and C++.
export CPLUS_INCLUDE_PATH=/usr/include/python2.7
@yijia2413
yijia2413 / test.py
Created August 3, 2018 02:44
python utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')
@yijia2413
yijia2413 / c_callback_func.c
Created September 3, 2018 02:17
c_callback_func
// https://segmentfault.com/a/1190000008293902
#include <stdio.h>
#include <stdlib.h>
/****************************************
* 函数指针结构体
***************************************/
typedef struct _OP {
float (*p_add)(float, float);
float (*p_sub)(float, float);
#!/bin/bash
set -ex
for drive in $(ls /dev/vd* | grep -v [s-v]da); do
mount_dir=/opt/$(basename ${drive})
mkdir -p ${mount_dir}
mkfs.ext4 ${drive}
blockid=$(blkid ${drive} | cut -d "\"" -f2)
echo "UUID=${blockid} ${mount_dir} ext4 defaults 1 2" >> /etc/fstab
@yijia2413
yijia2413 / labelencoder.py
Created November 7, 2018 06:50
onehot encoder & label encoder 使用
# labelencoder 和 onehotencoder 处理测试集中未出现的样本会报错,需要进行处理
import pandas as pd
df1 = pd.read_csv("data/xxx.csv", encoding = 'utf-8', error_bad_lines=False, warn_bad_lines=False)
df1 = df1.iloc[:, :-1]
df1 = df1.drop(['xxx', 'aaa'], axis=1)
df1 = df1.fillna('0')
# 下面的代码可以直接将 整个 df labelencoder
from collections import defaultdict
d = defaultdict(LabelEncoder)
@yijia2413
yijia2413 / shell_err.sh
Last active November 14, 2018 09:54
shell_err.sh
# https://zh-google-styleguide.readthedocs.io/en/latest/google-shell-styleguide/environment/
err() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2
}
if ! do_something; then
err "Unable to do_something"
exit "${E_DID_NOTHING}"
fi