Skip to content

Instantly share code, notes, and snippets.

@adrianmoses
adrianmoses / goquery-example.go
Last active April 20, 2018 03:13
goquery example
package main
/*
* Script that scrapes google front page
* Usage: ./google [<query>]
* e.g. ./google hacker news
*/
import (
"fmt"
@adrianmoses
adrianmoses / 1p_get_item_jq.sh
Created April 9, 2018 18:11
Get item 1p with jq
jq '. | {title: .overview.title, url: .overview.url, username: .details.fields[1].value, password: .details.fields[0].value}'
package main
import (
"fmt"
"reflect"
"encoding/json"
)
type Task struct {
Name string
@adrianmoses
adrianmoses / 0_reuse_code.js
Created April 6, 2017 22:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@adrianmoses
adrianmoses / monty_hall.py
Created August 18, 2016 04:33
Monty Hall Problem
import random
def expose_goat(doors, sel_index):
for i in doors:
if i != sel_index:
choice = doors[sel_index]
if choice == 'goat':
print "Door %s is a goat" % i
return i
factorial = lambda n: reduce(lambda x, y: x * y, range(1, n+1))
(6 * 7 * 24 * 60 * 60) == factorial(10)
#!/bin/sh
while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; cat index.html; } | nc -l 8080; done
# one line function that reverses integers
reverse = lambda n: int(''.join(list(str(n))[::-1]))
plotShares <- function(){
sharesData <- read.csv('shares.csv')
sharesData$Date <- as.Date(sharesData$Date, '%b %d, %Y')
plot(sharesData$Date, sharesData$Shares)
}
module Tackit
class User
def initialize(user, pass)
@user = user
@pass = pass
@token = Token.new.find_token(@user, @pass)
end
def has_token?