Skip to content

Instantly share code, notes, and snippets.

Yufan Lou louy2

Block or report user

Report or block louy2

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
# -*- coding: gbk -*-
from __future__ import with_statement
import codecs
from datetime import datetime
from datetime import timedelta
from os import linesep
import cPickle
#import ClientCookie
from urllib2 import urlopen
louy2 / dragToDownload.js
Last active Aug 29, 2015
A naive tampermonkey script enabling "drag to download" direct links. #user.js
View dragToDownload.js
// ==UserScript==
// @name Drag To Download
// @namespace
// @version 0.1
// @description Drag direct links to files to computer.
// @author Lou Yufan
// @match http://*/*
// @match https://*/*
// @grant none
// ==/UserScript==
louy2 / Vagrantfile
Created Dec 31, 2015
Vagrantfile for a Ubuntu box bridging an OpenVPN via Shadowsocks
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config| = "ubuntu/trusty64" "public_network", bridge: "<name of network interface>"
config.vm.provision "shell", inline: <<-INSTALL
louy2 / ando16.go
Last active Mar 9, 2016
「眼帯」ゲットチャレンジ! (go) | 恋愛SLG: プログラミングで彼女をつくる|paizaオンラインハッカソン7
View ando16.go
package main
import (
func parseBookList (bookListStr string) []int {
louy2 / ando17.go
Last active Mar 9, 2016
「縞ニーソセット」ゲットチャレンジ! | 恋愛SLG: プログラミングで彼女をつくる|paizaオンラインハッカソン7
View ando17.go
package main
import (
func parseStdin() (int, int) {
stdin := bufio.NewScanner(os.Stdin)
louy2 / ando11.go
Created Mar 9, 2016
「めがね」ゲットチャレンジ! | 恋愛SLG: プログラミングで彼女をつくる|paizaオンラインハッカソン7
View ando11.go
package main
import (
func parseStdin() {
stdin := bufio.NewScanner(os.Stdin)
louy2 / installBluraySupport.cmd
Last active Mar 10, 2016
Install Blu-ray support for VLC media player on Windows
View installBluraySupport.cmd
:: Name: installBluraySupport.cmd
:: Purpose: Install Blu-ray support for VLC media player on Windows
:: Usage: 1. Install VLC media player
:: * Install 64-bit version for 64-bit system, or this script doesn't work
:: 2. Download corresponding files from
:: 3. Put them under the same folder as this script
:: 4. Execute the script
@echo off
if not exist %PROGRAMDATA%\aacs (
louy2 /
Last active Mar 31, 2016
`defer` from Go (Golang) to C -- in [Emulating "defer" in C, with Clang or GCC+Blocks]( by [smokris](

How does the magic work? Starting from the last line:

  1. __attribute__((cleanup(…))) — an extension to the C language, provided by GCC and Clang. When a variable is tagged with this attribute, the specified function is invoked when the variable leaves scope.
  2. void (^…)(void) = ^{ … } — C Blocks, an extension to the C language, provided by Clang or GCC with Apple’s Blocks patch. Allows you to define inline, anonymous functions. In this case, I’m taking the block that’s expected to appear after the defer macro and assigning it to a local variable.
  3. a##b — merge two strings into a single token. By combining defer_scopevar_ with the __COUNTER__, I get a unique variable name.
  4. void defer_cleanup(void (^*b)(void)) { (*b)(); } — a C function that takes a block as its parameter. I pass this function to __attribute__((cleanup(…))), and it gets invoked when the variable (defined in step #2) leaves scope. When the function is invoked, it just calls the block that was passed to it. (This indirection
View xhistogram.c
* Copyright (C) 2010, Google Inc.
* and other copyright owners as documented in JGit's IP log.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Distribution License v1.0 which
* accompanies this distribution, is reproduced below, and is
* available at
* All rights reserved.
View titlecase.js
function titleCase(str) {
return str.toLowerCase().replace(/(^[a-z]| [a-z])/g, function(match) {
return match.toUpperCase();
You can’t perform that action at this time.