Skip to content

Instantly share code, notes, and snippets.

View maxwellE's full-sized avatar
🤔

Maxwell Elliott maxwellE

🤔
View GitHub Profile
@maxwellE
maxwellE / Euler.hs
Created May 20, 2013 02:38
Haskell List Monad Example
import Control.Monad
import Data.List
import Primes
primes4 = takeWhile (<10000) $ dropWhile (<1000) primes
result = do
a <- primes4
b <- dropWhile (<= a) primes4
guard ((sort $ show a) == (sort $ show b))
namespace :generate do
desc 'Generate FLMS views in host app for additional styling'
task :views do
host_view_dir = File.expand_path("../../../app/views/flms/*", __FILE__)
unless Dir.exists?("app/views/flms")
FileUtils.mkdir "app/views/flms"
FileUtils.cp_r Dir[host_view_dir], "app/views/flms/"
end
end
end
@maxwellE
maxwellE / gumroad_oauth.rb
Created December 9, 2013 23:33
Gumroad OAuth2 sample code, uses the OAuth2 Gem https://github.com/intridea/oauth2
require 'oauth2'
client = OAuth2::Client.new('client_id', 'client_secret', :site => 'https://example.org')
client.auth_code.authorize_url(:redirect_uri => 'http://localhost:8080/oauth2/callback')
# => "https://example.org/oauth/authorization?response_type=code&client_id=client_id&redirect_uri=http://localhost:8080/oauth2/callback"
token = client.auth_code.get_token('authorization_code_value', :redirect_uri => 'http://localhost:8080/oauth2/callback', :headers => {'Authorization' => 'Basic some_password'})
response = token.get('/api/resource', :params => { 'query_foo' => 'bar' })
response.class.name
# => OAuth2::Response
<a href="http://salty-hollows-7859.herokuapp.com/">
@maxwellE
maxwellE / keygen.m
Last active August 29, 2015 14:03
Array based key generation
// Array of ordinals (ASCII character posistions)
NSArray *keyStringCharacterOrdinals = @[@99, @109,.....];
NSMutableString *keyString = [[NSMutableString alloc] initWithCapacity:keyStringCharacterOrdinals.count];
for (NSNumber *characterOrdinal in keyStringCharacterOrdinals) {
[keyString appendString:[NSString stringWithFormat:@"%c", characterOrdinal.intValue]];
}
{
"cards":[
{
"type":"place",
"title":"McDonald's",
"imageURL":"http://upload.wikimedia.org/wikipedia/commons/thumb/1/17/DowneyMcdonalds.jpg/240px-DowneyMcdonalds.jpg",
"placeCategory":"Fast Food"
},
{
"type":"movie",