Skip to content

Instantly share code, notes, and snippets.

@akirakiron
akirakiron / one.cpp
Last active December 12, 2015 06:28
C++で静的ライブラリをリンクする時の引数の順番で詰まったのでメモ. ライブラリ間に依存関係がある場合には,依存している方を前に,依存されている方を後に置く. そうしないと'undefined reference'エラーになる. arコマンドで一つのライブラリにまとめる際は,引数の順番は気にする必要はない.
int get_zero();
int get_one() {
return get_zero() + 1;
}
@satojkovic
satojkovic / sift_match.rb
Last active March 12, 2019 15:21
image matching using SIFT
#!/usr/bin/env ruby
require 'rubygems'
require 'rmagick'
include Math
class KDTreeNode
attr_accessor :data, :left_child, :right_child
@ryanmaxwell
ryanmaxwell / ryan-objc.cfg
Last active June 26, 2019 16:41
Objective-C Uncrustify Config
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.2 (140)
#
# Alignment
# ---------
## Alignment
@fukamachi
fukamachi / gist:4109258
Last active May 27, 2016 21:05
Pretty lambda/nil for Emacs
;; This function is quoted from this page. Thanks to Tomohiro Matsuyama.
;; http://dev.ariel-networks.com/Members/matsuyama/pretty-lambda-in-emacs/
(defun set-pretty-patterns (patterns)
(loop for (glyph . pairs) in patterns do
(loop for (regexp . major-modes) in pairs do
(loop for major-mode in major-modes do
(let ((major-mode (intern (concat (symbol-name major-mode) "-mode")))
(n (if (string-match "\\\\([^?]" regexp) 1 0)))
(font-lock-add-keywords major-mode
`((,regexp (0 (prog1 ()
@hayajo
hayajo / changelog_en.md
Last active April 1, 2025 14:37
ChangeLog を支える英語

ChangeLog を支える英語

ChangeLog を書く際によく使われる英語をまとめました。

ほとんど引用です。

基本形

@mralexgray
mralexgray / customURL.m
Created October 19, 2012 00:33
Register Cocoa app for a custom URL scheme
Here is what you need to do to register your app for a custom URL scheme (for the example we will use a "myapp" scheme).
1) In your Info.plist, add a new entry for CFBundleURLTypes: <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>MyApp's URL</string> <key>CFBundleURLSchemes</key> <array> <string>myapp</string> </array> </dict> </array>
2) Somewhere in your application's startup code (e.g. init), add this code: - (void)registerMyApp { [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; }
- (void)getUrl:(NSAppleEventDescriptor )event withReplyEvent:(NSAppleEventDescriptor )replyEvent { NSString url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; // Now you can parse the URL and perform whatever action is needed }
Related Tidbits:
@Gab-km
Gab-km / github-flow.ja.md
Last active July 1, 2025 15:44 — forked from juno/github-flow.ja.md
GitHub Flow (Japanese translation)
@azu
azu / 1.m
Created June 18, 2012 13:49
NSArrayからNSIndexSetに該当するAtIndexのものだけを取り出したNSArrayを取得
NSMutableArray *dataSource;
NSMutableIndexSet *selectedIndexSet;
/*
dataSource,selectedIndexSetに突っ込む処理
*/
// dataSourceからselectedIndexSetにマッチするものだけを取り出す。
NSMutableArray *resultArray = [NSMutableArray array];
[self.selectedIndexSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
[resultArray addObject:[self.dataSource objectAtIndex:idx]];
}];
@kumagi
kumagi / benchmark.cc
Created June 17, 2012 03:23
single thread Hopscotch hashing with C++
#ifndef MAP_HPP
#define MAP_HPP
//#include <cstdint>
#include <stdint.h>
#include <cstddef>
#include <map>
#include <functional>
#include <boost/functional/hash.hpp>
#include <memory>
#include <utility>
@hollance
hollance / gist:2936287
Created June 15, 2012 12:42
Drawing inner glow with Core Graphics
- (CGImageRef)createMaskFromAlphaChannel:(UIImage *)image
{
size_t width = image.size.width;
size_t height = image.size.height;
NSMutableData *data = [NSMutableData dataWithLength:width*height];
CGContextRef context = CGBitmapContextCreate(
[data mutableBytes], width, height, 8, width, NULL, kCGImageAlphaOnly);