Skip to content

Instantly share code, notes, and snippets.

View myjian's full-sized avatar

Ming-yuan Jian myjian

View GitHub Profile
@myjian
myjian / Lists.html
Created March 16, 2014 13:26
Just part of the code
<div class="list-content" data-bind="if: announcementList.rendered, visible: announcementList.listVisible">
<div class="search-wrapper" data-bind="dxTextBox: { placeholder: 'Search', mode: 'search', value: announcementList.searchQuery, valueUpdateEvent: 'keyup' } "></div>
<!-- ko with: announcementList -->
<div class="list-indentation" data-bind="dxList: {dataSource: dataSource, searchQuery: searchQuery}">
<div data-options="dxTemplate : { name: 'item' } " >
<div>
<div class="course-icon-box">
<span data-bind="text: Course.substr(0, 1);"></span>
</div>
<div>
@myjian
myjian / db.js
Last active August 29, 2015 13:57
/// <reference path="../js/jquery-1.10.2.min.js"; />
/// <reference path="../js/knockout-3.0.0.js"; />
(function() {
var products = ["Spegesild", "Rogede sild", "吳佳倫", "Nord-Ost Matjeshering", "Konbu", "簡名沅", "Inlagd Sill",
"Ikura", "Guaraná Fantástica", "Gravad lax", "Escargots de Bourgogne", "Carnarvon Tigers", "Boston Crab Meat", "Uncle Bob's Organic Dried Pears",
"Tofu", "Rössle Sauerkraut", "Manjimup Dried Apples", "Longlife Tofu", "Tourtière", "Thüringer Rostbratwurst", "Perth Pasties", "Pâté chinois",
"Mishi Kobe Niku", "Alice Mutton", "Wimmers gute Semmelknödel", "Tunnbröd", "Singaporean Hokkien Fried Mee", "Ravioli Angelo", "Gustaf's Knäckebröd",
"Gnocchi di nonna Alice", "Filo Mix", "Steeleye Stout", "Sasquatch Ale", "Raclette Courdavault", "Queso Manchego La Pastora", "Mozzarella di Giovanni",
@myjian
myjian / Lists.css
Created March 16, 2014 13:33
Just part of the sheet
.course-icon-box {
float: left;
margin-right: 15px;
width: 36px;
height: 36px;
font-size: 30px;
}
@myjian
myjian / scrape.js
Last active August 29, 2015 14:01
CCSP-HW4
var request = require('request');
var cheerio = require('cheerio');
var fs = require('fs');
var appledailyURL = [
'http://www.appledaily.com.tw/realtimenews/section/new/1',
'http://www.appledaily.com.tw/realtimenews/section/new/2',
'http://www.appledaily.com.tw/realtimenews/section/new/3',
'http://www.appledaily.com.tw/realtimenews/section/new/4',
'http://www.appledaily.com.tw/realtimenews/section/new/5'];
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
<link rel="icon" type="image/png" href="/favicon-196x196.png" sizes="196x196">
<link rel="icon" type="image/png" href="/favicon-160x160.png" sizes="160x160">
@myjian
myjian / file-upload-example.js
Created December 11, 2015 10:31
File Upload using Multer with Express (Node.JS)
var express = require('express');
var multer = require('multer');
var upload = multer({ dest: 'uploads/'});
var PORT = 3000;
var app = express();
var htmlHeader = '<!DOCTYPE html>'
+ '<html lang="en">'
+ '<head>'
@myjian
myjian / Solution.java
Last active October 3, 2016 23:48
The Skyline Problem
import java.util.*;
public class Solution {
public List<int[]> getSkyline(int[][] buildings) {
// idxes: idx -> list of (start(1) or end(0), building idx)
TreeMap<Integer, List<int[]>> idxes = new TreeMap<>();
for (int i = 0; i < buildings.length; i++) {
int[] b = buildings[i];
if (!idxes.containsKey(b[0])) idxes.put(b[0], new LinkedList<int[]>());
if (!idxes.containsKey(b[1])) idxes.put(b[1], new LinkedList<int[]>());
@myjian
myjian / extract.py
Last active December 27, 2017 00:23
Extract Japanese zip file
import zipfile
import shutil
zipname = "brs.zip"
with zipfile.ZipFile(zipname) as z:
for fileinfo in z.infolist():
with z.open(fileinfo) as f:
unicode_filename = fileinfo.filename.decode("shift_jis").encode("utf-8")
with open(unicode_filename, "wb") as outputfile:
@myjian
myjian / hdx3-video-redirect.js
Last active August 18, 2018 23:13
Intelligently get password and play video for hdx3
/**
* This is a set of user scripts that open direct link to video for
* hdx3 blog when user hits the "確定" button next to the password input.
*
* Installation:
* 1. Install Tampermonkey browser extension.
* 2. Create a new script. Copy and paste PART 1 and save.
* 3. Create another script. Copy and paste PART 2 and save.
* 4. Restart the browser, OR reload any existing hdx3 pages.
*
@myjian
myjian / nextfile.js
Created September 30, 2018 07:21
mpv user script to navigate to previous/next file
/**
* mpv user script to navigate to previous/next file
* Usage: Add the following lines to input.conf
*
* MBTN_BACK script-message navigate prev
* MBTN_FORWARD script-message navigate next
* Shift+LEFT script-message navigate prev
* Shift+RIGHT script-message navigate next
* WHEEL_LEFT script-message navigate prev
* WHEEL_RIGHT script-message navigate next