Skip to content

Instantly share code, notes, and snippets.

Seivan Heidari seivan

Block or report user

Report or block seivan

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:da26b0a15c5901cba94a
@infix func == <T:ScalarArithmetic, U:ScalarArithmetic> (lhs:T,rhs:U) -> Bool {
return (lhs.toDouble == rhs.toDouble)
@infix func != <T:ScalarArithmetic, U:ScalarArithmetic> (lhs:T,rhs:U) -> Bool {
return (lhs == rhs) == false
@infix func <= <T:ScalarArithmetic, U:ScalarArithmetic> (lhs:T,rhs:U) -> Bool {
return (lhs.toDouble <= rhs.toDouble)
@infix func < <T:ScalarArithmetic, U:ScalarArithmetic> (lhs:T,rhs:U) -> Bool {
View gist:007bd54b7ed4635014aa
// Some global place
class CollisionMapping
enum Layer : Uint32 {
// Maps individual collision types (bird, pipe etc) to a smaller set of
// more generic types to make them more manageable
View tap-and-hold.js
const touchStart = Rx.Observable.fromEvent(window, 'touchstart').timestamp();
const touchMove = Rx.Observable.fromEvent(window, 'touchmmove');
const touchEnd = Rx.Observable.fromEvent(window, 'touchend').timestamp();
const touchAndHold = touchStart
.flatMap(() => touchEnd.takeUntil(touchMove), (x, y) => { start: x.timestamp, end: y.timestamp })
.filter(ts => (ts.end - ts.start) / 1000 > 2);
const subscription = touchAndHold.subscribe(
() => console.log('touch and hold!')
View TextFieldChanges.m
@synthesize firstName = _firstName;
@synthesize txtFirstName = _txtFirstName;
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }];
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable];
- (void) firstNameChanged:(id)firstName {
NSLog(@"changed: %@", firstName);
View assets.rake
# Stick this in lib/tasks/assets.rake or similar
# A bug was introduced in rails in 7f1a666d causing the whole application cache
# to be cleared everytime a precompile is run, but it is not neccesary and just
# slows down precompiling.
# Secondary consequences are the clearing of the whole cache, which if using
# the default file cache could cause an application level performance hit.
# This is already fixed in sprockets-rails for rails 4, but we patch here for
View BPGeometry.h
* BPGeometry.h
* Created by Jon Olson on 11/30/09.
* Copyright 2009 Ballistic Pigeon, LLC. All rights reserved.
#import <Foundation/Foundation.h>
View gist:8239351
- (void)textViewDidChange:(UITextView *)textView
CGRect line = [textView caretRectForPosition:textView.selectedTextRange.start];
CGFloat overflow = line.origin.y + line.size.height
- ( textView.contentOffset.y + textView.bounds.size.height
- textView.contentInset.bottom - );
if (overflow > 0) {
// We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it)
michaelochurch / hackernews-banned-post
Created Jan 9, 2014
This is the reply I can't write on Hacker News, because PG is a fucking child and I get the "submitting too fast" error after ~3 posts per day.
View hackernews-banned-post
In reply to:
*People, as a group, really aren't interested in learning any more than the bare minimum they need to
get what they want. That's what MOOCs are really up against.*
True, and the people who are motivated tend to rely on each other, if not for support, at least to have
peers who are similarly interested. It's like the fact that people whose friends are obese are more likely
to gain weight.
If your motivation/work ethic/freedom-from-external-distraction level is 9-10, then you're fine working
View gist:8398687

The most obvious example is linking of dependent libraries. When you add a framework to your project, that framework already has encoded the libraries it depends on; simply drop the framework in, and no further changes are required to the list of libraries your project itself links to.

People/companies do this with static libraries as well, whereas it should be “the application developer's responsibility to add all required libraries in addition to the one they actually want to use”.

Of course, if ‘the one [library] they actually want to use’ is the only library they care about, then having a single ‘drop-in’ solution is preferable. However, once you depend on multiple libraries that might have common dependencies, there’s no way around having to have a dependency (versions) manager. Because while you can pull-off various symbol tricks with C libraries, you cannot with Objective-C. As in, there can only ever be one class/method registered for a given name in the runtime.

I feel like this was

davbeck / assets.rb
Last active May 19, 2016
Automatic Enum-based Xcassets in Swift
View assets.rb
#!/usr/bin/env ruby
require "active_support"
def assetCatalogsAtPath(path)
results = []
contents = Dir.entries(path)
You can’t perform that action at this time.