Skip to content

Instantly share code, notes, and snippets.


Leo Lu leoluyi

Block or report user

Report or block leoluyi

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
leoluyi /
Created Aug 22, 2019 — forked from mariocj89/
Understanding logging in Python

Logging trees


When applications are running in production, they become black boxes that need to be traced and monitored. One of the simplest, yet main, ways to do so is logging. Logging allows us - at the time we develop our software - to instruct the program to emit information while the system is running that will be useful for us and our sysadmins.




h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
0        -   Move to beginning of line (including whitespace)
leoluyi /
Created Jul 13, 2019 — forked from conormm/
R to Python: Data wrangling with dplyr and pandas

R to python data wrangling snippets

The dplyr package in R makes data wrangling significantly easier. The beauty of dplyr is that, by design, the options available are limited. Specifically, a set of key verbs form the core of the package. Using these verbs you can solve a wide range of data problems effectively in a shorter timeframe. Whilse transitioning to Python I have greatly missed the ease with which I can think through and solve problems using dplyr in R. The purpose of this document is to demonstrate how to execute the key dplyr verbs when manipulating data using Python (with the pandas package).

dplyr is organised around six key verbs:

#!/usr/bin/env python
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
leoluyi / installPackages.R
Created Jun 28, 2019 — forked from cannin/installPackages.R
Install/update necessary packages from CRAN, Bioconductor, GitHub, or local source given a vector of strings with names of packages or file paths
View installPackages.R
#' Install/update necessary packages from CRAN, Bioconductor, GitHub
#' @param packages a vector of strings with names of packages from CRAN, Bioconductor, GitHub
#' @param file a file with packages; overrides packages parameter
#' @param updatePackages whether to update existing packages (Default: FALSE)
#' @param repos the CRAN repository to use
#' @example
#' \dontrun {
#' source("")
leoluyi / pagination-collection.liquid
Created Apr 9, 2019 — forked from Phlow/pagination-collection.liquid
If you need pagination for a collection in a Jekyll theme, you can use the following Liquid logic which works also on Github pages
View pagination-collection.liquid
{% comment %}
# I modified the original code from
# Make a collection in _config.yml and create the folder _your_collection in your root.
# collections:
# your_collection:
# output: true
# permalink: /:collection/:title/

docker-compose cheatsheet

docker-compose up # Starts multiple containers from docker-compose.yaml in same dir
docker-compose exec <service> <cmd> # Execute command in running container
docker-compose down # Removes associated containers, networks and volumes

$ docker-compose up -d         # start containers in background
leoluyi /
Created Jan 10, 2019 — forked from tgirke/
Nvim-R-Tmux: An Integrated Working Environment for R
leoluyi /
Created Dec 19, 2018 — forked from pjkelly/
GitHub Flow: Keeping Feature Branches Up-to-Date & Merging Work Back Into Master

Keeping Feature Branches Up-to-Date & Merging Work Back Into Master

The basic flow is this:

  • When you want to update a feature branch you're working on, rebase on to it.
  • When you're ready to integrate the work you've been doing into the master branch, merge it.

Detailed Step-by-Step

Given the name of your feature branch is registration-page:

leoluyi /
Created Nov 13, 2018 — forked from riffm/
Gentle `drop tables` using sqlalchemy
# -*- coding: utf-8 -*-
from sqlalchemy import create_engine
from sqlalchemy.types import SchemaType
from sqlalchemy.engine import reflection
from sqlalchemy.schema import (
You can’t perform that action at this time.