Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
@dchest
dchest / autobuild
Created February 8, 2009 00:06
"Tag, build, zip, upload, etc" automation script
#!/usr/bin/env perl
use File::Temp qw/ tempdir /;
use File::Path qw/ rmtree /;
use File::Spec::Functions;
print "autobuild (C) 2009 Dmitry Chestnykh and friends (http://twitter.com/dchest/friends)\n\n";
if ($#ARGV < 3) {
usage();
@dchest
dchest / gist:77178
Created March 10, 2009 22:22
Apple's i386 implementation of strlen() from libc sources of Darwin. (for this thread http://news.ycombinator.com/item?id=510326)
/*
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
@dchest
dchest / log2icalendar.rb
Created April 14, 2009 02:24
Outputs git log in iCalendar (.ics) format
#!/usr/bin/env ruby
#
# Git log to iCalendar
#
# Written by Dmitry Chestnykh, 5 Aug 2008
# Public domain
#
# Usage:
#
# cd git-repo
@dchest
dchest / gist:97823
Created April 18, 2009 23:17
Detect clicked segment in NSSegmentedCell subclass
// -------------------- CRSegmentedCell.h ------------------------------
#import <Cocoa/Cocoa.h>
@interface CRSegmentedCell : NSSegmentedCell {
NSInteger highlightedSegment;
}
@property(assign) NSInteger highlightedSegment;
@end
@dchest
dchest / CRToolPopUpButton.h
Created April 27, 2009 00:24
NSPopUpButton sublass for use in toolbars (to get toolbar item with drop-down menu)
// Public domain code
#import <Cocoa/Cocoa.h>
@interface CRToolPopUpButton : NSPopUpButton {
NSControlSize controlSize;
IBOutlet NSToolbarItem *toolbarItem;
}
@property(assign) NSControlSize controlSize;
@dchest
dchest / gist:176995
Created August 28, 2009 14:02
MacRuby 0.5-trunk: rake install log
~/Projects/MacRuby-trunk $ sudo rake install --trace
(in /Users/dmitry/Projects/MacRuby-trunk)
** Invoke install (first_time)
** Invoke framework:install (first_time)
** Invoke framework:info_plist (first_time)
** Execute framework:info_plist
** Invoke framework:install_ext (first_time)
** Execute framework:install_ext
cd ext/ripper
/usr/bin/make top_srcdir=../.. ruby="../../miniruby -I../.. -I../../lib" extout=../../.ext hdrdir=../../include arch_hdrdir=../../include install
#!/usr/bin/env ruby
# Convert Git repository to Fossil
#
# Use this script inside git working copy:
# (make a backup copy before using it!)
#
# $ cd git-repo
# $ ruby ../git2fossil.rb
#
@dchest
dchest / post-update
Created November 27, 2009 00:43
Git post-update hook to checkout working copy and publish it with jekyll (put it into .git/hooks and chmod +x post-update)
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
@dchest
dchest / gist:250234
Created December 6, 2009 13:56
Simple toy html writer in ruby
# Simple toy html writer in ruby
def tag(name, *args)
a = args.length > 0 ? " " + args.join(" ") : ""
a = "" if a == " "
name = "p" if name == "§"
block_given? ? "<#{name}#{a}>" + yield + "</#{name}>\n" : "<#{name}#{a} />"
end
def defmacro(name)
@dchest
dchest / shadows
Created December 15, 2009 20:39
Toggle shadows on screenshots (Cmd+Shift+4 - Space). Run once to disable shadows, run again to enable them back.
#!/bin/sh
(defaults read com.apple.screencapture disable-shadow 2> /dev/null && \
defaults delete com.apple.screencapture disable-shadow && \
echo "Screenshot shadows ON") || \
(defaults write com.apple.screencapture disable-shadow -bool true && \
echo "Screenshot shadows OFF")
killall SystemUIServer