Skip to content

Instantly share code, notes, and snippets.

@Air-Craft
Air-Craft / Contract Killer 3.md
Created Feb 3, 2020 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@Air-Craft
Air-Craft / ffmpeg_from_m3u_stream.sh
Created Dec 24, 2015
Rip m3u8 stream (series of .ts files) to video via ffmpeg #video #conversion #streaming #ripping
View ffmpeg_from_m3u_stream.sh
ffmpeg -i "https://content.jwplatform.com/manifests/Wqyolfwt.m3u8" -c copy -bsf:a aac_adtstoasc video.mp4
@Air-Craft
Air-Craft / flush_memcache.sh
Created Jun 28, 2015
Flush memcache server from command line #CLI #memcache #bash
View flush_memcache.sh
echo 'flush_all' | nc localhost 11211
# Or...
nc 192.168.1.10 11211<<<"flush_all"
@Air-Craft
Air-Craft / cifilter_calayer.m
Created Apr 30, 2015
Apply CIFilter to a CALayer #CoreImage #image-manipulation #ios
View cifilter_calayer.m
// SIMPLE
// Note: Can convert to UIImage but there's no way to go to CGImage.
CIImage *newImg = [[CIImage imageWithCGImage:img.CGImage] imageByApplyingFilter:@"CIColorMonochrome"
withInputParameters:@{kCIInputColorKey: ciCol}];
// EXTENDED
CIContext *ctx = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CIColorMonochrome"];
@Air-Craft
Air-Craft / iphone_vibrate.m
Created Apr 26, 2015
Short custom vibration on iPhone #ios #vibration #private-api
View iphone_vibrate.m
// Headers
#import <AudioToolbox/AudioToolbox.h>
void AudioServicesStopSystemSound(SystemSoundID inSystemSoundID);
void AudioServicesPlaySystemSoundWithVibration(SystemSoundID inSystemSoundID,id arg,NSDictionary* vibratePattern);
// Buzz code
NSArray *vibe = @[ @YES, @10 ]; // ON for 10ms
NSDictionary *dict = @{ @"Intensity": @0.1, @"VibePattern": vibe };
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate,nil,dict);
@Air-Craft
Air-Craft / float_modulus_objc.m
Created Apr 7, 2015
Float modulus block #objective-c #math
View float_modulus_objc.m
CGFloat (^modulus)(CGFloat, CGFloat) = ^CGFloat(CGFloat dividend, CGFloat divisor) {
return dividend - floor(dividend / divisor) * divisor;
};
@Air-Craft
Air-Craft / indexpath_addition_math.m
Created Apr 7, 2015
Add/subtract from an IndexPath `item` property overflowing into `section` #objective-c #cocoa #index
View indexpath_addition_math.m
- (NSIndexPath *)_indexPathByAdding:(NSInteger)N toIndexPath:(NSIndexPath *)idxPath
{
const NSInteger SIZE = 8;
NSInteger item = idxPath.item + N;
NSInteger sectionDelta = trunc(item / SIZE);
item = abs((int)item) % SIZE;
NSInteger section = idxPath.section + sectionDelta;
@Air-Craft
Air-Craft / objective_c_runtime_mixin.m
Created Mar 28, 2015
Mixin class method in Objective-C #objective-c #mixins #runtime #advanced
View objective_c_runtime_mixin.m
// MIXINS
+ (void)mixInto:(Class)destCls
{
NSAssert([[destCls alloc] isKindOfClass:[UIViewController class]], @"%@ is not a UIViewController subclass", destCls);
void (^inject)(Class, SEL, Class) = ^(Class srcCls,
SEL sel,
Class destcls){
Method newMethod = class_getInstanceMethod(srcCls, sel);
class_replaceMethod(destCls, sel, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)); // replace is like force-add, where addMethod fails if exists
@Air-Craft
Air-Craft / calayer_transform_w_perspective_anim.m
Created Mar 28, 2015
CALayer rotate, slide, fade in #animation with perspective #transform #3d
View calayer_transform_w_perspective_anim.m
_alertContainer.alpha = 0.0;
CATransform3D t = CATransform3DIdentity;
t.m34 = -1.0 / 700;
t = CATransform3DRotate(t, -40*M_PI/180., 1.0, 0.0, 0);
t = CATransform3DTranslate(t, 0, -0, -200);
_alertContainer.layer.transform = t;
[UIView
animateWithDuration:self.animDuration
delay:0
@Air-Craft
Air-Craft / ios_app_version_string.m
Created Mar 19, 2015
Get app version strings #ios #strings #basic
View ios_app_version_string.m
return [NSString stringWithFormat:@"%@ v%@ (%@)",
[[NSBundle mainBundle] infoDictionary][@"CFBundleDisplayName"],
[[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"],
[[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"]];