Skip to content

Instantly share code, notes, and snippets.

Kenn Ejima kenn

  • San Francisco
Block or report user

Report or block kenn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:f2a0d1f52358b9b2770b
199.91.171.93 bb-m.rubygems.org
54.186.104.15 api.rubygems.org rubygems.org
@kenn
kenn / staging.rb
Created Sep 14, 2014
config/environments/staging.rb
View staging.rb
require Rails.root.join('config/environments/production')
MyApp::Application.configure do
config.action_dispatch.tld_length = 2 # domain.com vs staging.domain.com
end
View gist:67730a44a0dc5078defd
#pragma mark - Original
- (NSURLSessionDataTask *)GET:(NSString *)URLString
parameters:(id)parameters
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;
#pragma mark - Overrides
- (NSURLSessionDataTask *)GET:(NSString *)URLString
View gist:fd4cc798804508c3de6d
# cat auth.log | grep Failed | grep root | cut -d ' ' -f 11 | sort | uniq
111.74.238.101
111.74.238.103
111.74.238.104
111.74.238.124
111.74.238.138
111.74.238.151
111.74.238.152
111.74.238.153
111.74.238.167
View gist:c59256c77af5fc03b241
mysql> explain SELECT * FROM messages USE INDEX (index_messages_on_friend_id_and_id) WHERE friend_id = 100 AND (id < 1000000) ORDER BY id DESC LIMIT 10\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: messages
type: range
possible_keys: index_messages_on_friend_id_and_id
key: index_messages_on_friend_id_and_id
key_len: 8
ref: NULL
@kenn
kenn / doorkeeper.rb
Created Jun 6, 2014
Doorkeeper client_secret obfuscation
View doorkeeper.rb
# config/initializers/doorkeeper.rb
Doorkeeper.configure do
client_credentials :from_obfuscated_params
end
module Doorkeeper
module OAuth
class Client
module Methods
def from_obfuscated_params(request)
View gist:b122e4ee58c513cbc7a3
import Foundation
class Foo : NSObject {
convenience init() {
self.init()
}
}
@kenn
kenn / gist:51af188d35dac8069313
Last active Aug 29, 2015
DigitalOcean Disk Performance (May 2014)
View gist:51af188d35dac8069313

Degradation of DigitalOcean Disk Performance

DigitalOcean's disk performance got order of magnitude worse. Compare the following test result with the ones that I did last year, when they started to support Virtio:

Probably DO started to throttle the I/O on the cheaper droplets, but the result is poor overall.

View Login.m
#import "NSString+SHA1HMAC.h"
NSString *client_time = [NSString stringWithFormat:@"%f", NSDate.date.timeIntervalSince1970];
NSString *client_digest = [client_time SHA1HMACWithKey:kCliendSecret];
NSDictionary *parameters = @{@"grant_type":@"password",
@"client_id":kCliendId,
@"client_time":client_time,
@"client_digest":client_digest,
@"username":self.emailField.text,
@"password":self.passwordField.text};
View BlackMagic.h
#define CLASS_PROPERTY_INTERFACE(TYPE, METHOD, CMETHOD) \
+ (TYPE) METHOD; \
+ (void) set##CMETHOD:(TYPE)val; \
#define CLASS_PROPERTY_IMPLEMENTATION(TYPE, METHOD, CMETHOD) \
static TYPE _##METHOD; \
+ (TYPE) METHOD \
{ @synchronized(self) { return _##METHOD; } } \
+ (void) set##CMETHOD:(TYPE)val \
{ @synchronized(self) { _##METHOD = val; } } \
You can’t perform that action at this time.