Skip to content

Instantly share code, notes, and snippets.

class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
@haikusw
haikusw / HUTF8MappedUTF16String.h
Created February 3, 2012 22:26 — forked from rsms/HUTF8MappedUTF16String.h
Convert a UTF-16 string to UTF-8, mapping indices to provide low-complexity range and index lookups
#ifndef H_UTF8_MAPPED_UTF16_STRING_H_
#define H_UTF8_MAPPED_UTF16_STRING_H_
#import <Foundation/Foundation.h>
#import <string>
/*
* Convert a UTF-16 string to UTF-8, mapping indices to provide low-complexity
* range and index lookups.
*
@haikusw
haikusw / main.m
Created December 29, 2011 03:59
Some odd bug in dictionary description ...
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
#define kItemKey @"kItemKey"
#define kPriceKey @"kPriceKey"
@autoreleasepool {
// insert code here...
@haikusw
haikusw / buildAndPackageOneConfig.sh
Created November 21, 2011 19:48
Builds one config (Debug, Release, or Dist)
#Xcode target has sub-targets of the resources bundle target, and the target that makes a universal version of the static library for the current build config).
#this is the Run Script build phase that happens after that.
echo ""
echo "moving resources bundle into universal build folder"
echo ""
if [ ${ACTION} = "build" ]
then
echo "Copying resources into ${BUILD_DIR}/${CONFIGURATION}-universal/ ..."
@haikusw
haikusw / makeunivstaticlib.sh
Created November 21, 2011 19:41
Run Script build phase script to make a universal static library.
#!/bin/sh
# makeuniversalstaticlib.sh
# SAMPLELib
#
#################[ Tests: helps workaround any future bugs in Xcode ]########
DEBUG_THIS_SCRIPT="false"
#import "AFRestClient+OAuth.h"
NSString * const kAFOAuthBasicGrantType = @"user_basic";
NSString * const kAFOauthRefreshGrantType = @"refresh_token";
@implementation AFRestClient (OAuth)
- (void)authenticateUsingOAuthWithPath:(NSString *)path
username:(NSString *)username
password:(NSString *)password
@haikusw
haikusw / gist:1098966
Created July 22, 2011 06:09
for Oxceed
de_CH: "CHF" (should be "Fr.")
fr_CH: "CHF" (should be "fr.")
it_CH: "CHF" (should be "fr.")
rm_CH: "CHF" (should be "fr.")
international: "USD" (should be "CHF")
@haikusw
haikusw / DropBox-info.plist
Created June 30, 2011 05:06
Dropbox 1.4.2 info.plist Document types possibly too broad?
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>All Files</string>
<key>LSItemContentTypes</key>
<array>
<string>public.data</string>
<string>public.content</string>
</array>
@haikusw
haikusw / gist:1050447
Created June 28, 2011 03:48
Objective C singleton pattern templates discussion
// Accessorizer's default generated singleton code for class Foo
static Foo *sharedInstance = nil;
+ (void) initialize
{
if (sharedInstance == nil)
sharedInstance = [[self alloc] init];
}
@haikusw
haikusw / HSIDateUtils.h
Created June 1, 2011 21:37
debugging aid for dates
#import <Foundation/Foundation.h>
@interface NSDateComponents (HSINSDateUtils)
- (void) logToConsole;
@end