Skip to content

Instantly share code, notes, and snippets.

View gwerbin's full-sized avatar
💭
I might be slow to respond.

Greg Werbin gwerbin

💭
I might be slow to respond.
View GitHub Profile
@gwerbin
gwerbin / demo.R
Created July 25, 2014 20:45
PCA & MDS demo
require(spls)
require(MASS)
data(prostate)
pca <- prcomp(prostate$x)
plot(pca$x,main="Principal components mapping of Prostate data",xlab="Dim 1",ylab="dim 2")
plot(pca$x,main="Principal components mapping of Prostate data",xlab="Dim 1",ylab="dim 2",pch=prostate$y+1)
sam <- sammon(dist(prostate$x))
plot(sam$points,main="Sammon mapping of Prostate data",xlab="Dim 1",ylab="Dim 2",pch=prostate$y+1)
<!-- save to <Sublime Text path>/Packages/User/Snippets or anywhere in <Sublime Text path>/Packages/ -->
<!-- with Sublime Text 3 on OSX Mavericks, <Sublime Text path> would be "~/Library/Application Support/Sublime Text 3" -->
<snippet>
<content><![CDATA[
functions{
}
@gwerbin
gwerbin / HTML - all files same name.sublime-build
Created November 16, 2014 17:53
Sublime Text 3 basic HTML system
{
"cmd": ["ls -l *.html"],
"shell": true,
"working_dir": "${project_path:${folder}}",
"selector": ["source.html", "source.javascript", "source.css"],
"osx": {
"cmd": ["open ${file_base_name}.html"],
"shell": true
@gwerbin
gwerbin / housing.sh
Last active August 29, 2015 14:09
Data processing in Bash -- some examples
#!/usr/env bash
## Process the "Housing" data set from the UCI Machine Learning Data Repository
## download the "housing" dataset; this will also tell you how big it is
curl https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data -O
## check if it has carriage returns in line endings
if [[ -z $(egrep -l $'\r$' < housing.data) ]]; then echo 'no CR line endings'
else echo 'has CR line endings'
<!DOCTYPE html>
<html>
<head>
<title>D3 - Line Chart - continuous function</title>
<!-- script type="text/javascript" src="https://raw.github.com/jquery/sizzle/master/sizzle.js"></script -->
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.min.js"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.time.min.js"></script>
<style type="text/css">
body {
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@gwerbin
gwerbin / Open in iTerm.scpt
Last active August 29, 2015 14:19
In Automator, create a new Workflow, add action Run Applescript, and replace the contents of the text box with this entire file. At the top, where it says "Service receives selected ___ in ___" select "Files or Folders" in the first drop-down menu, and "Finder.app" in the second. You can set a keyboard shortcut in System Preferences -> Keyboard …
on run {input, parameters}
tell application "Finder"
set currentSelection to selection
set currentFolder to target of front Finder window as text
end tell
tell application "iTerm" -- this should work if you replace "iTerm" with "Terminal" (untested)
if currentSelection = {} then
set thePath to POSIX path of currentFolder
@gwerbin
gwerbin / pandas-sklearn-workflow.py
Last active August 29, 2015 14:23
mini-API for comparing models
import numpy as np
import pandas as pd
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.pipeline import Pipeline
seed = 43770
rng = np.random.RandomState(seed)
@gwerbin
gwerbin / uninstall-ghostscript.sh
Last active August 18, 2023 07:52
Uninstall Ghostscript that comes with MacTex.
#!/usr/bin/env bash
# Copyright (c) 2015, 2020, and 2021 by Greg Werbin.
#
# Permission to use, copy, modify, and/or distribute this software for any purpose with
# or without fee is hereby granted, provided that the above copyright notice and this
# permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
# SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT