Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

View GitHub Profile
@dvliman
dvliman / google-contacts-authsub.html
Created December 28, 2011 08:37 — forked from boazsender/google-contacts-authsub.html
Boilerplate for authsubbing a user to grant permissions to their contacts, and loading in an arbitrary number of their contacts into the page.
<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="http://google.com/jsapi"></script>
<script src="google-contacts-authsub.js"></script>
</head>
<body>
<!-- Google requires an image to be on the page -->
<img src="https://localhost/img/1px.png">
@dvliman
dvliman / rspec-syntax-cheat-sheet.rb
Created January 25, 2012 21:01 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@dvliman
dvliman / api.rb
Created June 22, 2012 21:41 — forked from lucatironi/api.rb
Snippets for an API with grape
# Server App
# This file must be in lib/myapp/api.rb
module MyApp
module Entities
class Products < Grape::Entity
expose :id, :code, :name, :short_description
expose :description, :unless => { :collection => true }
expose (:category) { |model, options| model.category.name }
expose (:brand) { |model, options| model.brand.name }
end
@dvliman
dvliman / sudoku_solver.cpp
Created August 14, 2012 02:31 — forked from keveman/sudoku_solver.cpp
Sudoku solver in C++11
#include <iterator>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <cassert>
#include <memory>
#include <thread>
#include <future>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
@dvliman
dvliman / Encbox.md
Created July 20, 2013 21:04 — forked from Tho85/Encbox.md

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
package main
import (
"crypto/tls"
"net"
"net/http"
"time"
"fmt"
"errors"
)
def to_route(url)
#strip out the /v4/
url = url[4..-1]
dot = url.index('.')
#strip out the extension
url = url[0...dot] unless dot.nil?
parts = url.split('/')
if parts.length == 1
"list #{parts[0]}"
/* Tiny web server in Golang for sharing a folder
Copyright (c) 2010 Alexis ROBERT <alexis.robert@gmail.com>
Contains some code from Golang's http.ServeFile method, and
uses lighttpd's directory listing HTML template. */
package main
import "http"
import "io"
@dvliman
dvliman / README.md
Created October 12, 2013 12:29 — forked from nikcub/README.md