Skip to content

Instantly share code, notes, and snippets.

View BrambleXu's full-sized avatar

BrambleXu BrambleXu

View GitHub Profile
.DS_Store
.ipynb_checkpoints
__pycache__
.idea
.pyc
@BrambleXu
BrambleXu / gist:3a69b7017e6f40177ee20a9f382e5a80
Created June 29, 2018 00:34 — forked from jtdp/gist:5443297
See changes before pulling from remote git repository
# fetch the changes from the remote
git fetch origin
# show commit logs of changes
git log master..origin/master
# show diffs of changes
git diff master..origin/master
# apply the changes by merge..
@BrambleXu
BrambleXu / glove2npy.py
Last active June 13, 2021 06:53
load glove and show the progress, finally save to numpy file
import numpy as np
from tqdm import tqdm
def load_glove(file):
"""Loads GloVe vectors in numpy array.
Args:
file (str): a path to a glove file.
Return:
dict: a dict of numpy arrays.
@BrambleXu
BrambleXu / pygame_install.md
Created November 5, 2018 13:46
Installing Pygame, Python 3.6 with Anaconda on OS X

Please make sure you already install the Anaconda.

I will create a virtual environment with anaconda and install the pygame in this virtual environment.

  • First create a virtual environment called pygame and install the Python 3.6 version.
conda create --name pygame python=3.6
  • Change to the pygame virtual environment.
@BrambleXu
BrambleXu / CharNullField.py
Created January 30, 2019 09:07
CharField that stores NULL but returns empty string
from django.db import models
class CharNullField(models.CharField):
"""
Subclass of the CharField that allows empty strings to be stored as NULL.
This class is used to set charfield be optional but unique when added.
Set blank=True, null=True when declaring the field
"""
description = "CharField that stores NULL but returns ''."
from collections import OrderedDict
import numpy as np
import spacy
from spacy.lang.en.stop_words import STOP_WORDS
nlp = spacy.load('en_core_web_sm')
class TextRank4Keyword():
"""Extract keywords from text"""
from collections import OrderedDict
EMOJI_UNICODE = OrderedDict({
u':1st_place_medal:': u'\U0001F947',
u':2nd_place_medal:': u'\U0001F948',
u':3rd_place_medal:': u'\U0001F949',
u':AB_button_(blood_type):': u'\U0001F18E',
u':ATM_sign:': u'\U0001F3E7',
u':A_button_(blood_type):': u'\U0001F170',
u':Afghanistan:': u'\U0001F1E6\U0001F1EB',
🥇 1
🥈 1
🥉 1
🆎 1
🏧 1
🅰 1
🇦🇫 2
🇦🇱 2
🇩🇿 2
🇦🇸 2
var fs = require('fs');
var text = fs.readFileSync('./emoji_length.txt');
var lines = text.toString().split('\n')
for (i=0; i < lines.length; i++) {
// console.log(lines[i].split(' '));
emoji = lines[i].split(' ')[0];
count = lines[i].split(' ')[1];
// test for not use spread operator
"""
BMP ranges:
0000-007F:C0控制符及基本拉丁文 (C0 Control and Basic Latin)
0080-00FF:C1控制符及拉丁文补充-1 (C1 Control and Latin 1 Supplement)
0100-017F:拉丁文扩展-A (Latin Extended-A)
0180-024F:拉丁文扩展-B (Latin Extended-B)
0250-02AF:国际音标扩展 (IPA Extensions)
02B0-02FF:空白修饰字母 (Spacing Modifiers)
0300-036F:结合用读音符号 (Combining Diacritics Marks)