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
@louy2
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==
View qzone_exporter.py
# -*- 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
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|
config.vm.box = "ubuntu/trusty64"
config.vm.network "public_network", bridge: "<name of network interface>"
config.vm.provision "shell", inline: <<-INSTALL
@louy2
louy2 / ando16.go
Last active Mar 9, 2016
「眼帯」ゲットチャレンジ! https://paiza.jp/poh/ando (go) | 恋愛SLG: プログラミングで彼女をつくる|paizaオンラインハッカソン7
View ando16.go
package main
import (
"fmt"
"os"
"log"
"strings"
"bufio"
"strconv"
)
func parseBookList (bookListStr string) []int {
@louy2
louy2 / ando17.go
Last active Mar 9, 2016
「縞ニーソセット」ゲットチャレンジ!https://paiza.jp/poh/ando | 恋愛SLG: プログラミングで彼女をつくる|paizaオンラインハッカソン7
View ando17.go
package main
import (
"fmt"
"os"
"log"
"strconv"
"bufio"
)
func parseStdin() (int, int) {
stdin := bufio.NewScanner(os.Stdin)
@louy2
louy2 / ando11.go
Created Mar 9, 2016
「めがね」ゲットチャレンジ!https://paiza.jp/poh/ando | 恋愛SLG: プログラミングで彼女をつくる|paizaオンラインハッカソン7
View ando11.go
package main
import (
"fmt"
"os"
"bufio"
"strconv"
)
func parseStdin() {
stdin := bufio.NewScanner(os.Stdin)
stdin.Scan()
@louy2
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 https://www.videolan.org/vlc/download-windows.html
:: * Install 64-bit version for 64-bit system, or this script doesn't work
:: 2. Download corresponding files from http://vlc-aacs.whoknowsmy.name/
:: 3. Put them under the same folder as this script
:: 4. Execute the script
@echo off
if not exist %PROGRAMDATA%\aacs (
@louy2
louy2 / Explanation.md
Last active Mar 31, 2016
`defer` from Go (Golang) to C -- in [Emulating "defer" in C, with Clang or GCC+Blocks](http://fdiv.net/2015/10/08/emulating-defer-c-clang-or-gccblocks) by [smokris](http://fdiv.net/users/smokris)
View Explanation.md

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 http://www.eclipse.org/org/documents/edl-v10.php
*
* 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.