Skip to content

Instantly share code, notes, and snippets.

View stevekm's full-sized avatar

Stephen Kelly stevekm

View GitHub Profile
@jfaganUK
jfaganUK / sqlite_blob.r
Created January 12, 2015 18:26
Storing R Objects as a SQLite Blob
#' ## Storing R Objects in a SQLite Database
#' Two packages we are using. The first is the ```RSQLite``` which will be used to create and manage an in-memory SQLite database. The second is ```igraph``` which I will use to create and visualize a random network. Some of the work I do is on network simulation. I often don't know the metrics I need from a simulated network when it's created, so I want to be able to store the networks that are created so that I can go back later and analyze them.
library(RSQLite)
library(igraph)
#' Create a database in memory.
con <- dbConnect(SQLite(), ":memory:")
#' The table has two columns, an *id* column and a column called *graph* which is a **blob** type. This type just stores binary data.
@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active May 9, 2024 03:03
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@stephenturner
stephenturner / volcanoplot.r
Last active May 13, 2021 20:11
code from blog post to make a volcano plot
# Download the data from github (click the "raw" button, save as a text file called "results.txt").
# https://gist.github.com/stephenturner/806e31fce55a8b7175af
res <- read.table("results.txt", header=TRUE)
head(res)
# Make a basic volcano plot
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-2.5,2)))
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both)
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red"))
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@pcbulai
pcbulai / .bashrc
Last active November 11, 2021 09:44
.bashrc file with some useful aliases and functions
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
### autocorrects cd misspellings, 'cd /sur/src/linus' >> 'cd /usr/src/linux' ###
@dan-blanchard
dan-blanchard / create_single_machine_sge.md
Last active March 20, 2022 10:40
How to setup a single-machine (Sun) Grid Engine installation for unit tests on Travis-CI

I recently needed a way to run unit tests on Travis for a project that uses Sun Grid Engine, Grid Map. Unfortunately, it seemed like no one had figured out how to set that up on Travis before (or simply create a single-machine installation without any user interaction). After hours of trial-and-error, I now know the secrets to making a single-machine installation of SGE that runs on Travis, and I'm sharing my script to prevent other people from going through the same frustrating experience.

To use the install_sge.sh script below, you just need to copy all of the files in this gist to a travis sub-directory directly under the root of your GitHub project, and add the following lines to your .travis.yml

before_install:
  - travis/install_sge.sh
  - export SGE_ROOT=/var/lib/gridengine
  - export SGE_CELL=default
  - export DRMAA_LIBRARY_PATH=/usr/lib/libdrmaa.so.1.0
@mawaldne
mawaldne / gist:6272854
Last active August 5, 2021 11:33
Read the first line of a file in groovy
def line
new File("test.txt").withReader { line = it.readLine() }
println line
@Glench
Glench / python-async-callback.py
Last active August 2, 2021 10:34
An example of how to vary a parameter for an async callback function in python. Hint: don't use lambda functions in loops!
"""
We want to run a function asychronously and run a
callback function with multiple parameters when it
returns!
In this example, we are pretending we're analyzing
the names and ages of some people. We want to print
out:
jack 0