Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@j796160836
j796160836 / MultiScreen
Created October 2, 2013 23:54
MultiScreen Support in Unity (for iOS)
using UnityEngine;
using System.Collections;
public class MultiScreen : MonoBehaviour
{
Camera extCam;
Camera extCam2d;
void Start ()
{
@j796160836
j796160836 / gist:6806350
Created October 3, 2013 07:29
PHP連接 SQL Server實作分頁
$pageSize=20;
$page=@$_GET['page'];
if(strcmp($page, '')==0)
$page=1;
// 查找資料總數
$sql="SELECT TOP 1 count(*) as count FROM testtable";
$stmt = j_sqlquery($sql, array());
$total=sqlsrv_num_rows($stmt);
NSURL *URL = [NSURL URLWithString:@"http://example.com/"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
op.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
op.responseSerializer =[AFHTTPResponseSerializer serializer];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSStringEncoding big5 = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingBig5_HKSCS_1999);
NSString *string = [[NSString alloc] initWithData:responseObject encoding:big5];
NSLog(@"HTML: %@", string);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSURL *URL = [NSURL URLWithString:@"http://example.com/"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
op.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
op.responseSerializer =[AFHTTPResponseSerializer serializer];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
// NSString* newStr = [NSString stringWithUTF8String:[responseObject bytes]];
NSString* newStr = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"HTML: %@", newStr);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
@j796160836
j796160836 / gist:9450763
Created March 9, 2014 16:58
[iOS] POST取回HTML (UTF-8)
NSURL *URL = [NSURL URLWithString:@"http://example.com/"];
NSString *postString = @"company=Locassa&quality=AWESOME!";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
op.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
op.responseSerializer =[AFHTTPResponseSerializer serializer];
#!/bin/bash
# https://gist.github.com/949831
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/
# command line OTA distribution references and examples
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
#LOG="/tmp/testflight.log"
@j796160836
j796160836 / ReInstallAPK.sh
Last active August 29, 2015 14:02
ReInstallAPK.sh
#!/bin/bash
# Parameter check
if [[ "$1" == *'help' ]] || [[ "$1" == '-h' ]] ;then
echo "Usage:"
echo " Method 1:"
echo " \$ $0 <apk_apk_file> [start]"
echo
echo " Method 2:"
@j796160836
j796160836 / BuildAll.sh
Created July 17, 2014 05:37
Build All Android projects
#!/bin/bash
function StopIfFail(){
# http://www.dotkam.com/2008/10/24/getting-return-code-from-ant-in-shell/
if [ $? -ne 0 ];then
echo "BUILD ERROR: see message above."
exit 1;
else
sleep 1
fi
tell application "Google Chrome"
activate
set theUrl to "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
if (count every window) = 0 then
make new window
end if
set found to false
set theTabIndex to -1