Skip to content

Instantly share code, notes, and snippets.

View maccam912's full-sized avatar

Matthew Koski maccam912

View GitHub Profile
@maccam912
maccam912 / sudoku.cpp
Created December 10, 2012 04:53
Solution to HackerRank Olympics sudoku puzzle in C++
#include<iostream>
#include<vector>
#include<set>
#include<math.h>
using namespace std;
int getSector(int row, int col) {
return (row/3)*3+(col/3);
}
@maccam912
maccam912 / shortersudoku.cpp
Created December 10, 2012 05:24
Minified version of my solution to the HackerRank Olympics sudoku puzzle in C++
#include<iostream>
#include<set>
#include<math.h>
#define G(i,j) g[i][j]
using namespace std;int s(int r,int c){return (r/3)*3+(c/3);}bool v(int G(9,9),int r,int c){for (int i=0;i<9;i++){if (G(r,i)==G(r,c)&&i!=c) return false;if (G(i,c)==G(r,c)&&i!=r) return false;}for (int i=0;i<9;i++){for (int j=0;j<9;j++){if (s(r,c)==s(i,j)&&r!=i&&c!=j&&G(i,j)==G(r,c)) return false;}}return true;}void v(int g[9][9],set<int> y){int f=1;for (int z=0;z<81;){int r=z/9;int c=fmod(z,9);if (y.count(z)>0){z+=1*f;}else{G(r,c)++;if (G(r,c)==10){G(r,c)=0;f=-1;z--;}if (v(g,r,c)){f=1;z++;}}}for (int i=0;i<9;i++){for (int j=0;j<9;j++){cout<<G(i,j)<<" ";}cout<<endl;}}int main(){int n,G(9,9);set<int> y;cin >> n;for(int i=0;i<n;i++){for(int j=0;j<9;j++){for(int k=0;k<9;k++){G(j,k)=0;cin>>G(j,k);if (G(j,k)!=0) y.insert(j*9+k);}}v(g,y);}return 0;}
@maccam912
maccam912 / tahoe-node.sh
Last active August 29, 2015 14:11
Start tahoe-node based on maccam912/docker-tahoe
docker run -it -p 3456:3456 -p 39499:39499 maccam912/tahoe-node /tahoe-run.sh

Keybase proof

I hereby claim:

  • I am maccam912 on github.
  • I am koski (https://keybase.io/koski) on keybase.
  • I have a public key whose fingerprint is 5337 CC60 431F 08EA CA81 620F 314D D79F 55E4 F8A3

To claim this, I am signing this object:

@maccam912
maccam912 / chocolatey-install
Created June 4, 2015 15:35
Install a bunch of useful packages with chocolatey on windows
cinst -y flashplayerplugin googlechrome git.install flashplayeractivex javaruntime git notepadplusplus.install f autohotkeyirefox 7zip.install notepadplusplus 7zip atom vlc 7zip.commandline nodejs.install ccleaner autohotkey.portable sysinternals vcredist2010 ruby nodejs skype filezilla dotnet4.5 putty vim python dropbox mysql.workbench nuget.commandline putty.portable virtualbox fiddler svn hg wget curl boxstarter adobeair teamviewer console2 winscp silverlight keepass.install cygwin tortoisesvn phantomjs keepass wireshark sourcetree jdk8 jre8 winrar opera ruby.devkit tortoisegit vagrant foxitreader winpcap autohotkey.install autohotkey pip easy.install puppet maven launchy tortoisehg githubforwindows yeoman nmap brackets putty.install sourcecodepro sublimetext3.packagecontrol gow expresso cpu-z erlang ffmpeg ack silverlight winscp msysgit grepwin everything truecrypt virtualbox.extensionpack daemontoolslite golang r.project owncloud-client r.studio androidstudio visualstudiocode VisualStudio2013Ultimate -I
@maccam912
maccam912 / apm
Created June 5, 2015 17:27
apm packages
apm install hydrogen linter seti-ui seti-syntax vim-mode ex-mode atom-beautify minimap emmet js-autoimport autoclose-html settings-view language-java linter-javac javascript-refactoring pepper-autocomplete linter-clojure linter-cpplint ide-haskell haskell-ghc-mod language-haskell haskell-grammar autocomplete-haskell linter-hlint helium atom-lint hash-n ask-stack ide-haskell ide-flow
@maccam912
maccam912 / hostssetterupper.sh
Last active August 29, 2015 14:26
Used as a post-install script in openstack to set the correct hostname
#!/bin/sh
set -e -x
sed -i 's/^127.0.1.1.*$//g' /etc/hosts
echo "$(curl icanhazip.com) $(hostname)" >> /etc/hosts
@maccam912
maccam912 / gist:9589b37c65439416ec68
Last active November 17, 2015 15:53
Packages needed to build tensorflow on ubuntu
apt-get install git curl wget python-dev python-virtualenv gfortran libc-bin build-essential unzip zlib1g-dev zip oracle-java8-installer python-numpy swig python-dev
/**
* Created by maccam912 on 11/9/15.
*/
import org.apache.spark
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import org.apache.spark.rdd.RDD
import org.apache.spark.
#!/bin/bash
# Run this on This AMI on AWS:
# https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-b36981d8
# You should get yourself a fully working GPU enabled tensorflow installation.
cd ~
# grab cuda 7.0