Skip to content

Instantly share code, notes, and snippets.

@PoslinskiNet
PoslinskiNet / UIHelperColors.m
Created October 3, 2013 12:28
Colors helper
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
@interface FTUIHelper : NSObject
+ (UIImage *)createImageFromColor:(UIColor *)color;
+ (UIColor *)colorFromHexRGB:(NSString *)inColorString
@end
@randomsequence
randomsequence / StickyHeadersCollectionViewFlowLayout.m
Last active October 26, 2016 14:57
A subclass of UICollectionViewFlowLayout which has UITableView style sticky headers.
// StickyHeadersCollectionViewFlowLayout
//
// A subclass of UICollectionViewFlowLayout which has UITableView style sticky headers.
//
// This code is based on Evadne Wu's code^1, with the following changes:
//
// * Fixes a crash for sections with zero items
// * Adds support for UIScrollView's contentInset
// * Adds support for UICollectionViewFlowLayout's sectionInset
//
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Photos with Friends!</title>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script>
/**
* This is the getPhoto library
*/
@rbreve
rbreve / gist:5127070
Created March 10, 2013 04:01
merge video
if (firstAsset !=nil && secondAsset!=nil) {
[activityView startAnimating];
// 1 - Create AVMutableComposition object. This object will hold your AVMutableCompositionTrack instances.
AVMutableComposition *mixComposition = [[AVMutableComposition alloc] init];
// 2 - Video track
AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo
preferredTrackID:kCMPersistentTrackID_Invalid];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration)
ofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, secondAsset.duration)
@kuninori
kuninori / videoViewController.h
Last active May 7, 2017 04:58
AVFoundation Video
//
// DetailViewController.h
// Sync Camera
//
// Created by kuninorif on 2014/05/22.
// Copyright (c) 2014年 kuninori. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@doluvor
doluvor / Thumbnail.m
Created October 18, 2016 03:34
Generate thumbnail of video
AVAsset *asset = [AVAsset assetWithURL:url];
CMTime duration = [asset duration];
CMTime snapshot = CMTimeMake(duration.value * progress, duration.timescale);
AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset];
CGImageRef imageRef = [generator copyCGImageAtTime:snapshot actualTime:nil error:nil];
UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
@renehuber
renehuber / gist:2959472
Created June 20, 2012 11:38
Plaintext contentEditable DIVs
/**
* Event handler to prevent richtext and linebreaks in contentEditable DIVs
*/
$('body').on('keydown paste', 'div.editfield', function(e) {
var $field = $(e.currentTarget);
if (e.keyCode===13 && $field.hasClass('multiline')) {
return true;
} else if (e.keyCode===13 || e.type==='paste') {
setTimeout(function() {
$field.html($field.text());
@stefanvangastel
stefanvangastel / default.ctp
Last active October 10, 2017 15:11 — forked from ichord/gist:9808444
demo of using pdf.js to extract pages to images in CakePHP (http://book.cakephp.org/3.0/en/views.html#using-view-blocks)
//Your layout file
<html>
<head>
//etc
</head>
<body>
//Bla bla
<?php
@dserodio
dserodio / delete-all-slack-images.py
Last active March 28, 2018 20:35
Delete all images in Slack that were uploaded until yesterday
#!/usr/bin/env python
"""Delete all images in Slack that were uploaded until yesterday"""
import requests
import datetime
import sys
TOKEN = 'Put your Slack auth token here'
SLACK_API = 'https://slack.com/api'
@justinHowlett
justinHowlett / gist:4611988
Last active July 24, 2018 06:13
Determine if a UIImage is generally dark or generally light
BOOL isDarkImage(UIImage* inputImage){
BOOL isDark = FALSE;
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage));
const UInt8 *pixels = CFDataGetBytePtr(imageData);
int darkPixels = 0;
int length = CFDataGetLength(imageData);