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 / 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
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)
1
! 1
" 1
# 1
$ 1
% 1
& 1
' 1
( 1
) 1
var fs = require('fs');
var text = fs.readFileSync('./unicode_plane.txt');
var lines = text.toString().split('\n')
for (i=0; i < lines.length; i++) {
// console.log(lines[i].split(' '));
unicode_char = lines[i].split(' ')[0];
count = lines[i].split(' ')[1];
// test for not use spread operator
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if len(nums) == 0: return 0
if len(nums) == 1: return 1
# nums = [0,0,1,1,1,2,2,3,3,4]
j = 1 # slover pointer, only move when meet unique number
for i in range(1, len(nums)): # faster pointer, i will iterate over all element in nums
if nums[i] != nums[i-1]: # when nums[i] is a unique number, assign it to nums[j]
nums[j] = nums[i]