Skip to content

Instantly share code, notes, and snippets.

View maxwellE's full-sized avatar
🤔

Maxwell Elliott maxwellE

🤔
View GitHub Profile
{
"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",
@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]];
}
<a href="http://salty-hollows-7859.herokuapp.com/">
@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
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 / 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))
@maxwellE
maxwellE / async_json.java
Created April 2, 2013 18:02
Code for loading red lights needs to be in an async task bc we are using json http request
public void executeAsyncGet(View view) {
AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.put("latitude", "40.192512");
params.put("longitude", "-83.526306");
params.put("distance_in_miles", "10000");
client.get("http://redlights.herokuapp.com/in_proximity_of",params ,new JsonHttpResponseHandler() {
@Override
public void onSuccess(JSONArray red_lights) {
for (int i = 0; i < red_lights.length(); i++) {
@maxwellE
maxwellE / fizz_buzz.rb
Last active December 14, 2015 12:39
FizzBuzz example implementation
class FizzBuzz
def initialize(lower_bound,upper_bound)
@lower_bound = lower_bound
@upper_bound = upper_bound
end
def evaluate
(@lower_bound..@upper_bound).map do |x|
if (x % 5) == 0 && (x % 3) == 0
"FizzBuzz"
elsif (x % 5) == 0
import com.github.kevinsawicki.http.HttpRequest;
public class HTTPCaller {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
@maxwellE
maxwellE / template_ex.js
Created February 26, 2013 00:03
example for jia
// ajax call
req = $.get('/get_assets',{company_id: $(this).dataset.company});
req.success(function(data){
JST['template name']
assets: data
})
//template call
<img src="{{it.assets.pic1}}"<img>