Skip to content

Instantly share code, notes, and snippets.

@itsmikeq
itsmikeq / rdd.md
Created October 29, 2015 01:48 — forked from kenchung/rdd.md
Resume Driven Development Challenge

Resume Driven Development Challenge

Using the Github Archive API, create a command-line tool to find popular repos to add lots of hipster acronyms to your resume!

It should support a date range in the past in case time travel becomes possible and you decide to go back and learn different things.

You should use Ruby or Javascript based on the role you are being considered for.

Given the date range, you'll collect event data from the Github Archive and give each repo a popularity score.

@itsmikeq
itsmikeq / live_database_dump.rb
Last active September 11, 2015 20:01 — forked from njakobsen/live_database_dump.rb
Live stream a database dump (or any other STDOUT) using Rails 4. Why would you want this? If you have a large database dump and want to avoid storing it in memory as Rails streams it. This allows pipe the dump directly into the http response instead of storing it as a file, sending it, and then deleting it. Let me know what you think! I've teste…
class DatabaseController < ApplicationController
def database_dump
database = Rails.configuration.database_configuration[Rails.env]["database"]
send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup")
pipe = IO.popen("pg_dump '#{database}' -F c")
stream = response.stream
while (line = pipe.gets)
stream.write line
sleep 0.0001 # HACK: Prevent server instance from sleeping forever if client disconnects during download
@itsmikeq
itsmikeq / LocalStorage.js
Created August 30, 2015 01:39
JavaScript local storage
Storage.prototype.setObject = function (_key, _value) {
return this.setItem(_key, JSON.stringify({timestamp: new Date().getTime(), data: _value }));
};
// Clears stuff older than 2 hours
Storage.prototype.clearOld = function () {
_t_date = new Date().getTime();
for (var i = 0; i < Storage.prototype.length; i++) {
if ((_t_date - this.key(i).timestamp) > 7200) {
this.removeItem(this.key(i));
@itsmikeq
itsmikeq / collapsed-bootstrap-nav.scss
Created June 11, 2015 14:27
bootstrap css for collapsed navbar
body {
padding-top:70px;
}
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
rot io.Reader
package main
import (
"golang.org/x/tour/reader"
)
type MyReader struct{}
type MyError string
// TODO: Add a Read([]byte) (int, error) method to MyReader.
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
@itsmikeq
itsmikeq / API.swift
Last active August 29, 2015 14:12 — forked from higepon/API.swift
//
// API.swift
//
// Created by Taro Minowa on 6/10/14.
// Copyright (c) 2014 Higepon Taro Minowa. All rights reserved.
//
import Foundation
typealias JSONDictionary = Dictionary<String, AnyObject>
@itsmikeq
itsmikeq / gist:5752955
Last active December 18, 2015 08:19
Accessing an Atom feed behind Site Minder
#!perl
#
# Example script to connect to an ATOM feed behind SiteMinder
# Usage: feed_parser.pl <username> <password> <url>
# URL Can also be copied and pasted from the Atom feed link at the bottom
# of any project
#
#
use strict;
@itsmikeq
itsmikeq / IssueResource.rb
Created January 6, 2013 17:36
Class for connecting to remote Redmine Instance
class IssueResource < ActiveResource::Base
self.element_name = "issue"
self.user="admin"
self.password="admin"
self.site = "http://localhost:3000"
end