Skip to content

Instantly share code, notes, and snippets.

View densa's full-sized avatar
🇺🇦
UKE

Denys densa

🇺🇦
UKE
View GitHub Profile
@JmeHsieh
JmeHsieh / gist:2002207
Created March 8, 2012 17:25
Decode UIImage in background
__weak Photo *p = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
CGImageRef imageRef = image.CGImage;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
CGImageGetWidth(imageRef),
CGImageGetHeight(imageRef),
8,
CGImageGetWidth(imageRef) * 4,
@nielsbot
nielsbot / UIImage+JPEG2000.h
Created February 19, 2012 00:43
Decoding JPEG 2000 files to UIImage
#import <Foundation/Foundation.h>
extern UIImage * UIImageWithJPEG2000Data( NSData * data ) ;
@farcaller
farcaller / gist:1801278
Created February 11, 2012 15:56
Refactored macros from bitbucket.org/snej/myutilities
#define $array(OBJS...) ({id objs[]={OBJS}; \
[NSArray arrayWithObjects: objs count: sizeof(objs)/sizeof(id)];})
#define $marray(OBJS...) ({id objs[]={OBJS}; \
[NSMutableArray arrayWithObjects: objs count: sizeof(objs)/sizeof(id)];})
#define $mdict(PAIRS...) ( \
{id pairs[]={PAIRS}; \
NSMutableDictionary *d = [NSMutableDictionary dictionary]; \
int cnt = sizeof(pairs)/sizeof(id); \
@wearhere
wearhere / keep_current_file_open.sh
Created February 9, 2012 09:34
Keep your current source file open in Xcode after a run completes (a.k.a don't die in main.m)
#! /bin/sh
# On alternate invocations, this script
# saves the path of the source file currently open in Xcode
# and restores the file at that path in Xcode.
#
# By setting Xcode (in Behaviors) to run this script when "Run Starts"
# and when "Run Completes", you can prevent it from switching to main.m
# when a run finishes.
# See http://stackoverflow.com/questions/7682277/xcode-4-2-jumps-to-main-m-every-time-after-stopping-simulator
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
@zachwaugh
zachwaugh / gist:1151687
Created August 17, 2011 14:53
Image mask
- (UIImage *)imageWithMask:(UIImage *)maskImage andIsWhite:(BOOL)isWhite
{
CGRect imageRect = CGRectMake(0, 0, maskImage.size.width, maskImage.size.height);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(NULL, maskImage.size.width, maskImage.size.height, 8, 0, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextClipToMask(ctx, imageRect, maskImage.CGImage);
if (isWhite) {
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
} else {
@oleganza
oleganza / NSData+OADataHelpers.m
Last active December 9, 2022 03:50
Creating NSString from NSData by fixing invalid UTF8 characters
// Author: Oleg Andreev <[email protected]>
// May 28, 2011
// Do What The Fuck You Want Public License <http://www.wtfpl.net>
#import "NSData+OADataHelpers.h"
#if !__has_feature(objc_arc)
#error ARC must be enabled!
#endif
@darkseed
darkseed / Curved_shadow.m
Created May 11, 2011 22:13
Curved shadow below an image
#import <QuartzCore/QuartzCore.h>
- (void)viewDidLoad
{
[super viewDidLoad];
UIImage *image = [UIImage imageNamed:@"photo.png"];
UIView *photoView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height)];
photoView.center = CGPointMake(self.view.center.x, self.view.center.y - 10);
@osteslag
osteslag / IR_Black.dvtcolortheme
Created February 20, 2011 10:54
IR_Black theme for Xcode 4, based on IR_Black for Xcode 3 by David Zhou, based on IR_Black for TextMate by Todd Werth. See links in comments below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.811765 0.796078 0.564706 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 16.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@gampleman
gampleman / board.css
Created November 5, 2010 15:36
CSS to make a Departure board
#4606367513 {
padding: 5px 10px;
display: inline-block;
background: rgb(30, 30, 30);
background: -webkit-gradient(linear, center top, center bottom,
color-stop(0.0, rgba(0,0,0, 1)),
color-stop(0.05, rgba(30,30,30, 1)),
color-stop(1.0, rgba(50, 50, 60, 1)));
background: -moz-linear-gradient(270deg,
rgba(0,0,0,1) 0%,