Skip to content

Instantly share code, notes, and snippets.

View edison7500's full-sized avatar
:octocat:
I may be slow to respond.

err edison7500

:octocat:
I may be slow to respond.
View GitHub Profile
@edison7500
edison7500 / cputemp.c
Created August 2, 2021 14:51
获得当前 cpu 的温度
/****************************************************************************************
* Include files
****************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/****************************************************************************************
* Function prototypes
****************************************************************************************/
{
"spec": {
"template": {
"spec": {
"initContainers": [{
"name": "sysctl",
"image": "alpine:3.10",
"securityContext": {
"privileged": true
},
@edison7500
edison7500 / force_default_language_middleware.py
Created April 9, 2020 13:01 — forked from vstoykov/force_default_language_middleware.py
Force Django to use settings.LANGUAGE_CODE for default language instead of request.META['HTTP_ACCEPT_LANGUAGE']
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = object
class ForceDefaultLanguageMiddleware(MiddlewareMixin):
"""
Ignore Accept-Language HTTP headers
@edison7500
edison7500 / shadowsocks_ubuntu1604.org
Created February 4, 2020 04:30 — forked from nuhuo08/shadowsocks_ubuntu1604.org
Install Shadowsocks-libev + simple-obfs on Ubuntu 16.04

Install Shadowsocks-libev + simple-obfs on Ubuntu 16.04

Install shadowsocks-libev via Ubuntu PPA

sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y
sudo apt-get update
sudo apt install shadowsocks-libev
@edison7500
edison7500 / vimrc
Created January 7, 2020 15:23
服务器上 vim 配置
" 不兼容
set nocompatible
" 显示行号
set number
" 不发出错误滴滴声
set noerrorbells
@edison7500
edison7500 / crop_image_rim.py
Last active December 18, 2019 04:10
利用 numpy 删除图片白色边框
#!/usr/bin/env python
# coding: utf-8
import numpy as np
from PIL import Image
# 得到需要裁剪边框的距离
def remove_image_rim(np_img, boundary=0.8):
_np_img = np_img
h, w, c = np_img.shape
@edison7500
edison7500 / cal_tfidf_sklearn.py
Created November 25, 2019 03:42
利用 sklearn 计算文本 tf-idf
import shutil
import tempfile
from datetime import datetime, timedelta
import jieba
import pandas as pd
from django.conf import settings
from django.core.management.base import BaseCommand
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
@edison7500
edison7500 / cal_tfidf.py
Created November 25, 2019 03:03
计算文本 tf-idf
import math
from datetime import datetime, timedelta
from django.conf import settings
from django.core.management.base import BaseCommand
from apps.articles.models import Article
idf_path = getattr(settings, "IDF_PATH", None)
from pprint import pprint
words = {'Bakkt': 2, 'Telegram': 1, 'Dfinity': 2, '大公司': 5, 'EOS': 2, 'BTC': 7, '开发者': 4, '联盟链': 1, '期货合约': 1, '投资': 3, 'ETH': 2, '安全': 1, '矿业': 3, '交易所': 1, '政策': 1, '公链': 1, '分叉': 1}
# sorted with value
sorted_words = sorted(words.items(), key=lambda x: x[1], reverse=True)
pprint(sorted_words, indent=2)
@edison7500
edison7500 / Rpi-InfluxDB-Install.md
Created October 26, 2019 04:02 — forked from boseji/Rpi-InfluxDB-Install.md
Raspberry Pi InfluxDB installation

Raspberry Pi InfluxDB: The solution for IoT Data storage

Raspberry Pi is costeffect linux computer very commonly used for IoT home automation projects.

Here are the 3 problems with conventional databases for IoT data store applications:

  • Too much or complex configuration
  • Unable to expire data / set retentional policies
  • Not tailor made of Time Series Data