This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'rubygems' | |
require "dm-migrations" | |
require 'sinatra-authentication' | |
require 'sinatra/authorization' | |
download_base = './Downloads' | |
set :authorization_realm, "download" | |
configure do | |
set :template_engine, :erb # for example | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IssueResource < ActiveResource::Base | |
self.element_name = "issue" | |
self.user="admin" | |
self.password="admin" | |
self.site = "http://localhost:3000" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
type ErrNegativeSqrt float64 | |
func (e ErrNegativeSqrt) Error() string { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"golang.org/x/tour/reader" | |
) | |
type MyReader struct{} | |
type MyError string | |
// TODO: Add a Read([]byte) (int, error) method to MyReader. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"os" | |
"strings" | |
) | |
type rot13Reader struct { | |
rot io.Reader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer