Skip to content

Instantly share code, notes, and snippets.

View nebiros's full-sized avatar

Juan Alvarez nebiros

View GitHub Profile
@gurgeh
gurgeh / mp3.cpp
Created October 11, 2012 11:29
A C++ example of Dive Into Python
//Having to include so many different header files to do basic
//things like open a file, use strings, vectors and tuples, etc,
//is still annoying.
#include <fstream>
#include <vector>
#include <map>
#include <tuple>
#include <string>
//To use C++11 lambdas with Boost lambdas we define this.
@arunkv
arunkv / gist:4137835
Created November 24, 2012 00:36
Arun's Slate Configuration
config defaultToCurrentScreen true
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
config windowHintsSpread true
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
# Cmd+E brings up window chooser based on alphabet
bind e:cmd hint ASDFGHJKLQWERTYUIOPCVBN
@prashmohan
prashmohan / .slate
Created November 25, 2012 21:13
Slate configuration file
# ======================================
# The HYPER key
# ======================================
alias hyperend shift;alt;cmd;fn
alias hyper shift;alt;cmd;ctrl
# ======================================
# Application aliases
# ======================================
alias browser 'Google Chrome'
@ChrisRisner
ChrisRisner / eventFlow.m
Last active December 10, 2015 05:58
iOS Day 24
2012-12-27 12:27:35.942 DayTwentyFour[20082:c07] initWithCoder
2012-12-27 12:27:35.947 DayTwentyFour[20082:c07] loadView
2012-12-27 12:27:35.949 DayTwentyFour[20082:c07] viewDidLoad
2012-12-27 12:27:35.949 DayTwentyFour[20082:c07] viewWillAppear
2012-12-27 12:27:35.952 DayTwentyFour[20082:c07] viewWillLayoutSubviews
2012-12-27 12:27:35.952 DayTwentyFour[20082:c07] viewDidLayoutSubviews
2012-12-27 12:27:35.956 DayTwentyFour[20082:c07] viewDidAppear
AsyncBlockOperation is very similar to NSBlockOperation with one caveat; the block you pass to it receives one argument, a reference to the AsyncBlockOperation for the block. When your block is done with its task, it must call [op complete]
Example usage:
NSOperation* asyncOp = [AsyncBlockOperation blockOperationWithBlock:^(AsyncBlockOperation* op) {
NSLog(@"starting op");
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
@whalesalad
whalesalad / gist:5571730
Last active December 17, 2015 07:18
How to chain GPUImage filters together. Below is an example of doing a fast blur followed by a grayscale filter. The docs are a bit light on how to do this and a lot of folks seem to have a hard time. Below is an example that worked for me.
- (UIImage*)blurImage
{
// Create our sourcePicture for processing
GPUImagePicture *sourcePicture = [[[GPUImagePicture alloc] initWithImage:self] autorelease];
// init the fast blur filter
GPUImageFastBlurFilter *blurFilter = [[[GPUImageFastBlurFilter alloc] init] autorelease];
// set some parameters for the fast blur
[blurFilter setBlurPasses:3.0f];
@Marlunes
Marlunes / hide_status_bar
Created July 16, 2013 07:54
FORCE HIDE STATUS BAR FOR IOS 7 AND 6
//viewDidload
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
CGRect OldFrame = CGRectMake(150, 150, 120, 150);
UIView * view = [[UIView alloc] initWithFrame:OldFrame];
view.clipsToBounds = YES;
self.toolBar = [[UIToolbar alloc] initWithFrame:view.bounds];
self.toolBar.tintColor = [UIColor redColor];
[view.layer insertSublayer:self.toolBar.layer atIndex:0];
[self.view addSubview:view];
double delayInSeconds = 2.0;
@idStar
idStar / UITableViewCellSublclass.m
Created October 17, 2013 01:56
Workaround for iOS7 bug where UITableViewCell background in editing mode, covers up the Delete button.
- (void)layoutSubviews {
[super layoutSubviews];
[self applyEditingModeBackgroundViewPositionCorrections];
}
/**
When using a backgroundView or selectedBackgroundView on a custom UITableViewCell
subclass, iOS7 currently
@lordcodes
lordcodes / build-fix-robolectric-properties.gradle
Last active January 18, 2016 23:36
Workaround for test resources file not being found by Robolectric. You will need to add: "apply from: 'build-test-fixes.gradle'" to your main build.gradle file.
// Workaround for missing test resources when run unit tests within android studio.
// This copy the test resources next to the test classes for each variant.
// Tracked at https://github.com/nenick/AndroidStudioAndRobolectric/issues/7
// Original solution comes from https://code.google.com/p/android/issues/detail?id=136013#c10
gradle.projectsEvaluated {
// Base path which is recognized by android studio.
def testClassesPath = "${buildDir}/intermediates/classes/test/"
// Copy must be done for each variant.
def variants = android.applicationVariants.collect()