Skip to content

Instantly share code, notes, and snippets.

View luketheobscure's full-sized avatar
🤘
rockin out

luke.js luketheobscure

🤘
rockin out
View GitHub Profile
@luketheobscure
luketheobscure / testFeatureFlags.m
Last active December 17, 2015 09:29
Unit testing AFNetworking blocks can be tricky since SenTestingKit won't wait for the completion blocks to finish. Here's how I test my functions that deal with networking. Slightly adapted from https://gist.github.com/andrewroycarter/2254570
/*
Testing the af.updateFeatureFlags method, which returns an AFJSONRequestOperation operation
*/
- (void) testFeatureFlags{
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[af.sharedHTTPClient enqueueBatchOfHTTPRequestOperations:@[af.updateFeatureFlags] progressBlock:nil completionBlock:^(NSArray *operations) {
dispatch_semaphore_signal(semaphore);
}];
@luketheobscure
luketheobscure / priceInfo.m
Created May 17, 2013 18:34
RestKit experiment. Don't actually use this code... It took 2 minutes to parse 10K rows.
- (void) getPriceInfo{
// Initialize HTTPClient
NSURL *baseURL = [NSURL URLWithString:@"http://localhost"];
AFHTTPClient* client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];
[client setDefaultHeader:@"Accept" value:RKMIMETypeJSON];
// Initialize RestKit
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];
// Initialize managed object store
import Ember from 'ember';
export default Ember.Route.extend({
init() {
this._super(...arguments);
$.mockjax({
url: '/parents',
responseText: {
name: "someText"
@luketheobscure
luketheobscure / controllers.application.js
Last active May 2, 2017 19:01
Power Select 1.8.2 Bug
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
names: [1, 2],
actions: {
foo(){}
}
});
@luketheobscure
luketheobscure / lambda.js
Last active June 10, 2019 12:57
Percy Bitbucket AWS Lambda
const https = require('https');
const AUTHORIZATION = ''; // base 64 of user:password
const BITBUCKET_USER = ''; // either the user or the org that owns the repo
const PERCY_USER = ''; // the name of your percy user or org
exports.handler = (event, context, callback) => {
/**
We need to post to a URL like this:
https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<hash>/statuses/build
@luketheobscure
luketheobscure / loadtest.sh
Created July 21, 2024 19:38
Simple load testing
# Very simple load testing script. Will invoke a given url X number of times
# example usage: ./loadtest.sh 25 "http://localhost:3000/my-url"
max="$1"
date
echo "url: $2
rate: $max calls / second"
START=$(date +%s);
get () {
curl -s -v "$1" 2>&1 | tr '\r\n' '\\n' | awk -v date="$(date +'%r')" '{print $0"\n-----", date}' >> /tmp/perf-test.log