Skip to content

Instantly share code, notes, and snippets.

View qnoid's full-sized avatar
💭
I have been raised by women. My single mother, my grandma, my godmother.

Markos Zoulias Charatzas qnoid

💭
I have been raised by women. My single mother, my grandma, my godmother.
View GitHub Profile
@henrik
henrik / .bashrc
Created December 3, 2008 17:56
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@hramos
hramos / _InfiniteTableViewController.m
Created January 24, 2011 15:29
Infinite Load More Table View Example
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if(_reachedEndOfFeed) return;
if(!_dynamicFeed) return;
DLog();
if (!reloading)
{
checkForRefresh = YES; // only check offset when dragging
}
@jimweirich
jimweirich / analysis.rb
Created July 20, 2011 16:37
Results from Roman Numeral Calculator Kata at @cincinnatirb
# When I posted the results of the Roman Numeral Calculator kata
# earlier this week, I said that I felt that the evolution of the code
# through TDD was much more interesting than the final result. Let me
# explain.
#
# First, some background. The goal of this Kata is to produce a
# RomanNumeralCalculator object that converts from arabic numbers to
# Roman numerals, and from Roman numerals back to arabic.
Then { calculate("1").should == "I" }
// Copyright (c) 2012-2013 Peter Steinberger (http://petersteinberger.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@ahoward
ahoward / a.rb
Created August 19, 2012 14:17
threads are so dang awesome
=begin
READ THIS FOR CONTEXT:
http://tenderlovemaking.com/2012/07/30/is-it-live.html
=end
strategy =
@steipete
steipete / gist:3713233
Created September 13, 2012 09:39
I often use dispatch queues for locking, and this function just makes life SO MUCH EASIER. Accidental deadlocks in more complex code paths are a PITA otherwise. But Apple deprecated dispatch_get_current_queue with iOS6?
nline void pspdf_dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) {
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
}
@kenn
kenn / gist:5105175
Last active December 14, 2015 15:08
Unicorn memory usage improvement with Ruby 2.0.0

Unicorn memory usage improvement with Ruby 2.0.0

Here's a preliminary experiment to see how much memory is saved with the new copy-on-write friendly (bitmap marking) GC.

Calculated by memstats.rb https://gist.github.com/kenn/5105061 on Debian x86_64.

Master process:

# ./memstats.rb 20547
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
source ~/.bash_profile
cd ${SRCROOT}
/path/to/xctool.sh -reporter json-compilation-database:compile_commands.json clean
/path/to/xctool.sh -reporter json-compilation-database:compile_commands.json build
oclint-json-compilation-database | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'
@alloy
alloy / gist:5850206
Last active December 18, 2015 21:49
Meta alert: A Kiwi matcher that allows you to define custom matchers with one block instead of subclassing KWMatcher.
#import "KWMatcher.h"
typedef BOOL (^FTKiwiCustomMatcherBlock)(id subject);
@interface FTKiwiCustomBlockMatcher : KWMatcher
// Your custom matcher block will receive the expectation ‘subject’ and must
// return `YES` if the expaction passes or `NO` if it fails.
- (void)be:(FTKiwiCustomMatcherBlock)block;