Skip to content

Instantly share code, notes, and snippets.

View Synashida's full-sized avatar

syn256 Synashida

View GitHub Profile
@Synashida
Synashida / LeftDrawerViewController.swift
Created June 26, 2016 14:19
Swift2でMMDrawerContrllerを使って画面遷移する ref: http://qiita.com/Syn256/items/89ed8065f7d63640660e
@IBAction func toView1(sender: UIButton) {
toView("toView1")
}
@IBAction func toView2(sender: UIButton) {
toView("toView2")
}
func toView(segueId: String) {
let mainView = (self.mm_drawerController.centerViewController as! UINavigationController).childViewControllers[0] as! MainViewController
@Synashida
Synashida / file0.txt
Created June 28, 2016 13:56
Swift2でナビゲーションバーの背景・文字色・区切り線をカスタマイズ ref: http://qiita.com/Syn256/items/ebd9e4c2a61606030a2d
// MARK: - NavigationBarの下部に線を引くのと背景色の設定
extension UINavigationController {
/**
ナビゲーションバーの色を共通色に設定し、下線を引く
- parameter animated: <#animated description#>
*/
override public func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
@Synashida
Synashida / PostgreSQLCountDistinctInWindowFunction.sql
Created June 30, 2016 02:18
[PostgreSQL] 分析関数を使ったサブクエリでできるだけローコストにCOUNT(DISTINCT field) OVER()をする ref: http://qiita.com/Syn256/items/ba1019bab9a6beb2664f
-- Window関数でCOUNT(DISTINCT field) OVER()を擬似的に実現する
SELECT
都道府県名
, 公園名
, "訪問者IP"
, 県別訪問者数
, 都道府県別公園別訪問者数
, SUM(都道府県別ユニーク訪問者フラグ) OVER(PARTITION BY 都道府県名 ORDER BY 都道府県名) AS 都道府県別ユニーク訪問者数
, SUM(公園別ユニーク訪問者フラグ) OVER(PARTITION BY 公園名 ORDER BY 公園名) AS 公園別ユニーク訪問者数
, SUM(ユニーク訪問者フラグ) OVER() AS ユニーク訪問者数
@Synashida
Synashida / multi_tenant.conf
Created June 30, 2016 07:09
ApacheでDNSのワイルドカードレコードに対応するVirtual Hostの記述方法(For Rails) ref: http://qiita.com/Syn256/items/88b7fa38b911b2f1b209
# ファイル名は適当です。
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName www.example.com
ServerAlias *.example.com # ここ重要。ここでxxx.example.comのアクセスを受ける宣言をしている。
DocumentRoot /path to your rails app/public
<Directory "/path to your rails app/public">
AllowOverride All
Options FollowSymLinks Includes
Require all granted
@Synashida
Synashida / HealthKit.swift
Created July 1, 2016 10:05
[Swift2]HealthKitから指定日の歩数を取得するサンプル ref: http://qiita.com/Syn256/items/3767514d4c5f3e7087c7
import HealthKit
/// HealthKitから歩数を取得するサンプルプログラム
class HealthKit {
/// HealthKitストレージにアクセスする
var storage:HKHealthStore = HKHealthStore()
/**
HealthKitへのアクセス許可を確認
@Synashida
Synashida / database.yml
Last active July 13, 2016 00:01
Rails+PostGIS+YOLPで現在表示している地域の市区町村境界を描画するサンプル ref: http://qiita.com/Syn256/items/f07ae9b8ab3820aee366
default: &default
adapter: postgis
encoding: unicode
# For details on connection pooling, see rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
username: <ご自身のPostgreSQLユーザ名>
password: <PostgreSQLのパスワード>
host: localhost
port: 5432
@Synashida
Synashida / Form1.cs
Last active July 13, 2016 03:15
C#の大量文字列連結をParallel実行して超高速化 ref: http://qiita.com/Syn256/items/7792b41bce84576ef079
private void ParallelNormalLoop(int threadCount)
{
string lines = "";
DateTime timer = DateTime.Now;
// ここで並列処理を書いています。
Parallel.For(0, threadCount, i =>
{
// Thread内の文字列連結をスレッド外変数に直接行うと
// 同時書き込みが発生し、データが損失するため、スレッドローカルで文字連結を行う
@Synashida
Synashida / file0.txt
Created July 13, 2016 05:15
C# 大量の文字列連結にはStringBuilderだよねってサンプル ref: http://qiita.com/Syn256/items/d3b36680c6777a3e5e09
private void btnExec_Click(object sender, EventArgs e)
{
NormalLoop();
StringBuilderLoop();
PachimonStringBuilderLoop();
MessageBox.Show("Done.");
}
private void NormalLoop()
{
@Synashida
Synashida / MESH03622.gml
Last active July 26, 2016 15:40
PythonでNamespace指定のXMLを読む ref: http://qiita.com/Syn256/items/8335f36d7b2127a1a730
<?xml version="1.0" encoding="UTF-8"?>
<gml:FeatureCollection xmlns:fme="http://www.safe.com/gml/fme" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.safe.com/gml/fme MESH03622.xsd">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:4612" srsDimension="2">
<gml:lowerCorner>24.4333333329177 122.924999999934</gml:lowerCorner>
<gml:upperCorner>24.4833333336014 123.000000000218</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<fme:MESH03622 gml:id="id060c8300-20cf-4750-b6a6-6b9730bc8fb3">
@Synashida
Synashida / App_Start¥BundleConfig.cs
Last active August 2, 2016 02:53
C# ASP.NETでHighchartsを利用するサンプル ref: http://qiita.com/Syn256/items/a1ff8f4b07a36497aca6
bundles.Add(new ScriptBundle("~/bundles/highcharts").Include(
"~/Scripts/Highcharts-4.0.1/js/highcharts.js"));