Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ikonst's full-sized avatar

Ilya Priven ikonst

  • New York, NY
  • 07:14 (UTC -04:00)
View GitHub Profile
from github import Github
from csv import DictWriter
# Generate on https://github.com/settings/tokens
TOKEN = '<REDACTED>'
ORG = 'lyft'
AUTHOR = '<github username here>'
g = Github(login_or_token=TOKEN)
org = g.get_organization(ORG)
from mongoengine import Document, EmbeddedDocument, Q, ReferenceField
from pymongo.read_preferences import ReadPreference
all_models = Document.__subclasses__()
def referencing_models(document):
for model in all_models:
if issubclass(model, EmbeddedDocument):
continue
fields = [field for field in get_reference_fields_of_model(model)
#!/bin/sh
set -e
# Converts a Quicktime movie to a GIF aniamtion.
# Useful for screen recordings.
# Preliminary step with palette required to make it look good
# without dithering artifacts.
FPS=10
PALETTE=$(mktemp).png
@ikonst
ikonst / private.xml
Created March 18, 2016 21:34
Microsoft L5V-00001 Sculpt Ergonomic Desktop Keyboard and Mouse — private.xml for Karabiner
<?xml version="1.0"?>
<root>
<!--
Based on:
https://blog.yorkxin.org/posts/2014/04/12/microsoft-sculpt-mobile-mouse-and-mac/
Button 4 is the side button (located by the blue Windows button).
This allows you to map the Windows button as Button 5.
1. brew cask install karabiner
#!/bin/sh -e
# Converts a Quicktime movie to a GIF aniamtion.
# Useful for screen recordings.
# Preliminary step with palette required to make it look good
# without dithering artifacts.
FPS=10
PALETTE=$(mktemp).png
MOV=$1
@ikonst
ikonst / cfdata.py
Last active January 27, 2024 22:18
LLDB extension for saving CFData to local file; useful for remote iOS debugging
'''
INSTALLING
curl --create-dirs -o ~/.lldb/cfdata.py https://gist.githubusercontent.com/ikonst/364af37c44e5f549b722/raw/cfdata.py \
&& echo 'command script import ~/.lldb/cfdata.py' >> ~/.lldbinit
USING
(lldb) cfdata_save some_cfdata /Users/john/foo
(lldb) cfdata_save some_nsdata /Users/john/bar
@ikonst
ikonst / xcode-rainbow.c
Created July 27, 2015 17:30
XCode Rainbow Print
// 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 / cancelable_worker_thread.c
Last active August 29, 2015 14:25
Cancelable worker thread
#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 / NSMutableAttributedString+FontWithFamily.h
Last active August 29, 2015 14:25
Enables creating a UIFont that's a variant of another font in a different family
@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 / NSData+GStreamer.h
Created July 1, 2015 13:12
NSData+GStreamer
@import Foundation;
#include <gst/gst.h>
@interface NSData (GStreamer)
- (GstBuffer *)gstBuffer;
@end
@interface NSMutableData (GStreamer)