Skip to content

Instantly share code, notes, and snippets.

View kkebo's full-sized avatar
📱
Using iPad Pro 13” (M4)

Kenta Kubo kkebo

📱
Using iPad Pro 13” (M4)
View GitHub Profile
@aki-null
aki-null / gist:1497649
Created December 19, 2011 15:23
Core Text APIを使用した際に起こる行間の問題の回避
NSFont *normalFont = [NSFont systemFontOfSize:12];
CGRect renderFrame = CGRectMake(0, 0, 300, 50); // box to render the text into
static NSLayoutManager *layMan = nil;
if (!layMan) {
layMan = [NSLayoutManager new];
}
CGFloat lineHeight = [layMan defaultLineHeightForFont:normalFont]; // calculate the expected height of a line
NSDictionary *attrDict = [NSDictionary dictionaryWithObject:normalFont andKey:NSFontAttributeName];
@pudquick
pudquick / pipista.py
Created November 20, 2012 07:23
pipista - pip module (for installing other modules) for Pythonista
import os, os.path, sys, urllib2, requests
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def _chunk_report(bytes_so_far, chunk_size, total_size):
if (total_size != None):
@uhtred
uhtred / mixin-linear-gradient.scss
Created July 23, 2014 21:49
SASS: Mixin Linear Gradient
@mixin linear-gradient( $start: #f1f1f1, $from: 0%, $stop: #d9d9d9, $to: 100% ) {
background: $start;
background: -webkit-gradient(linear, left top, left bottom, from(ie-hex-str($start)), to(ie-hex-str($stop)));
background: -moz-linear-gradient(center top, $start $from, $stop $to);
background: -moz-gradient(center top, $start $from, $stop $to);
background: -webkit-linear-gradient(top, $start $from,$stop $to);
background: -o-linear-gradient(top, $start $from,$stop $to);
background: -ms-linear-gradient(top, $start $from,$stop $to);
background: linear-gradient(to bottom, $start $from,$stop $to);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#{ie-hex-str($start)}', endColorstr='#{ie-hex-str($stop)}',GradientType=0 );
@akanehara
akanehara / scope.coffee
Last active August 29, 2015 14:04
var がないことによる問題
# var がないことによる問題
# 関数sum内の x がローカル変数であることをいつも保証できない
# このコメントアウトを外すと sum 内の x はローカル変数でなくなる
# x = 100
sum = (n) ->
x = 0
for i in [1..n]
x += i
@geomaedr
geomaedr / gist:1926562ab9b051552a4c
Last active August 29, 2015 14:04 — forked from padolsey/gist:527683
JavaScript: Detect IE
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@omz
omz / Add Web Tab.py
Last active December 3, 2023 23:33 — forked from steventroughtonsmith/Add Web Tab.py
Insert a custom browser tab into Pythonista
# coding: utf-8
from objc_util import *
import console
import urllib
import dialogs
WKWebView = ObjCClass('WKWebView')
UIViewController = ObjCClass('UIViewController')
UIBarButtonItem = ObjCClass('UIBarButtonItem')
NSURLRequest = ObjCClass('NSURLRequest')
@voluntas
voluntas / realtime_movie_stream.rst
Last active May 18, 2023 04:25
リアルタイム動画配信コトハジメ
@steventroughtonsmith
steventroughtonsmith / main.m
Created March 24, 2016 08:08
Load Mach-O executable at runtime and execute its entry point
void callEntryPointOfImage(char *path, int argc, char **argv)
{
void *handle;
int (*binary_main)(int binary_argc, char **binary_argv);
char *error;
int err = 0;
printf("Loading %s…\n", path);
handle = dlopen (path, RTLD_LAZY);
@robo8080
robo8080 / FaceDetectTest2.py
Created September 3, 2016 12:29
FaceDetectTest2.py
# coding: utf-8
import photos
import console
from objc_util import *
CIFilter, CIImage, CIContext, CIDetector, CIVector = map(ObjCClass, ['CIFilter', 'CIImage', 'CIContext', 'CIDetector', 'CIVector'])
def take_photo(filename='.temp.jpg'):
img = photos.capture_image()
@manasthakur
manasthakur / plugins.md
Last active June 2, 2024 07:29
Managing plugins in Vim

Managing plugins in Vim: The basics

Let's say the plugin is at a GitHub URL https://github.com/manasthakur/foo. First get the plugin by either cloning it (git clone https://github.com/manasthakur.foo.git) or simply downloading it as a zip (from its GitHub page).

Adding a plugin in Vim is equivalent to adding the plugin's code properly into its runtimepath (includes the $HOME/.vim directory by default). For example, if the layout of a plugin foo is as follows:

foo/autoload/foo.vim
foo/plugin/foo.vim