Skip to content

Instantly share code, notes, and snippets.

@glamp
glamp / nodejitsudeployerrorhangup
Created November 3, 2012 13:45
nodejitsu error deploying
info: Creating snapshot 0.0.0-12
info Uploading: [============================ ] 98%
info: Updating app movie-match
info: Activating snapshot 0.0.0-12 for movie-match
info: Starting app movie-match
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error: There was an error while attempting to deploy the app
error:
error: Rackspace Error (404): Item not found
@glamp
glamp / jitsudeployerror2
Created November 3, 2012 14:40
deploy error #2
info: Creating snapshot 0.0.0-15
info Uploading: [=============================] 99%
info: Updating app movie-match
info: Activating snapshot 0.0.0-15 for movie-match
info: Starting app movie-match
error: Error running command deploy
error: socket hang up
info:
jitsu's client request timed out before the server could respond
info: This error may be due to network connection problems
@glamp
glamp / svmflag.py
Last active March 5, 2021 06:59
Plotting SVM predictions using matplotlib and sklearn
import numpy as np
import pylab as pl
import pandas as pd
from sklearn import svm
from sklearn import linear_model
from sklearn import tree
from sklearn.metrics import confusion_matrix
@glamp
glamp / cows_and_wolves.txt
Last active July 3, 2017 14:23
plotting wolf/cow fence boundaries
o o o
o x
o x x x
x o
x x x o
x
o o
o
from sklearn.cluster import AffinityPropagation, KMeans, MiniBatchKMeans
from sklearn.feature_extraction.text import TfidfVectorizer
import odcdata
import pprint as pp
q = "select UPPER(description) as description from odc_bank_transaction limit 1000"
data = odcdata.read_gp_as_dict(q)
descriptions = [row['description'] for row in data]
tfidf = TfidfVectorizer()
@glamp
glamp / sqldf_examples.R
Last active December 12, 2015 09:19
some basic examples of sqldf
library(sqldf)
sqldf("SELECT
day
, avg(temp) as avg_temp
FROM beaver2
GROUP BY
day;")
# day avg_temp
library(plyr)
# split a data frame by Species, summarize it, then convert the results
# into a data frame
ddply(iris, .(Species), summarise,
mean_petal_length=mean(Petal.Length)
)
# Species mean_petal_length
#1 setosa 1.462
#2 versicolor 4.260
library(stringr)
names(iris)
#[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
names(iris) <- str_replace_all(names(iris), "[.]", "_")
names(iris)
#[1] "Sepal_Length" "Sepal_Width" "Petal_Length" "Petal_Width" "Species"
s <- c("Go to Heaven for the climate, Hell for the company.")
str_extract_all(s, "[H][a-z]+ ")
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
db <- dbConnect(drv, dbname="ncaa",
user="YOUR USER NAME", password="YOUR PASSWORD")
q <- "SELECT
*
FROM
game_scores;"
library(lubridate)
year("2012-12-12")
#[1] 2012
day("2012-12-12")
#[1] 12
ymd("2012-12-12")
#1 parsed with %Y-%m-%d
#[1] "2012-12-12 UTC"