Skip to content

Instantly share code, notes, and snippets.

@jawngee
jawngee / faces.php
Created September 29, 2017 18:35
Passing detected faces to imgix
<?php
// not tested
// would go into your theme's functions.php
add_filter('ilab-imgix-filter-parameters',function($params, $size, $id, $meta){
if (isset($meta['faces']) && is_array($meta['faces'])) {
$firstFace = $meta['faces'][0];
$rect = $firstFace['BoundingBox'];
list($width, $height, $left, $top) = array_values($rect);
@jawngee
jawngee / functions.php
Last active April 21, 2017 16:11
Adding parameters to Imgix URL
<?php
add_filter('ilab_imgix_filter_parameters',function($params, $size, $id, $meta){
$params['blur'] = 20;
return $params;
}, 10, 4);
@jawngee
jawngee / deploy.sh
Created October 3, 2012 11:01
bash script to combine multiple js files into main.js for Parse.com's Cloud shiz
#!/bin/bash
## combines multiple js files into main.js for deploying to parse
## Your separate js files should be in a directory 'source' that
## is at the same level as the 'cloud' and 'config' directories
## parse uses.
cat source/*.js > cloud/main.js
## deploy
parse deploy
//
// SomeObject.h
//
#import <Cocoa/Cocoa.h>
@interface SomeObject {
NSString *title;
NSString *subtitle;
}
-(NSImage *)getAnImage {
return [[[NSImage alloc] initWithContentsOfFile:@"/tmp/youownthis.jpg"] autorelease];
}
-(NSImage *)getAnImage {
return [[NSImage alloc] initWithContentsOfFile:@"/tmp/youownthis.jpg"];
}
//
// SomeObject.h
//
#import <Cocoa/Cocoa.h>
@interface SomeObject : NSObject {
NSMutableArray *things;
NSMutableDictionary *someOtherThings;
}
-(void)sayWhat
{
NSString *doIOwnThisIWonder = [NSString stringWithFormat:@"%@",@"Nope"];
NSImage *iOwnThisImage = [[NSImage alloc] initWithContentsOfFile:@"/tmp/youownthis.jpg"];
NSData *perhapsThisData=[iOwnThisImage TIFFRepresentation];
... do my thing ...
[iOwnThisImage release];
}
-(void)sayWhat
{
NSString *doIOwnThisIWonder = [NSString stringWithFormat:@"%@",@"Nope"];
NSImage *iOwnThisImage = [[NSImage alloc] initWithContentsOfFile:@"/tmp/youownthis.jpg"];
NSData *perhapsThisData=[iOwnThisImage TIFFRepresentation];
}
-(void)someMethod
{
// I own this!
SomeObject *iOwnThis = [[SomeObject alloc] init];
[iOwnThis doYourThing];
// I release this!
[iOwnThis release];
}