Skip to content

Instantly share code, notes, and snippets.

@mshwery
mshwery / shynav.js
Last active April 18, 2018 00:27
Shynav Plugin. This is a little plugin that hides/shows the nav based on scrolling. It's decoupled from the styles, so you are left to implement whatever styles meet the needs of a nav when scrolled, detached from the top, and hidden.
$.fn.shynav = function(opts) {
var elem = this;
var defaults = {
delay: 4000, // how long til shynav gets shy
minScroll: $(elem).height() || 0, // how far user scrolls before shynav does its thing
detachedClass: 'scrolled', // what class does the element get when scrolled
hiddenClass: 'hidden' // what class does the element get when hidden
};
@mrdwab
mrdwab / stratifiedDT.R
Last active April 10, 2019 06:29
Attempt to rewrite stratified for `data.table`. The `data.frame` version can be found at https://gist.github.com/mrdwab/6424112
stratifiedDT <- function(indt, group, size, select = NULL,
replace = FALSE, keep.rownames = FALSE,
bothSets = FALSE) {
if (is.numeric(group)) group <- names(indt)[group]
if (!is.data.table(indt)) indt <- as.data.table(
indt, keep.rownames = keep.rownames)
if (is.null(select)) {
indt <- indt
} else {
if (is.null(names(select))) stop("'select' must be a named list")
@busterbenson
busterbenson / markov_tweets.rb
Created September 25, 2013 05:05
How I do @buster_ebooks.
#!/usr/bin/ruby
# Make sure you have these gems installed
require 'rubygems'
require 'thread'
require 'csv'
require 'twitter'
require 'marky_markov'
# Create a new Twitter account that you'd like to have your auto-tweets posted to
@eamartin
eamartin / benchmark.py
Created August 10, 2011 09:10
Python JSON Benchmark
'''cjson, jsonlib, simplejson, and yajl also use C code
demjson did not use C code, but was too painfully slow to benchmark
(took about 20 seconds for these tests)
'''
import json
import sys
import time
with open('doc.json') as f:
@bobthecat
bobthecat / r-tutorial.r
Created August 15, 2012 15:41
R tutorial
### R code from vignette source 'Presentation.Rnw'
### Encoding: UTF-8
###################################################
### code chunk number 1: init
###################################################
options(width=60)
###################################################
@cirrusUK
cirrusUK / pac.sh
Created March 11, 2014 20:48
shell script to show terminal colours, based on the arcade game pacman
#!/bin/sh
# ANSI Color -- use these variables to easily have different color
# and format output. Make sure to output the reset sequence after
# colors (f = foreground, b = background), and use the 'off'
# feature for anything you turn on.
initializeANSI()
{
esc=""
@schakko
schakko / check_microsoft_windows_software_raid.ps1
Last active January 24, 2023 17:24
A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart. The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason) or using the new PowerShell API introduced with Windows 8 (wrong target system as o…
# A simple PowerShell script for retrieving the RAID status of volumes with help of diskpart.
# The nicer solution would be using WMI (which does not contain the RAID status in the Status field of Win32_DiskDrive, Win32_LogicalDisk or Win32_Volume for unknown reason)
# or using the new PowerShell API introduced with Windows 8 (wrong target system as our customer uses a Windows 7 architecture).
#
# diskpart requires administrative privileges so this script must be executed under an administrative account if it is executed standalone.
# check_mk has this privileges and therefore this script must only be copied to your check_mk/plugins directory and you are done.
#
# Christopher Klein <ckl[at]neos-it[dot]de>
# This script is distributed under the GPL v2 license.
@lisamelton
lisamelton / transcode-video.sh
Last active September 8, 2023 23:51
Transcode video file (works best with Blu-ray or DVD rip) into MP4 (or optionally Matroska) format, with configuration and at bitrate similar to popular online downloads.
#!/bin/bash
#
# transcode-video.sh
#
# Copyright (c) 2013-2015 Don Melton
#
about() {
cat <<EOF
$program 5.13 of April 8, 2015
@stevenworthington
stevenworthington / ipak.R
Created July 25, 2012 19:44
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 26, 2024 17:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###