Skip to content

Instantly share code, notes, and snippets.

Avatar

Peadar Coyle springcoil

View GitHub Profile
@springcoil
springcoil / gist:3231352
Created Aug 1, 2012 — forked from swannodette/gist:3217582
sudoku_compact.clj
View gist:3231352
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
(defn init [vars hints]
@springcoil
springcoil / gist:5480336
Created Apr 29, 2013
Python Traceback error, from Ipython code. Basically I attempted to replicate by writing myself the Sean J.Taylor code.
View gist:5480336
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-34-180a07193cfb> in <module>()
21 for eval_name, evaluation in evaluations.iteritems():
22 for year in range(2002, 2013):
---> 23 metric = evaluation(ranker, year)
24 results.append({
25 'rank': name,
<ipython-input-34-180a07193cfb> in <lambda>(rank, year)
@springcoil
springcoil / Fizzbuzz.py
Created Apr 9, 2014
Fizz Buzz in one line in python
View Fizzbuzz.py
for x in range(100): print x%3/2*'Fizz'+x%5/4*'Buzz' or x+1
@springcoil
springcoil / MongoDB_Experiment_IPython
Created May 21, 2014
IPython Notebook - for MongoDB
View MongoDB_Experiment_IPython
{
"metadata": {
"name": "",
"signature": "sha256:2c5a94596837b925899f0aab294f5a5d31a0c6227abf97c00b871ecbe116bcdf"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@springcoil
springcoil / Postgres_Fun
Created Jun 18, 2014
CSVKit and PostgreSQL
View Postgres_Fun
csvsql --db postgresql:///test1 --insert Problem_Set_Operations_Research.csv
# I was having some trouble getting a csv file inserted into a Postgres Database. The above line worked.
\dt
#Shows the tables in a particular database
\connect test1
#Connects to a database with a particular name in the case above "test1"
View pandas_dbms.py
# -*- coding: utf-8 -*-
"""
LICENSE: BSD (same as pandas)
example use of pandas with oracle mysql postgresql sqlite
- updated 9/18/2012 with better column name handling; couple of bug fixes.
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle.
to do:
save/restore index (how to check table existence? just do select count(*)?),
finish odbc,
@springcoil
springcoil / datascienceRscript
Created Aug 19, 2014
Coursera UW: Introduction to Data Science
View datascienceRscript
install.packages("caret")
install.packages("rpart")
install.packages("tree")
install.packages("randomForest")
install.packages("e1071")
install.packages("ggplot2")
table <- read.csv("DataSciIntro/assignment5//seaflow_21min.csv")
library("caret")
library("rpart")
@springcoil
springcoil / datascienceRscript
Created Aug 19, 2014
Coursera UW: Introduction to Data Science
View datascienceRscript
install.packages("caret")
install.packages("rpart")
install.packages("tree")
install.packages("randomForest")
install.packages("e1071")
install.packages("ggplot2")
table <- read.csv("DataSciIntro/assignment5//seaflow_21min.csv")
library("caret")
library("rpart")
@springcoil
springcoil / Logistic_Regression_Kzggle.py
Last active Apr 7, 2016
Logistic_Regression_Kaggle
View Logistic_Regression_Kzggle.py
__author__ = 'Miroslaw Horbal'
__email__ = 'miroslaw@gmail.com'
__date__ = '14-06-2013'
from numpy import array, hstack
from sklearn import metrics, cross_validation, linear_model
from scipy import sparse
from itertools import combinations
import numpy as np
View installpythonframeworks.sh
#!/bin/bash
virtualenv .env &&
source .env/bin/activate &&
sudo apt-get install -y libevent-dev &&
sudo apt-get install -y libyaml-0-2 &&
sudo apt-get install --yes --force-yes automake autoconf libtool* gfortran &&
sudo apt-get install --yes --force-yes liblapack-dev &&
sudo apt-get install --yes --force-yes binutils &&
sudo apt-get install -y libatlas-dev &&
sudo apt-get install -y build-essential --upgrade &&