Skip to content

Instantly share code, notes, and snippets.

@willurd
willurd / web-servers.md
Last active June 13, 2024 14:37
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@byzheng
byzheng / xlsxToR.r
Last active March 20, 2019 06:54 — forked from schaunwheeler/xlsxToR.r
Thanks @schaunwheeler codes to read xlsx files. I had remove all dependence and parse the xml files with text regular expression. It will be much faster to read large xlsx files.
#' Read xlsx files
#'
#' @param file The path to xlsx file
#' @param keep_sheets A vector of sheet name
#' @param header Whether include the head in the sheet
#' @param empty_row Whether to remove the empty rows
#' @export
xlsxToR <- function(file, keep_sheets = NULL, header = TRUE, empty_row = TRUE)
{
suppressWarnings(file.remove(tempdir()))
# here's some sample data to test it out
require(data.table)
require(dplyr)
set.seed(45)
DF <- data.frame(x=sample(3, 25, TRUE), y=1:25, z=26:50)
DP <- tbl_df(DF) # for DPLYR data.frame object
DT <- data.table(DF)
# 1) row-wise subset (usually based on conditions):
@brodieG
brodieG / data.table.standard.eval.R
Last active April 8, 2020 11:02
Corner Cases With Non-Standard Evaluation in data.table
# Because there is no way to tell data.table
# "interpret this variable as a column name", it's possible to come up
# with corner cases. I'll grant these are unlikely to occur in day
# to day use, but any function that uses `data.table` must account for
# them
# Low odds, and yes, there are workarounds, but this is
# what I mean by you have to think carefully to avoid
# corner cases
@Pakillo
Pakillo / git-github-tutorials.md
Last active July 8, 2023 13:51
Git & GitHub tutorials
@Pakillo
Pakillo / Rprogramming-syllabus.md
Last active September 13, 2016 15:32 — forked from hadley/curriculum.md
R programming syllabus by Hadley Wickham

Notes:

  • I've tried to break up in to separate pieces, but it's not always possible: e.g. knowledge of data structures and subsetting are tidy intertwined.

  • Level of Bloom's taxonomy listed in square brackets, e.g. http://bit.ly/15gqPEx. Few categories currently assess components higher in the taxonomy.

Programming R curriculum

Data structures

@upsuper
upsuper / bind-backup.sh
Last active March 13, 2024 17:08
Script to automatically bind and unbind external USB drive on Synology NAS
#!/bin/bash
SERIAL="00000000"
echo "Looking for device with serial $SERIAL..."
for d in /sys/bus/usb/devices/*-*; do
if [[ -f "$d/serial" ]]; then
serial=$(<"$d/serial")
if [[ "$serial" = "$SERIAL" ]]; then
device="$(basename $d)"
@nacnudus
nacnudus / data.table-joins.R
Created August 21, 2017 09:20
How to do joins with data.table
library(data.table)
?`[.data.table`
DT <- data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6), v=1:9)
X <- data.table(x=c("c","b"), v=8:7, foo=c(4,2))
colnames(DT)
# [1] "x" "y" "v"
@fuzziebrain
fuzziebrain / sql.bat
Created January 8, 2018 15:48
Oracle SQLcl sql.bat fixed
@echo off
REM ########################################################################
REM # (@)sql.bat
REM #
REM # Copyright 2014 by Oracle Corporation,
REM # 500 Oracle Parkway, Redwood Shores, California, 94065, U.S.A.
REM # All rights reserved.
REM #
REM # This software is the confidential and proprietary information
REM # of Oracle Corporation.
@hjbotha
hjbotha / free_ports.sh
Last active June 4, 2024 15:57
Free ports 80 and 443 on Synology NAS
#! /bin/bash
# NEWLY ADDED BACKUP FUNCTIONALITY IS NOT FULLY TESTED YET, USE WITH CARE, ESPECIALLY DELETION
# Developed for DSM 6 - 7.0.1. Not tested on other versions.
# Steps to install
# Save this script in one of your shares
# Edit it according to your requirements
# Backup /usr/syno/share/nginx/ as follows:
# # cd /usr/syno/share/
# # tar cvf ~/nginx.tar nginx