Skip to content

Instantly share code, notes, and snippets.

@larryprice
larryprice / golangTour.go
Last active September 11, 2017 18:22
golang tour exercise solutions
// http://tour.golang.org/
/*
Slide 24: Loops and Functions
*/
package main
import (
"fmt"
"math"
@larryprice
larryprice / client.js
Created July 14, 2014 12:02
Modified Trello client.js for use on Ollert
!function(){var b,c,d,e,f,g,a={version:1,apiEndpoint:"https://api.trello.com",authEndpoint:"https://trello.com"},h=[].slice;g=function(a,b,g){var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;for(n=g.key,s=g.token,j=g.apiEndpoint,k=g.authEndpoint,t=g.version,m=""+j+"/"+t+"/",p=a.location,i={clearReady:function(){e={}},version:function(){return t},key:function(){return n},setKey:function(a){n=a},token:function(){return s},setToken:function(a){s=a},rest:function(){var a,c,d,e;return c=arguments[0],a=2<=arguments.length?h.call(arguments,1):[],e=q(a),d=e[0],a=e[1],g={url:""+m+d,type:c,data:{},dataType:"json",success:e[2],error:e[3]},b.support.cors||(g.dataType="jsonp","GET"!==c&&(g.type="GET",b.extend(g.data,{_method:c}))),n&&(g.data.key=n),s&&(g.data.token=s),null!=a&&b.extend(g.data,a),b.ajax(g)},authorized:function(){return null!=s},deauthorize:function(){s=null,u("token",s)},authorize:function(c){var d,e,h,i,j;if(g=b.extend(!0,{type:"redirect",persist:!0,interactive:!0,scope:{read:!0,write:!1,account:!1},expiration:"30da
@larryprice
larryprice / web_steps.rb
Created August 7, 2014 11:45
web_steps.rb
# Taken from the cucumber-rails project.
require 'uri'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
module WithinHelpers
def with_scope(locator)
locator ? within(locator) { yield } : yield
end
@larryprice
larryprice / twitter_handle_generator.py
Created November 1, 2014 22:22
Daily Programmer Challenge #185
# https://www.reddit.com/r/dailyprogrammer/comments/2jt4cx/10202014_challenge_185_easy_generated_twitter/
import re
p = re.compile('^at')
modified = []
f = open('enable1.txt', 'r')
@larryprice
larryprice / lcs.rb
Last active August 29, 2015 14:17
Longest Common Substring
#!/usr/bin/env ruby
def common?(strings, substring)
strings.each do |s|
return false if !s.include? substring
end
true
end
def possible_sequences(anchor, sequenceLength)
@larryprice
larryprice / Dockerfile
Created June 26, 2015 14:01
Golang dockering with gpm vendoring
FROM golang:1.4
# install gpm
RUN git clone https://github.com/pote/gpm.git /tmp/gpm
WORKDIR /tmp/gpm
RUN ./configure && make install
# sets the working directory to the application source for convenience
ADD . /go/src/github.com/larryprice/myapp
WORKDIR /go/src/github.com/larryprice/myapp
<div id="content" style="margin-bottom: 1.5em;">Welcome</div>
<button id="continue" onclick="nextPage()">
Continue
</button>
<script type="text/javascript" async>
function nextPage() {
var content = document.getElementById("content"),
nextPage = 1;
if (content.innerHTML === "Welcome") {
updatePageContent(nextPage);
@larryprice
larryprice / debounce.js
Last active November 17, 2015 19:32
How does _'s debounce work?
var _ = {};
_.debounce = function (func, wait, immediate) {
var timeout, start, that, args;
var later = function () {
if (Date.now() - start >= wait && !immediate) {
func.apply(that, args);
timeout = null;
}
@larryprice
larryprice / prime.js
Created August 5, 2015 02:04
determine whether a number is prime
if (process.argv.length !== 3) {
console.log("Usage:", process.argv[1], "num")
return;
}
var primeNum = parseInt(process.argv[2]);
if (isNaN(primeNum)) {
console.log("is not even a number, let alone prime");
return;
}
if (process.argv.length !== 3) {
console.log("Usage:", process.argv[1], "num")
return;
}
var garland = function (word) {
var degree = 0;
for (var i = 1; i < word.length; ++i) {
var front = word.slice(0, i);
for (var j = 1; j <= i; ++j) {