Skip to content

Instantly share code, notes, and snippets.

Avatar

Ilya Konstantinov ikonst

View GitHub Profile
@ikonst
ikonst / git_tfs_add_date.pl
Created Mar 31, 2014
git commit message filter that adds the original committer timestamp to the comment. (This is due to the fact that it's impossible to specify a timestamp during TFS checkin.)
View git_tfs_add_date.pl
#!/usr/bin/perl
#
# Execute with:
#
# git filter-branch -f --msg-filter 'perl /path/to/git_tfs_add_date.pl' HEAD
#
use POSIX;
open INPUT, "<-";
$ENV{'GIT_COMMITTER_DATE'} =~ /^@(.*) \+(\d\d)(\d\d)/;
@ikonst
ikonst / gst.py
Last active Aug 29, 2015
GStreamer extensions for LLDB
View gst.py
# To use:
# 1) Save to $HOME
# 2) echo 'command script import ~/gst.py' >> ~/.lldbinit
# 3) From within lldb:
#
# To open pipeline graph in Graphviz:
#
# gst_dot foobar
#
# foobar: any expression of type GstObject* -- e.g. GstElement*, GstPad* or GstBin*
@ikonst
ikonst / gist:8f94b537731d8a1744cb
Created Mar 31, 2015
Connecting GLib g_log to NSLog
View gist:8f94b537731d8a1744cb
void my_log_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
{
NSLog(@"%@", [NSString stringWithUTF8String:message]);
}
...
g_log_set_default_handler( my_log_handler, NULL);
@ikonst
ikonst / applemedia-setjmp-longjmp.patch
Created Apr 5, 2015
avfvideosrc: setjmp/longjmp patch
View applemedia-setjmp-longjmp.patch
From c3199506fd03e77b61cd6fdfbd8184e1effb28ba Mon Sep 17 00:00:00 2001
From: Ilya Konstantinov <ilya.konstantinov@gmail.com>
Date: Sun, 5 Apr 2015 05:39:14 +0300
Subject: [PATCH] applemedia: setjmp/longjmp
Migrate the pipeline into the AVFoundation dispatch queue thread
to enable operation without context switching and unneeded yielding.
---
sys/applemedia/avfvideosrc.m | 101 ++++++++++++++++++++++++++++---------------
1 file changed, 66 insertions(+), 35 deletions(-)
@ikonst
ikonst / NSMutableAttributedString+FontWithFamily.h
Last active Aug 29, 2015
Enables creating a UIFont that's a variant of another font in a different family
View NSMutableAttributedString+FontWithFamily.h
@import Foundation;
@interface NSMutableAttributedString (FontWithFamily)
// Modifies the attributed text to change the font family while keeping
// font size and traits.
- (void)setFontFamily:(NSString *)fontFamily inRange:(NSRange)range;
- (void)setFontFamily:(NSString *)fontFamily;
@end
@ikonst
ikonst / cancelable_worker_thread.c
Last active Aug 29, 2015
Cancelable worker thread
View cancelable_worker_thread.c
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/time.h>
#include <sys/errno.h>
struct thread_data {
pthread_cond_t cond;
int finished;
@ikonst
ikonst / xcode-rainbow.c
Created Jul 27, 2015
XCode Rainbow Print
View xcode-rainbow.c
// Prints rainbow-colored text into the Xcode output window.
// Required the XcodeColors plugin:
// https://github.com/robbiehanson/XcodeColors
void XcodeRainbowLog(const char *str)
{
float hueStep = 1.0 / strlen(str);
float hue = 0.0;
for (char *c = str; *c != '\0'; ++c) {
UIColor *color = [UIColor colorWithHue:hue saturation:1 brightness:0.8 alpha:1];
hue += hueStep;
@ikonst
ikonst / libusb-1.0.9-android-log.patch
Created Aug 14, 2012
libusb 1.0.9 Android logging patch
View libusb-1.0.9-android-log.patch
--- libusb-1.0.9/libusb/core.c Fri Apr 20 09:44:27 2012
+++ libusb-1.0.9/libusb/core.c Tue Aug 14 17:29:08 2012
@@ -31,6 +31,10 @@
#include <sys/time.h>
#endif
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
+
@ikonst
ikonst / putty.iss.patch
Created Nov 9, 2012
PuTTY InnoSetup "Add to PATH" patch
View putty.iss.patch
Index: putty.iss
===================================================================
--- putty.iss (revision 9586)
+++ putty.iss (working copy)
@@ -77,6 +77,9 @@
Name: desktopicon\user; Description: "For the current user only"; GroupDescription: "Additional icons:"; Flags: exclusive unchecked
Name: quicklaunchicon; Description: "Create a &Quick Launch icon for PuTTY (current user only)"; GroupDescription: "Additional icons:"; Flags: unchecked
Name: associate; Description: "&Associate .PPK files (PuTTY Private Key) with Pageant and PuTTYgen"; GroupDescription: "Other tasks:"
+Name: path; Description: "Add PuTTY to the system &path"; GroupDescription: "Other tasks:"
+Name: path\common; Description: "For all users"; GroupDescription: "Other tasks:"; Flags: exclusive unchecked
@ikonst
ikonst / MountInfo.java
Created Aug 19, 2012
Java code to parse /proc/mounts.
View MountInfo.java
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
/**
* Parses of /proc/mounts.
*/
public class MountInfo {