This file contains 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 'win32ole' | |
require 'pathname' | |
require 'chronic' | |
excel = WIN32OLE.new('Excel.Application') | |
excel.visible = false | |
# Print header line | |
header = %w(Date Subprime_1yr Subprime_2yr Subprime_3yr Subprime_5yr Subprime_7+yr Prime_03-04_15yrPT Prime_03-04_30yrPT Prime_03-04_5/1PT Prime_03-04_10/1PT Prime_06-07_15yrPT Prime_06-07_30yrPT Prime_06-07_5/1PT Prime_06-07_10/1PT) | |
puts header.join(",").gsub("_", " ") |
This file contains 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
Sub formatChartInFimsStyle() | |
Dim myChart As Chart | |
Set myChart = ActiveChart | |
' Set width and height | |
myChart.ChartArea.Height = 158 | |
myChart.ChartArea.Width = 230 | |
myChart.ChartArea.Format.Line.Visible = msoFalse | |
This file contains 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
=DATE(LEFT(B2,4),MID(B2,5,2),RIGHT(B2,2)) |
This file contains 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
(function($) { | |
window.Album = Backbone.Model.extend({ | |
isFirstTrack: function(index) { | |
return index == 0; | |
}, | |
isLastTrack: function(index) { | |
return index >= this.get('tracks').length - 1; | |
}, |
This file contains 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 "crack" | |
require "json" | |
files = File.read("files.txt").split("\n") | |
files.each { |filename| | |
filename = filename.strip | |
next if filename.empty? | |
myXML = Crack::XML.parse( File.read(filename) ) |
This file contains 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 'hmac-sha1' | |
require 'base64' | |
require 'cgi' | |
module OauthHelper | |
def URLEscape(text) | |
return CGI.escape(text).gsub("+", "%20") | |
end | |
This file contains 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 NestedDict(dict): | |
def __getitem__(self, key): | |
if key in self: return self.get(key) | |
return self.setdefault(key, NestedDict()) |
This file contains 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
oauth_request_url, oauth_token, oauth_token_secret = generate_request_token() | |
# save oauth_token and oauth_token_secret to @user | |
redirect_to oauth_request_url |
This file contains 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 OAuthController < ApplicationController | |
def authenticate | |
oauth_token = params[:oauth_token] | |
oauth_verifier = params[:oauth_verifier] | |
@user = User.find_by_oauth_token(oauth_token) | |
if !@user | |
# Do something appropriate, such as a 404 | |
else | |
begin |
This file contains 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
- (void)reposition { | |
// https://developer.apple.com/library/ios/#qa/qa2010/qa1688.html | |
// tl;dr Only the first subview in the window receives orientation changes. | |
// So we apply a transform manually to rotate the view, and change the origin of the frame so | |
// that it remains in a top-center position for the user. | |
UIInterfaceOrientation orientation = | |
[UIApplication sharedApplication].statusBarOrientation; | |
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; | |
CGAffineTransform viewTransform = CGAffineTransformIdentity; |
OlderNewer