Skip to content

Instantly share code, notes, and snippets.

@hachibeeDI
hachibeeDI / compose.py
Last active August 29, 2015 14:02
Haskellの合成演算子 . をPythonで
def _compose(f_t_u, f_u_r):
return lambda t: f_u_r(f_t_u(t))
class Compose(object):
def __init__(self):
# :type: T -> U
self.func = lambda a: a
def __call__(self, val):
##### Uncrustify config
# Objective-C
# ===== Preprocessor =====
# via: http://qiita.com/items/dd7c5ffdff27451dae16
# #if、#ifdef、#ifndef〜#else〜#endifブロック内のプロプロセッサをインデントするかどうか。{ ignore, add, remove, force }
pp_indent = add
# ソースコードのインデントレベルに合わせてインデントするかどうか。{ true, false }
pp_indent_at_level = true
@hachibeeDI
hachibeeDI / overdrive.swift
Last active August 29, 2015 14:02
こ…こんな!こんなこと!残酷すぎる!
import Foundation
import Cocoa
let CORRECT_CASE = "波紋疾走"
let AN = "深仙脈"
let DO = "波紋"
let TROW = "疾走"

Vimの会

The power tool for everyone.

vim

はじめの.vimrc

Question

How to implement a UITableView with a separator line like this:

doubly separator line

Usually, you can only set the separatorLine property of a UITableView with to single line or single line etched. Sometimes, it is not enough. So, how to implement a separator line like this?

Answer

# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import DictProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int
@hachibeeDI
hachibeeDI / perhaps.py
Created May 20, 2014 05:58
Object#try in python
# -*- coding: utf-8 -*-
from __future__ import (print_function, division, absolute_import, unicode_literals, )
from operator import methodcaller
class Perhaps(object):
'''
>>> p = Perhaps('hoge huga foo')
>>> P = p.try_('replace', 'huga', 'muoo').try_('upper').apply(print)
# -*- coding: utf-8 -*-
from __future__ import (print_function, division, absolute_import, unicode_literals, )
class Monad(object):
def __init__(self, v):
self.value = v
def __repr__(self):
/* Responsive: yes */
/* <system section="theme" selected="bordeaux"> */
@import "/css/theme/bordeaux/bordeaux.css";
/* </system> */
/* elements {{{ */
/* <system section="background" selected="490A3D"> */
body{
background-color: #2dadac;
color: #fff6d3;
papers = [80, 10, 20, 30, 71, 69, 100]
result = papers.reduce(
{passing: [], rejected: [], }
) do |boxes, paper|
if paper >= 70 then boxes[:passing] else boxes[:rejected] end << (paper)
boxes
end
p result
# => {:passing=>[80, 71, 100], :rejected=>[10, 20, 30, 69]}