Skip to content

Instantly share code, notes, and snippets.

View linyiru's full-sized avatar
🐝

Lawrence Lin linyiru

🐝
View GitHub Profile
@linyiru
linyiru / decrypt_pdf.py
Last active April 18, 2020 11:55 — forked from bzamecnik/decrypt_pdf.py
Decrypt password-protected PDF in Python.
# Decrypt password-protected PDF in Python.
# cleaned-up version of http://stackoverflow.com/a/26537710/329263
#
# Requirements:
# pip install PyPDF2
#
# Usage: decrypt_pdf('encrypted.pdf', 'decrypted.pdf', 'secret_password')
import sys
from PyPDF2 import PdfFileReader, PdfFileWriter
@linyiru
linyiru / firebase-online-user-count-example.md
Created October 24, 2017 07:13 — forked from ajaxray/firebase-online-user-count-example.md
Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally

Gathering.js - How to use

Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally.

Live Demo

Firebase Shared Checklist is a demo application that shows the number of users joined a checklist using gathering.js. Here is a 1 minute screencast of using this application.

@linyiru
linyiru / .block
Created April 17, 2017 10:18 — forked from mbostock/.block
Epicyclic Gearing
license: gpl-3.0
@linyiru
linyiru / importer_from_mysql.rb
Last active April 4, 2019 13:29
Import posts from Wordpress to Jekyll in Ruby.
require "jekyll-import";
JekyllImport::Importers::WordPress.run({
"dbname" => "YOUR_DB_NAME",
"user" => "root",
"password" => "root",
"socket" => "/Applications/MAMP/tmp/mysql/mysql.sock",
"table_prefix" => "wp_",
"site_prefix" => "",
"clean_entities" => true,
@linyiru
linyiru / webpack.config.js
Last active April 12, 2017 02:28
webpack 2.2.x config file
var path = require('path')
var _ = require('lodash')
var webpack = require('webpack')
var assetsPath = path.join(__dirname, '..', 'public', 'assets')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var config = {
context: path.join(__dirname, '..'),
entry: {
application: [
@linyiru
linyiru / 0_reuse_code.js
Created February 20, 2017 10:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@linyiru
linyiru / environment
Last active March 13, 2017 10:59
mosh mobile shell on Ubuntu
## /etc/environment
## add the following lines
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
@linyiru
linyiru / gist:6389837
Created August 30, 2013 13:26
Fail to select your own output device on Mac OSX? This tell you how to fix streaming music on Mountain Lion and AirPlay.
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
---
:verbose: true
:bulk_threshold: 1000
install: --no-ri --no-rdoc --env-shebang
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com
:benchmark: false
:backtrace: false
@linyiru
linyiru / gist:3501122
Created August 28, 2012 17:26
config/initializers/carrierwave.rb
config.fog_host = lambda do
lambda do |file|
host_number = file.path.sum % 4
"//cdn%d.icook.tw" % host_number
end
end