Skip to content

Instantly share code, notes, and snippets.

View LeeMendelowitz's full-sized avatar

Lee Mendelowitz LeeMendelowitz

View GitHub Profile
@sainathadapa
sainathadapa / anti_join.py
Created May 9, 2018 10:00
anti-join-pandas
import pandas as pd
def anti_join(x, y, on):
"""Return rows in x which are not present in y"""
ans = pd.merge(left=x, right=y, how='left', indicator=True, on=on)
ans = ans.loc[ans._merge == 'left_only', :].drop(columns='_merge')
return ans
def anti_join_all_cols(x, y):
@LeeMendelowitz
LeeMendelowitz / bash.md
Last active August 29, 2015 14:16
Bash one-liners

find with redirected stdout

find . -name '*.aln' | xargs -I {} sh -c 'cut -f 1 "$1" > "$1.cut"' -- {}

This will find all files *.aln and then output the first column to *.aln.cut.

get filetypes

@skranz
skranz / s_dplyr
Created March 21, 2014 07:48
Wrappers to dplyr's data modification functions like arrange, select,... that work with string arguments.
# Helper functions that allow string arguments for dplyr's data modification functions like arrange, select etc.
# Author: Sebastian Kranz
# Examples are below
#' Modified version of dplyr's filter that uses string arguments
#' @export
s_filter = function(.data, ...) {
eval.string.dplyr(.data,"filter", ...)
}
@quickshiftin
quickshiftin / osx-brew-gnu-coreutils-man.sh
Created February 21, 2014 07:25
Running GNU coreutils via Homebrew on your Mac? Here's a one-liner to get the manpages working!
# Short of learning how to actually configure OSX, here's a hacky way to use
# GNU manpages for programs that are GNU ones, and fallback to OSX manpages otherwise
alias man='_() { echo $1; man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1 1>/dev/null 2>&1; if [ "$?" -eq 0 ]; then man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1; else man $1; fi }; _'
@wch
wch / app.r
Last active December 18, 2023 16:41
Shiny example app with dynamic number of plots
max_plots <- 5
ui <- fluidPage(
headerPanel("Dynamic number of plots"),
sidebarPanel(
sliderInput("n", "Number of plots", value=1, min=1, max=5)
),
@osdf
osdf / test_numpy.py
Created October 5, 2012 21:27
Testing numpy and scipy setups
#!/usr/bin/env python
import numpy
import sys
import timeit
try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 1, 2024 03:34
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname