Skip to content

Instantly share code, notes, and snippets.

@akisute
akisute / gist:7799914
Created December 5, 2013 04:05
Several useful commands when you debug apps with AFNetworking
# Some request interrogations
po operation.request.HTTPMethod
po operation.request.allHTTPHeaderFields
# Prints out HTTPBody as string, using NSUTF8StringEncoding
expr (void)NSLog(@"%@", (NSString *)[[NSString alloc] initWithData:operation.request.HTTPBody encoding:4]);
@akisute
akisute / gist:7670871
Created November 27, 2013 04:59
PostprocessBuildPlayer for Unity, Written in Ruby.
#!/usr/bin/env ruby
#
# PostprocessBuildPlayer version 2
# Tested on Ruby 1.8.7, Gem 1.3.6, and xcodeproj 0.4.1
# Created by akisute (http://akisute.com)
# Licensed under The MIT License: http://opensource.org/licenses/mit-license.php
#
require 'rubygems'
# least require version, doesn't work in 0.3.X or less
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualsToString:@"Special"]) {
[self doSomething];
} else if ([segue.sourceViewController isKindOfClass:[MyViewController class]] && [segue.destinationViewController isKindOfClass:[MyDetailViewController class]]) {
MyDetailViewController *vc = segue.destinationViewController;
vc.someInfo = self.someInfo;
} else if ([segue.sourceViewController isKindOfClass:[MyViewController class]] && [segue.destinationViewController isKindOfClass:[MyModalViewController class]]) {
MyModalViewController *vc = segue.destinationViewController;
vc.someInfo = self.someInfo;
@akisute
akisute / PatternMatch.m
Last active December 27, 2015 07:09
もうそう
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//
// We NEED this kind of pattern matcher, don't we!? ;(
//
match(@[segue.identifier, segue.sourceViewController, segue.destinationViewController])
{
case @[@"Special", _, _]: ^(_, _, _){
[self doSomething];
}
@akisute
akisute / configure.sh
Last active July 3, 2017 05:16
How to build ncurses-5.9 for iOS :D
# Just comment out these lines in L4428 before ./configure
if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
{ { echo "$as_me:4429: error: Cross-build requires two compilers.
Use --with-build-cc to specify the native compiler." >&5
echo "$as_me: error: Cross-build requires two compilers.
Use --with-build-cc to specify the native compiler." >&2;}
{ (exit 1); exit 1; }; }
fi
@akisute
akisute / admin.py
Created August 6, 2013 11:40
How to use django.contrib.admin.models.LogEntry
# -*- coding: utf-8 -*-
import datetime
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE
class MoniterLog(admin.ModelAdmin):
#dt_utc = datetime.datetime.strptime('action_time', '%Y-%m-%d %H:%M:%S')
#str_utc = 'action_time'
#dt_utc = datetime.datetime.strptime(str_utc, '%Y-%m-%d %H:%M:%S')
#dt_jst = dt_utc + datetime.timedelta(0,3600)
#str_jst = dt_jst.strftime('%Y/%m/%d %H:%M:%S')
@akisute
akisute / gist:5790904
Created June 16, 2013 05:41
Great example code of how to detect major version of running iOS. Uses dispatch_once for performance.
NSUInteger DeviceSystemMajorVersion();
NSUInteger DeviceSystemMajorVersion() {
static NSUInteger _deviceSystemMajorVersion = -1;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
});
return _deviceSystemMajorVersion;
}
// http://tour.golang.org/#70
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// http://go-tour-jp.appspot.com/#23
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
@akisute
akisute / FuckUnity.cs
Created May 24, 2013 08:37
In Unity 4.1.3f3 this code crashes the MonoDevelop's debugger (It worked in Unity 4.1.2f3 / 4.1.0f1)
using UnityEngine;
using System.Collections;
using System;
public class FuckIt : MonoBehaviour {
// Use this for initialization
void Start () {
DateTime now = DateTime.Now;
Debug.Log (now); // Add a breakpoint here and IT CRASHES