Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / retropi.txt
Last active May 12, 2016 20:47
Steps for setting up RetroPi on the Raspberry Pi 2.
1. Plug-in wifi, usb keyboard, power cord. Power up Pi.
2. Login with: pi/raspberry
3. Follow steps to install RetroPi at http://www.emulationstation.org/gettingstarted.html#install_rpi_retropie
sudo apt-get update
sudo apt-get install git dialog
cd
git clone --depth=0 https://github.com/petrockblog/RetroPie-Setup
cd RetroPie-Setup
chmod +x retropie_setup.sh
sudo ./retropie_setup.sh
@primaryobjects
primaryobjects / atbash.R
Last active February 21, 2016 18:42
[2016-02-16] Challenge #254 [Easy] Atbash Cipher
#
# [2016-02-16] Challenge #254 [Easy] Atbash Cipher
# https://www.reddit.com/r/dailyprogrammer/comments/45w6ad/20160216_challenge_254_easy_atbash_cipher/
# Demo: http://www.r-fiddle.org/#/fiddle?id=OBWeefV6&version=1
#
# Atbash encodes a string by reversing the alphabet and then substituting the letters in the string with the reversed form alphabet.
# Example
# Plain: abcdefghijklmnopqrstuvwxyz
# Cipher: zyxwvutsrqponmlkjihgfedcba
# foobar -> ullyzi
@primaryobjects
primaryobjects / othello.R
Last active February 20, 2016 16:20
[2016-02-17] Challenge #254 [Intermediate] Finding Legal Othello (Reversi) Moves
#
# [2016-02-17] Challenge #254 [Intermediate] Finding Legal Reversi Moves
# https://www.reddit.com/r/dailyprogrammer/comments/468pvf/20160217_challenge_254_intermediate_finding_legal/
# Demo: http://www.r-fiddle.org/#/fiddle?id=qBVAmIPB&version=2
#
# Find all valid moves on a board in Othello (Reversi).
#
# Kory Becker 2/20/2016
# http://primaryobjects.com
#
@primaryobjects
primaryobjects / winequality.R
Last active March 28, 2018 08:39
Wine Quality Dataset Prediction Analysis using R and caret
packages <- c('caret')
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
install.packages(setdiff(packages, rownames(installed.packages())))
}
library(caret)
# Download dataset, if it does not exist.
fileName <- 'winequality-red.csv';
if (!file.exists(fileName)) {
download.file(paste0('https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/', fileName), fileName, method="curl")
@primaryobjects
primaryobjects / markov.R
Last active March 31, 2020 04:21
Generating text with a markov chain in R.
library(markovchain)
text <- readLines('text.txt')
text <- text[nchar(text) > 0]
text <- gsub('.', ' .', text, fixed = TRUE)
text <- gsub(',', ' ,', text, fixed = TRUE)
text <- gsub('!', ' !', text, fixed = TRUE)
text <- gsub('(', '( ', text, fixed = TRUE)
text <- gsub(')', ' )', text, fixed = TRUE)
@primaryobjects
primaryobjects / slack.js
Created March 11, 2016 22:23
Example Slack chatbot in node.js
var SlackBot = require('slackbots');
BotManager = {
bot: null,
initialize: function() {
// Get token at https://my.slack.com/services/new/bot.
BotManager.bot = new SlackBot({ token: 'slack-api-token', name: 'mybot' });
BotManager.bot.on('start', BotManager.start);
@primaryobjects
primaryobjects / slack.js
Last active July 13, 2017 16:18
Example Slack chatbot running chatskills.
var chatskills = require('chatskills');
var SlackBot = require('slackbots');
var bot = new SlackBot({ token: 'your-slack-token', name: 'awesome' });
// Set bot name.
chatskills.name('awesome');
// Create a new skill.
var hello = chatskills.add('hello');
@primaryobjects
primaryobjects / irc.py
Created March 18, 2016 03:10
A simple IRC client written in Python.
#
# [2016-03-14] Challenge #258 [Easy] IRC: Making a Connection
# https://www.reddit.com/r/dailyprogrammer/comments/4ad23z/20160314_challenge_258_easy_irc_making_a/
#
import socket
input = """chat.freenode.net:6667
dude1267
dude1267
@primaryobjects
primaryobjects / xgboost.R
Created March 25, 2016 18:26
Example using xgboost to model Santander data.
# https://www.kaggle.com/fsimond/santander-customer-satisfaction/santander-starter/run/172126/files
library(xgboost)
library(Matrix)
set.seed(1234)
train <- read.csv("train.csv")
test <- read.csv("test.csv")
##### Removing IDs
@primaryobjects
primaryobjects / nnet.R
Created March 28, 2016 19:53
Neural network (nnet) with caret and R. Machine learning classification example, includes parallel processing.
library(caret)
library(doParallel)
registerDoParallel(cores = 2)
# Read data.
data <- read.csv('train.csv')
test <- read.csv('test.csv')
# Set classification column to factor.