Skip to content

Instantly share code, notes, and snippets.

@1995eaton
1995eaton / main.py
Created April 5, 2014 22:57
Imgur Album Downloader
#!/usr/bin/env python
#
# Usage ./main.py <imgur_album_url>
#
from requests import get
from re import sub
from sys import argv
from os import listdir, mkdir, chdir
@1995eaton
1995eaton / puush.js
Created April 19, 2014 07:49
A puu.sh image searcher
function toBase(c, s) {
var l = c.length,
_ret = "";
while (s !== 0) {
_ret += c[s % l];
s = Math.floor(s / l);
}
return _ret.split("").reverse().join("");
}
@1995eaton
1995eaton / 162.js
Last active August 29, 2015 14:01
/r/dailyprogrammer problem #162 [easy + intermediate + hard]
#!/usr/bin/env node
// See http://www.reddit.com/r/dailyprogrammer/comments/25o2bd/5162014_challenge_162_hard_novel_compression_pt_3/
// Usage:
// ./162 -c input.txt -o compressed.txt
// ./162 -d compressed.txt -o output.txt
var fs = require("fs");
var stdio = require("stdio"); // npm install stdio
@1995eaton
1995eaton / 163.js
Created May 27, 2014 03:06
/r/dailyprogrammer problem #163 [hard + challenge]
function intersecting(a, b, c, d) {
var intersection = [((a[0] * b[1] - a[1] * b[0]) * (c[0] - d[0]) - (a[0] - b[0]) * (c[0] * d[1] - c[1] * d[0])) /
((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) * (c[0] - d[0])),
((a[0] * b[1] - a[1] * b[0]) * (c[1] - d[1]) - (a[1] - b[1]) * (c[0] * d[1] - c[1] * d[0])) /
((a[0] - b[0]) * (c[1] - d[1]) - (a[1] - b[1]) * (c[0] - d[0]))];
function between(a, b, c) {
return c >= Math.min(a, b) && c <= Math.max(a, b);
}
if (between(a[0], b[0], intersection[0]) &&
between(c[0], d[0], intersection[0]) &&
@1995eaton
1995eaton / upvoteDownvote.js
Last active August 29, 2015 14:02
A userscript that adds upvotes and downvotes to reddit comments (similar to RedditEnhancementSuite)
function formatComments() {
var commments = document.querySelectorAll("div[data-ups]");
for (var i = 0, l = commments.length; i < l; ++i) {
var data = commments[i];
var likes = data.getAttribute("data-ups");
var dislikes = data.getAttribute("data-downs");
if (likes !== undefined && dislikes !== undefined) {
var post = data.querySelector(".entry.unvoted");
if (post && !post.querySelector(".wooo")) {
// Important updates:
// #6 - load function works as intended
// #8 - core functionality works with loading questions and calculating scores
// #9 - completion of task
var Quiz = {
questions: [
{title: "How many hairs are on a pony?", choices: ["0", "1", "2", "More than two"], correctAnswer: 3},
{title: "Who lives in the Barbie Dream House?", choices: ["Barbie & Ken", "Peter & Mary", "Ben & Jerry", "It is an empty house"], correctAnswer: 0}
@1995eaton
1995eaton / powerline.vim
Created June 11, 2014 17:43
Vim Powerline
function! GetModeName(mode)
if a:mode ==# "n"
return "NORMAL"
elseif a:mode ==# "i"
return "INSERT"
elseif a:mode ==# "V"
return "VISUAL LINE"
elseif a:mode ==# "v"
return "VISUAL"
elseif a:mode ==# ""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hex Time</title>
<style>
body {
transition: background-color 0.2s ease-out;
-webkit-transition: background-color 0.2s ease-out;
-moz-transition: background-color 0.2s ease-out;
@1995eaton
1995eaton / index.html
Created June 21, 2014 18:01
Lot's of links
<a href="#1">1</a> <a href="#2">2</a> <a href="#3">3</a> <a href="#4">4</a> <a href="#5">5</a> <a href="#6">6</a> <a href="#7">7</a> <a href="#8">8</a> <a href="#9">9</a> <a href="#10">10</a> <a href="#11">11</a> <a href="#12">12</a> <a href="#13">13</a> <a href="#14">14</a> <a href="#15">15</a> <a href="#16">16</a> <a href="#17">17</a> <a href="#18">18</a> <a href="#19">19</a> <a href="#20">20</a> <a href="#21">21</a> <a href="#22">22</a> <a href="#23">23</a> <a href="#24">24</a> <a href="#25">25</a> <a href="#26">26</a> <a href="#27">27</a> <a href="#28">28</a> <a href="#29">29</a> <a href="#30">30</a> <a href="#31">31</a> <a href="#32">32</a> <a href="#33">33</a> <a href="#34">34</a> <a href="#35">35</a> <a href="#36">36</a> <a href="#37">37</a> <a href="#38">38</a> <a href="#39">39</a> <a href="#40">40</a> <a href="#41">41</a> <a href="#42">42</a> <a href="#43">43</a> <a href="#44">44</a> <a href="#45">45</a> <a href="#46">46</a> <a href="#47">47</a> <a href="#48">48</a> <a href="#49">49</a> <a href="#50"
<!DOCTYPE html>
<html>
<head>
<style>
html, body {
-webkit-font-smoothing: subpixel-antialiased;
}
#links {
display: block;
color: #ddd;