Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Leo Lu leoluyi

🎯
Focusing
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
leoluyi / python-logging.md
Created Aug 22, 2019 — forked from mariocj89/python-logging.md
Understanding logging in Python
View python-logging.md

Logging trees

Introduction

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.

View vim-shortcuts.md

VIM KEYBOARD SHORTCUTS

MOVEMENT

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
leoluyi / r-to-python-data-wrangling-basics.md
Created Jul 13, 2019 — forked from conormm/r-to-python-data-wrangling-basics.md
R to Python: Data wrangling with dplyr and pandas
View r-to-python-data-wrangling-basics.md

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:

View summary_tool.py
#!/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
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("https://gist.githubusercontent.com/cannin/6b8c68e7db19c4902459/raw/installPackages.R")
@leoluyi
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 http://anjesh.github.io/2015/01/25/collection-pagination-working-github-pages/
#
# Make a collection in _config.yml and create the folder _your_collection in your root.
#
# collections:
# your_collection:
# output: true
# permalink: /:collection/:title/
View docker-compose-cheatsheet.md

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
leoluyi / _Nvim-R-Tmux.md
Created Jan 10, 2019 — forked from tgirke/_Nvim-R-Tmux.md
Nvim-R-Tmux: An Integrated Working Environment for R
View _Nvim-R-Tmux.md
@leoluyi
leoluyi / Readme.md
Created Dec 19, 2018 — forked from pjkelly/Readme.md
GitHub Flow: Keeping Feature Branches Up-to-Date & Merging Work Back Into Master
View Readme.md

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
leoluyi / db_tools.py
Created Nov 13, 2018 — forked from riffm/db_tools.py
Gentle `drop tables` using sqlalchemy
View db_tools.py
# -*- coding: utf-8 -*-
from sqlalchemy import create_engine
from sqlalchemy.types import SchemaType
from sqlalchemy.engine import reflection
from sqlalchemy.schema import (
MetaData,
Table,
DropTable,
ForeignKeyConstraint,
You can’t perform that action at this time.