Skip to content

Instantly share code, notes, and snippets.

Jinyang Li jinyangustc

Block or report user

Report or block jinyangustc

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

How to sort dict...

By value

Return as a list of tuples:

x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
sorted_x = sorted(x.items(), key=lambda kv: kv[1])
#=> [(0, 0), (2, 1), (1, 2), (4, 3), (3, 4)]
`datetime` is included in the standard library.
time format:
%d: Day of the month as a zero-padded decimal number. 01, 02, ..., 31
%m: Month as a zero-padded decimal number. 01, 02, ..., 12
%Y: Year with century as a decimal number.
%H: Hour (24-hour clock) as a zero-padded decimal number. 00, 01, ..., 23
%M: Minute as a zero-padded decimal number. 00, 01, ..., 59
jinyangustc / config2.json
Created Jul 22, 2019 — forked from pmav99/config2.json
Python logging configuration using JSON. If you want an updated example also covering YAML files, check here:
View config2.json
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
jinyangustc /
Created Jul 21, 2019 — forked from bessarabov/
Script to generate data shown in post 'At what time of day does famous programmers work? Part 2. Workweek vs Weekend.' —
# This script is made to show graphs with git commit time made on workweek vs weekend
# The desription of this script and results of its usage is avaliable at:
# usage:
# git log --author="Sebastian Riedel" --format="%H %ai" | perl
jinyangustc / vimgolf.vimrc
Created Jul 19, 2019 — forked from igrigorik/vimgolf.vimrc
Basic vimrc to level the playing field...
View vimgolf.vimrc
set nocompatible " use vim defaults
set scrolloff=3 " keep 3 lines when scrolling
set ai " set auto-indenting on for programming
set showcmd " display incomplete commands
set nobackup " do not keep a backup file
set number " show line numbers
set ruler " show the current row and column
import logging
class TaskIdFilter(logging.Filter):
"""This filter injects task_id into the log."""
def __init__(self, task_id):
self.task_id = task_id
jinyangustc / merlin-sublime-popups.patch
Created Jul 15, 2019 — forked from trishume/merlin-sublime-popups.patch
Patch to add type inference and definition popups to Sublime Text's Merlin plugin
View merlin-sublime-popups.patch
diff --git a/Packages/Merlin/ b/Packages/Merlin/
--- a/Packages/Merlin/
+++ b/Packages/Merlin/
@@ -248,6 +248,57 @@
opened_view.run_command("insert_code", { "arg": sig })
+class MerlinInfoPopup:
+ """
+ Pop up a menu at a point describing an expression
jinyangustc /
Created Dec 7, 2018 — forked from iamaziz/
Calculate Entropy and Information Gain for Decision Tree Learning
# -*- coding: utf-8 -*-
# calculating the Entropy and Information Gain for: Learning with Trees
# by: Aziz Alto
# see Information Gain:
from __future__ import division
jinyangustc / vimrc
Created Aug 28, 2018 — forked from r00k/vimrc
A minimal vimrc for beginners
View vimrc
" A minimal vimrc for new vim users to start with.
" Referenced here:
" Original Author: Bram Moolenaar <>
" Made more minimal by: Ben Orenstein
" Last change: 2012 Jan 20
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc


There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.


  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
You can’t perform that action at this time.