Skip to content

Instantly share code, notes, and snippets.

@y16ra
y16ra / Dockerfile for Gitlab
Last active August 29, 2015 14:04
GitLab作成用Dockerfile
# ubuntu 14.04 for Gitlab
FROM ubuntu:14.04
MAINTAINER hogehoge
RUN apt-get update
RUN apt-get -y install wget zip gcc openssh-server postfix
RUN wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.1.1-omnibus-1_amd64.deb
RUN dpkg -i gitlab_7.1.1-omnibus-1_amd64.deb
@y16ra
y16ra / gist:d850986b198c8c561036
Created July 31, 2014 09:38
GitLabコンテナ構築手順
docker pull sameersbn/gitlab:latest
docker run --name='gitlab' -it --rm -p 10022:22 -p 10080:80 -e 'GITLAB_PORT=10080' -e 'GITLAB_SSH_PORT=10022' sameersbn/gitlab:latest
@y16ra
y16ra / gist:78430f2d4ad640d0e6fc
Created December 16, 2014 07:55
WebHook -> git pull
// for GitHub webhook
router.all('/webhook', function(req, res) {
var cmd = exec("git pull", {
cwd: conf.deploy.dir
}, function(error, stdout, stderr) {
if (error) {
debug("> ERROR (error): " + error);
}
if (stderr && error) {
debug("> ERROR (error): " + error);
@y16ra
y16ra / gist:0e8e22a6f97df4fdc003
Created January 30, 2015 03:49
Javascriptで月末日を取得するサンプル
var today = new Date();
new Date(today.getFullYear(), today.getMonth() + 1, 0);
// error
dt.setFullYear(today.getFullYear());
dt.setMonth(today.getMonth()+1);
dt.setDate(0);
dt.getDate();
@y16ra
y16ra / AccountsViewController.swift
Created February 3, 2015 23:17
iOSでTwitterのアイコンを取得して表示する
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
println("AccountsViewController#tableView cellForRowAtIndexPath called.")
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
// ユーザIDを表示する
cell.textLabel?.text = accounts[indexPath.row].username
// プロフィール画像を取得して非同期で表示させる
var q_global: dispatch_queue_t = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
var q_main: dispatch_queue_t = dispatch_get_main_queue();
cell.imageView?.image = nil;
dispatch_async(q_global, {
@y16ra
y16ra / toppage-purge.py
Created March 6, 2015 06:46
nginx上のproxy cache をpurgeするスクリプト。(http://monasan.info/blog/用)
#!/usr/bin/env python
import os
import commands
# logging config
from logging import getLogger,StreamHandler,Formatter,DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
handler.setFormatter(Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
@y16ra
y16ra / sitemap.js
Created April 23, 2015 08:49
sitemap.xmlをパースしてURLの一覧を取り出す
/*
* 使いにくい部分があったのでいろいろ直していますが
* 基本は以下のライブラリのソースを使っています。
*
* Sitemap Parser
* Copyright (c) 2014 Sean Thomas Burke
* Licensed under the MIT license.
* https://github.com/hawaiianchimp/sitemap-parser.git
*/
@y16ra
y16ra / gcp-storage.js
Created May 8, 2015 10:03
node.jsでGoogle Cloud Strageのファイル操作する例
var projectId = process.env.GCLOUD_PROJECT_ID
var gcloud = require('gcloud')({
projectId: projectId,
keyFilename: '/local/path/to/keyfile'
});
var storage = gcloud.storage();
var bucket = storage.bucket('storageName');
var options = {
destination: '2015/05/file',
@y16ra
y16ra / save_mail_attachments.js
Created May 12, 2015 10:15
JXA(Javascript for Automation)で添付ファイルを保存する
var Mail = Application("Mail");
Mail.includeStandardAdditions = true;
// 選択したメッセージを取得
var messages = Mail.selection();
for (i = 0; i < messages.length; i++) {
var thisMessage = messages[i];
// メッセージに添付されたファイルを取得しhogehogeユーザホームに保存する
var atFiles = thisMessage.mailAttachments();
@y16ra
y16ra / fq5-query.sql
Created May 28, 2015 04:40
FQ5 Query
select
id,
case
when ((dt_bit & 31) = 31) then 5
when ((dt_bit & 15) = 15) then 4
when ((dt_bit & 7) = 7) then 3
when ((dt_bit & 3) = 3) then 2
when ((dt_bit & 1) = 1) then 1
else 0
end as fq