Skip to content

Instantly share code, notes, and snippets.

@jwthanh
jwthanh / Open-source-iOS-apps.md
Last active September 16, 2015 09:32 — forked from Angles/Open-source-iOS-apps.md
real iOS apps with GitHub open source repos

Real iOS Apps in AppStore, with source on GitHub:

thanks 4 putting source for a noob to learn a little

I've used these:

@jwthanh
jwthanh / new_gist_file.sh
Created November 22, 2015 14:51 — forked from un1ko85/new_gist_file.sh
Starting and stopping NginX / MySQL / PHP-FPM on Mac OS X
#! /bin/bash
MYSQL="/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper"
NGINX="/opt/local/sbin/nginx"
PHPFPM="/opt/local/sbin/php-fpm"
PIDPATH="/opt/local/var/run"
MEMCACHED="/opt/local/bin/memcached -m 24 -P /opt/local/var/run/memcached.pid -u root"
if [ $1 = "start" ]; then
sudo $MYSQL start
echo "Starting php-fpm ..."
@jwthanh
jwthanh / updateXcodePlugin.sh
Last active December 2, 2015 12:16
Help to update xcode plugin UUID after upgrade xcode version.
xcodePath=`xcode-select -p`
xcodeUUID=`defaults read "$xcodePath/../../Contents/Info.plist" DVTPlugInCompatibilityUUID`
echo $xcodeUUID
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add $xcodeUUID
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// Dynamic sizing for the header view
if let headerView = tableView.tableHeaderView {
let height = headerView.systemLayoutSizeFittingSize(UILayoutFittingCompressedSize).height
var headerFrame = headerView.frame
// If we don't have this check, viewDidLayoutSubviews() will get
// repeatedly, causing the app to hang.
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
import UIKit
// MARK: - UIView
extension UIView {
@IBInspectable var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set {
@jwthanh
jwthanh / _service.md
Created February 22, 2016 17:33 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@jwthanh
jwthanh / GsonRequest.java
Created March 11, 2016 16:47 — forked from ficusk/GsonRequest.java
A Volley adapter for JSON requests that will be parsed into Java objects by Gson.
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
@jwthanh
jwthanh / OAuthClient.java
Created May 28, 2016 13:16 — forked from dzolnai/OAuthClient.java
Retrofit OAuth2 refreshing tokens without modifying all requests.
package com.example.yourapp;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.example.yourapp.AuthenticationModel;
import retrofit.client.Header;
import retrofit.client.OkClient;