Skip to content

Instantly share code, notes, and snippets.

@boie0025
boie0025 / gist:ae9697eed61cbf5342a6
Last active May 17, 2017 20:20
scraper-psuedocode-exmaple
module Producers
class DataModelA
... # Some ruby magic to return the correct subclass for a state
def page
@page ||= Nokogiri.new(URL)
end
end
class SpecificState < DataModelA
@alexrepty
alexrepty / CustomUITableViewCell.m
Created December 22, 2014 11:56
One way to use a custom reorder control in iOS 8 apps.
- (void)addSubview:(UIView *)view {
// For the system-supplied reorder control, we want to eliminate the default
// image and instead use our own. In order to achieve this, we need to use
// the somewhat hacky way of confirming that this is indeed a system-created
// UITableViewCellReorderControl by checking the class name. Icky? Icky.
NSArray *relevantClassnameParts = @[@"ReorderControl"];
NSString *viewClassname = NSStringFromClass([view class]);
for (NSString *classname in relevantClassnameParts) {
if (![viewClassname containsString:classname]) {
@natecook1000
natecook1000 / NSTimer+Closure.swift
Last active July 12, 2024 05:11
Scheduled NSTimer with a Swift closure
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/
@staltz
staltz / introrx.md
Last active May 24, 2025 19:53
The introduction to Reactive Programming you've been missing
@alloy
alloy / Rakefile
Last active March 23, 2016 10:36
A Rakefile that standardises program env installation and guides the user, as opposed to crashing with Ruby exceptions such as `LoadError`. The only case where this will *never* work reliably is if you use the `rubygems-bundler` (NOEXEC) plugin, which introduces chicken-and-egg problems.
# Do *not* load any libs here that are *not* part of Ruby’s standard-lib. Ever.
desc "Install all dependencies"
task :bootstrap do
if system('which bundle')
sh "bundle install"
sh "git submodule update --init"
# etc
else
$stderr.puts "\033[0;31m[!] Please install the bundler gem manually: $ [sudo] gem install bundler\e[0m"
@velsa
velsa / app.js
Created March 25, 2014 15:43
Express server used to launch ffmpeg, transcode stream from peerflix and serve it to HTML5 video tag
var express = require('express'),
http = require('http'),
path = require('path'),
child_process = require("child_process");
var app = express();
// Server settings
app.set('port', process.env.PORT || 9999);
app.use(express.favicon());
@orta
orta / ARAllViewControllers.m
Created February 16, 2014 17:42
Check all view controllers to see if they load the view on init
//
// ARAllViewControllers.m
// Artsy
//
// Created by Orta on 16/02/2014.
// Copyright (c) 2014 Art.sy. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "ARClassGetSubclasses.h"
@fractaledmind
fractaledmind / Create JSON Evernote Cache
Last active July 9, 2019 04:51
Creates cache of Evernote note data in JSON format. Once created, this .txt cache can be read and searched much more quickly than pinging the Evernote app with each script you write. This script should be saved as a Stay open after Run application. It will ping your system every (default) 3 hours to see if the cache hasn't been updated today. If…
(* CREATE JSON EVERNOTE CACHE
--Stephen Margheim
--11/14/13
--open source
Creates cache of Evernote note data in JSON format.
Once created, this .txt cache can be read and searched much more quickly than pinging the Evernote app with each script you write.
@MarkVillacampa
MarkVillacampa / JavaScriptCore.m
Last active December 27, 2015 19:49
Trying to add methods at runtime for the JSExport protocol in JavaScriptCore. As-is, the method is not called from Javascript. Uncomment lines 7-8 and the end of 11, comment line 65, and run. The method is now called from JavaSript. Any idea why?
#import <Foundation/Foundation.h>
#import <JavaScriptCore/JavaScriptCore.h>
#import <objc/runtime.h>
const char *_protocol_getMethodTypeEncoding(Protocol *, SEL, BOOL isRequiredMethod, BOOL isInstanceMethod);
//@protocol MyProtocol <JSExport>
// -(void)one:(id)one;
//@end
@aprato
aprato / AMPNavigationBar.m
Last active July 13, 2018 00:23
Darker iOS7 translucent UINavigationBar
// .h
@interface AMPNavigationBar : UINavigationBar
@property (nonatomic, assign) CGFloat extraColorLayerOpacity UI_APPEARANCE_SELECTOR;
@end
// .m