Skip to content

Instantly share code, notes, and snippets.

View mitsuse's full-sized avatar
💭
🐈🐈

mitsuse mitsuse

💭
🐈🐈
View GitHub Profile
@mitsuse
mitsuse / file0.go
Last active August 29, 2015 14:23
gocron でジョブスケジューリング ref: http://qiita.com/mitsuse/items/8669bf54d2310b3e68a1
package main
import (
"fmt"
"github.com/jasonlvhit/gocron"
)
func main() {
scheduler := gocron.NewScheduler()
@mitsuse
mitsuse / LICENSE.txt
Last active August 29, 2015 14:26
Watch updating a file written in DOT and generate the graph. This gist requires watchdog (https://github.com/gorakhargosh/watchdog).
The MIT License (MIT)
Copyright (c) 2015 Tomoya Kose.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@mitsuse
mitsuse / pre-push.py
Last active November 17, 2015 01:53
Forbid to push remote branches specified with an environment variable "GIT_PROTECTED_BRANCHES".
#!/usr/bin/env python3
# coding: utf-8
def main():
import sys
local_ref, local_sha1, remote_ref, remote_sha1 = sys.stdin.readline().split()
remote_branch = extract_branch(remote_ref)
if remote_branch in list_protected_branches():
@mitsuse
mitsuse / GenericNode.swift
Last active January 14, 2016 11:23
Example: Automatic initializer inheritance doesn't work for generic types.
class Node<T> {
let value: T
init(value: T) {
self.value = value
}
}
class Terminal<T>: Node<T> {
}
@mitsuse
mitsuse / unzip_cp932.py
Created January 27, 2016 03:54
Unzip files encoded with cp932.
#!/usr/bin/env python3
# coding: utf-8
def main(context):
from zipfile import ZipFile
with ZipFile(context.archive) as f:
if context.password is not None:
f.setpassword(context.password.encode())
@mitsuse
mitsuse / reader_multi.go
Created February 15, 2016 15:52
Simplify error checking of `binary.Read` by iterating over a slice of pointers.
package main
import (
"bytes"
"encoding/binary"
"fmt"
"os"
)
func main() {
@mitsuse
mitsuse / ConditionalPresenter.swift
Created April 1, 2016 01:12
An implementation of view controller to choose and present a view conditionally.
import UIKit
public protocol ConditionalPresenter: class {
var view: UIView! { get }
func addChildViewController(childController: UIViewController)
var current: UIViewController! { get set }
func generateController() -> UIViewController
}
@mitsuse
mitsuse / brew-install-sourcekiite-daemon.log
Last active April 16, 2016 13:19
Formula for SourceKittenDaemon 0.1.5.
==> Cloning https://github.com/terhechte/SourceKittenDaemon.git
Updating /Library/Caches/Homebrew/sourcekitten-daemon--git
git config remote.origin.url https://github.com/terhechte/SourceKittenDaemon.git
git config remote.origin.fetch +refs/tags/0.1.5:refs/tags/0.1.5
==> Checking out tag 0.1.5
git checkout -f 0.1.5 --
HEAD is now at 2a8eef4... Bump to 0.1.5
git reset --hard 0.1.5
HEAD is now at 2a8eef4 Bump to 0.1.5
git submodule foreach --recursive git submodule sync
@mitsuse
mitsuse / Map.swift
Last active June 23, 2016 05:38
A workaround for iOS 8.x, which cannnot use `q` parameter as the label of pin. (Swift 2.2)
import Foundation
public func buildMapUrl(
latitude latitude: Double,
longitude: Double,
label: String
) -> NSURL? {
let components = NSURLComponents(string: "http://maps.apple.com/")
if #available(iOS 9, *) {
@mitsuse
mitsuse / swiftlint.yml
Created September 20, 2016 03:55
A config file to format source codes automatically with SwiftLint.
whitelist_rules:
# Correctable rules
- "colon"
- "comma"
- "leading_whitespace"
- "legacy_cggeometry_functions"
- "legacy_constrant"
- "legacy_constructor"
- "legacy_nsgeometry_functions"
- "return_arrow_whitespace"