This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (() => { | |
/** | |
* This script is used to create the Google Calendar event links of the | |
* courses on the NTU "My Schedule" page. | |
*/ | |
if ( | |
location.href !== "https://nol.ntu.edu.tw/nol/coursesearch/myschedule.php" | |
) { | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
WARNING: This model does NOT reflect the situation of the real world, and | |
I(the author) do NOT like to decide which policy the government should | |
implement based on accidents data. | |
''' | |
import sys | |
import random | |
if not sys.version_info.major == 3 and sys.version_info.minor >= 7: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Usage: | |
* 1. Minify this script. | |
* 2. Rewrite minified script to `javascript:THE_MINIFIED_SCIPT`. | |
* 3. Add modified script to your bookmark. | |
* 4. Click it when you're at the Gmail page. | |
*/ | |
(async function () { | |
if (location.hostname != 'mail.google.com') return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import json | |
import pathlib | |
import re | |
import sqlite3 | |
import sys | |
import urllib | |
from pprint import pprint | |
from bs4 import BeautifulSoup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This exercise covers the first 6 chapters of "Learn You a Haskell for Great Good!" | |
-- Chapter 1 - http://learnyouahaskell.com/introduction | |
-- Chapter 2 - http://learnyouahaskell.com/starting-out | |
-- Chapter 3 - http://learnyouahaskell.com/types-and-typeclasses | |
-- Chapter 4 - http://learnyouahaskell.com/syntax-in-functions | |
-- Chapter 5 - http://learnyouahaskell.com/recursion | |
-- Chapter 6 - http://learnyouahaskell.com/higher-order-functions | |
-- Download this file and then type ":l Chapter-1-6.hs" in GHCi to load this exercise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from inspect import getargspec, getfullargspec | |
def kwargs_only(a, b, c=3, d=4, **kwargs): | |
pass | |
def default_args(a, b, c=3, d=4, *args, **kwargs): | |
pass | |
def default_kwargs(a, b, *args, c=3, d=4, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict, List, Iterable, Hashable, Mapping, Sequence | |
def seq2lookup( | |
seqences: Iterable[Sequence], index: int, | |
) -> Dict[Hashable, Sequence]: | |
""" | |
Build the lookup table from a group of sequences. | |
The lookup table is used to quickly find the target sequence with the | |
corresponding item which is at the specific index of the target sequence. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import io | |
from pathlib import Path | |
from PIL import Image | |
from PIL import ImageFont | |
from PIL import ImageDraw | |
from PIL import ExifTags | |
import exiftool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function signature(e){switch(typeof e){case"string":return"s";case"number":return Number.isInteger(e)?"i":"f";case"undefined":return"u";default:return null===e?"n":e.constructor===Array?"a":`{${Object.keys(e).sort().map(r=>`${r}:${signature(e[r])}`).join(",")}}`}} | |
function deserilize(sign){return eval(`i='i';s='s';n='n';a='a';f='f';var o=${sign};o;`)} | |
function _diff([e,t]){return Object.keys(e).forEach(f=>{"object"==typeof e[f]&&"object"==typeof t[f]?([e[f],t[f]]=_diff([e[f],t[f]]),Object.keys(e[f]).length||Object.keys(t[f]).length||(delete e[f],delete t[f])):e[f]===t[f]&&(delete e[f],delete t[f])}),[e,t]} | |
function diff(f,i){return _diff([f,i].map(deserilize))} | |
// > use mydb | |
db.mycollection.mapReduce(function() { emit(signature(this), 1)}, function(k, vs) { return Array.sum(vs) }, { out: {replace: 'mycollection_', db: 'mydbschema'}, scope: { signature }) | |
// > use mydbschema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const java = require('java'); | |
const path = require('path'); | |
const JAVA_DIR = path.resolve(__dirname, '../libs/java/'); | |
java.options = [ '-Xms3072m' , '-Xmx3072m', '-Xmn1152m' ]; | |
java.asyncOptions = { | |
asyncSuffix: 'Async', | |
syncSuffix: '', // For readability, remove the convetional suffix of sync | |
// functions. | |
ifReadOnlySuffix: '_alt', |