Skip to content

Instantly share code, notes, and snippets.

View linyiru's full-sized avatar
🐝

Lawrence Lin linyiru

🐝
View GitHub Profile
@linyiru
linyiru / redis_helper.rb
Created February 14, 2012 10:58 — forked from wxmn/redis_helper.rb
How to Build a Fast News Feed in Redis and Rails
module RedisHelper
# decode Redis value back to Ruby object
def self.decode(json)
self.new(ActiveSupport::JSON.decode(json)["#{self.name.downcase}"])
end
# encode Ruby object for Redis
def encoded
self.updated_at = nil
self.to_json
@linyiru
linyiru / gist:3484999
Created August 27, 2012 01:58 — forked from dlackty/gist:3483170
OS X Rails Setup
#! /usr/bin/env bash
# llvm-gcc
if `type -P llvm-gcc &>/dev/null`; then
echo "Command Line Tools found."
else
echo "Command Line Tools not found."
echo "Please go https://developer.apple.com/downloads and install **Command Line Tools for Xcode**" && exit 0;
fi
@linyiru
linyiru / .gemrc
Created August 28, 2012 08:24 — forked from dlackty/gist:3483170
OS X Rails Setup
---
: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 / 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 / .block
Created April 17, 2017 10:18 — forked from mbostock/.block
Epicyclic Gearing
license: gpl-3.0
@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 / 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 / Gemfile
Last active October 15, 2018 13:59 — forked from pietern/redis_pubsub_demo.rb
bundle exec ruby redis_pubsub_demo.rb
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
gem 'eventmachine'
gem 'sinatra'
gem 'yajl-ruby', require: 'yajl'
gem 'thin'
gem 'em-websocket'
@linyiru
linyiru / deploy.sh
Created January 15, 2019 13:39 — forked from sbrichardson/deploy.sh
Poor man's continuous integration script, simple code deployment to Kubernetes on GCP (Google Cloud Platform)
#!/bin/bash
#
# Checks Google Cloud container registry to see if build has finished deploying new image from
# source repository recent update. "GCP" stands for "Google Cloud Platform" when used below.
#
# By default, retries 9 times, waiting 45 seconds between attempts.
#
# Configure the variables at the top of the file for your environment
@linyiru
linyiru / buildSitemap.js
Created January 18, 2019 05:17 — forked from evantahler/buildSitemap.js
35 lines to build a sitemap for next.js projects
#! /usr/bin/env node
// I am ./bin/buildSitemap.js
const path = require('path')
const glob = require('glob')
const fs = require('fs')
const SITE_ROOT = process.env.SITE_ROOT || 'https://www.actionherojs.com'
const SOURCE = process.env.SOURCE || path.join(__dirname, '..', 'pages', '/**/*.js')
const DESTINATION = process.env.DESTINATION || path.join(__dirname, '..', 'static', 'sitemap.xml')