Skip to content

Instantly share code, notes, and snippets.

:octocat:
I may be slow to respond.

jiaxin edison7500

:octocat:
I may be slow to respond.
Block or report user

Report or block edison7500

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@edison7500
edison7500 / model2csv.py
Last active Jul 16, 2019
django command model2csv
View model2csv.py
"""
Prints CSV of all fields of a model.
"""
import csv
import logging
import sys
from django.core.management.base import BaseCommand
@edison7500
edison7500 / jquery.scrollToTop.js
Last active Aug 21, 2019
jquery.scrollToTop.js
View jquery.scrollToTop.js
import $ from "jquery";
import plugin from "./plugin";
class ScrollToTop {
constructor(element, options) {
const $element = $(element);
$(window).scroll(function () {
if ($(this).scrollTop() > options.offset) {
$element.fadeIn();
@edison7500
edison7500 / plugin.js
Created Aug 21, 2019
jquery.plugin.js
View plugin.js
import $ from "jquery";
/**
* Generate a jQuery plugin
* @param pluginName [string] Plugin name
* @param className [object] Class of the plugin
* @param shortHand [bool] Generate a shorthand as $.pluginName
*
* @example
* import plugin from 'plugin';
@edison7500
edison7500 / bmi.py
Created Sep 11, 2019
python 计算 BMI
View bmi.py
# how to calculate BMI
def BMI(height, weight):
bmi = weight/(height**2)
return bmi
# Driver code
height = 1.79832
weight = 70
# calling the BMI function
@edison7500
edison7500 / noprefix_i18n.py
Created Sep 30, 2019
django default language_code no prefix urls
View noprefix_i18n.py
import re
import logging
from django.conf import settings
from django.urls import LocaleRegexURLResolver
from django.utils.translation import get_language
logger = logging.getLogger("django")
class NoPrefixLocaleRegexURLResolver(LocaleRegexURLResolver):
@edison7500
edison7500 / Rpi-InfluxDB-Install.md
Created Oct 26, 2019 — forked from boseji/Rpi-InfluxDB-Install.md
Raspberry Pi InfluxDB installation
View Rpi-InfluxDB-Install.md

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
View sorted_dict.py
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 / cal_tfidf.py
Created Nov 25, 2019
计算文本 tf-idf
View cal_tfidf.py
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)
@edison7500
edison7500 / cal_tfidf_sklearn.py
Created Nov 25, 2019
利用 sklearn 计算文本 tf-idf
View cal_tfidf_sklearn.py
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 / crop_image_rim.py
Last active Dec 18, 2019
利用 numpy 删除图片白色边框
View crop_image_rim.py
#!/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
You can’t perform that action at this time.