Skip to content

Instantly share code, notes, and snippets.

@funami
funami / gist:2407027
Created April 17, 2012 15:50
Upload file to S3 with AFNetworking
#import "AFNetworking.h"
- (IBAction)uploadTest:(id)sender {
NSURL *url = [NSURL URLWithString:@"https://xxx.s3-ap-northeast-1.amazonaws.com/"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSData *imageData = UIImagePNGRepresentation([UIImage imageNamed:@"194-note-2.png"]);
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
@"xxxxx/videos/XXXXW",@"key",
@"XXXXXXXX",@"AWSAccessKeyId",
@sekati
sekati / xcode-build-bump.sh
Created July 24, 2012 20:44
Xcode Auto-increment Build & Version Numbers
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
@jonzhan
jonzhan / xcode_git_update_plist.rb
Last active October 8, 2015 22:08
Automatically update info.plist with git build number and hash when building in Xcode
#!/usr/bin/env ruby
# Giants' Shoulders Trodden Upon
# Based on the xcode auto-versioning script for Subversion by Axel Andersson
# Updated for git by Marcus S. Zarra and Matt Long
# Converted to ruby by Abizer Nasir
# Improved? By Jonathan Zhan
# Appends the number of commits on the current branch and a short git hash to the version number set in Xcode.
@gavrix
gavrix / gist:5054182
Created February 28, 2013 04:28
Script integrating OCLint into XCode. Put it in "Run script" build phase.
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
@couchdeveloper
couchdeveloper / transform_each.m
Last active October 30, 2016 09:50
Asynchronous Pattern with GCD Part I
/**
Objective:
Asynchronously transform or process an array of items - one after the
other and return the result of each transform in an array.
Synopsis:
void transform_each(NSArray* inArray, unary_async_t task, completion_t completion);
@kevinelliott
kevinelliott / osx-10.11-setup.md
Last active April 10, 2022 15:47
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@maxsz
maxsz / DelayedBlockOperation.swift
Last active October 26, 2018 11:21
Delayed NSOperation
class DelayedBlockOperation: NSOperation {
private var delay: NSTimeInterval = 0
private var block: (() -> Void)? = nil
private var queue: dispatch_queue_t = dispatch_get_main_queue()
override var asynchronous: Bool { return true }
override var executing : Bool {
get { return _executing }
set {
willChangeValueForKey("isExecuting")
@lukegre
lukegre / LG_xarray_tools.py
Last active December 10, 2020 20:06
function that takes the trend for an xarray.DataArray over the 'time' variable. Returns the slopes and p-values for each location.
def dataset_encoding(xds):
cols = ['source', 'original_shape', 'dtype', 'zlib', 'complevel', 'chunksizes']
info = pd.DataFrame(columns=cols, index=xds.data_vars)
for row in info.index:
var_encoding = xds[row].encoding
for col in info.keys():
info.ix[row, col] = var_encoding.pop(col, '')
return info
@anttilipp
anttilipp / solarzenithazimuthdemo.py
Last active April 6, 2024 09:21
Demo code to compute + visualize solar zenith angle and solar azimuth angle in Python
"""
DEMO TO COMPUTE SOLAR ZENITH ANGLE
version 6 April 2017
by Antti Lipponen
Copyright (c) 2017 Antti Lipponen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
ncflint -A -C -v ubar_north,vbar_north,u_north,v_north,ubar_west,vbar_west,u_west,v_west -w 0.0,0.0 ws4km_bry_SODA3_19890115_to_20151215_test.nc ws4km_bry_SODA3_19890115_to_20151215_test.nc test.nc