Skip to content

Instantly share code, notes, and snippets.

View andreyvit's full-sized avatar

Andrey Tarantsov andreyvit

View GitHub Profile
@andreyvit
andreyvit / PageViewController.h
Created December 17, 2011 16:41
A demo of UIViewController-like class (PageViewController)
#import <UIKit/UIKit.h>
@class PageInfo;
@protocol PageViewControllerDelegate;
@interface PageViewController : NSObject {
NSInteger pageIndex;
@andreyvit
andreyvit / fpdi_with_annots.php
Created March 12, 2012 07:16
FPDI extension to preserve external hyperlinks
<?php
// FPDI extension that preserves hyperlinks when copying PDF pages.
//
// (c) 2012, Andrey Tarantsov <[email protected]>, provided under the MIT license.
//
// Published at: https://gist.github.com/2020422
//
// Note: the free version of FPDI requires unprotected PDFs conforming to spec version 1.4.
// I use qpdf (http://qpdf.sourceforge.net/) to preprocess PDFs before running through this
@andreyvit
andreyvit / remove-old-db-backups.sh
Created March 24, 2012 08:07
A script to remove old DB backup files, keeping one backup per month, one backup per day for the last X months and the last Y backups.
#! /bin/bash
# vim: sw=2 ts=2 et ai
NUM_OLDEST_BACKUPS_TO_KEEP=1
NUM_RECENT_BACKUPS_TO_KEEP=100
NUM_MONTHS_TO_KEEP_DAILY_BACKUPS=4
AUTOMATIC_REMOVAL_THRESHOLD=40
# Deletes old DB backup files from the folder specified as an argument.
#
@andreyvit
andreyvit / DockIcon.h
Created March 25, 2012 16:13
Show in Dock / Menu Bar / Nowhere coordinator
#import <Foundation/Foundation.h>
typedef enum {
AppVisibilityModeNone,
AppVisibilityModeDock,
AppVisibilityModeMenuBar
} AppVisibilityMode;
@andreyvit
andreyvit / tender-proxy.php
Created April 14, 2012 17:13
Tender (tenderapp.com) proxy script
<?php
// Works: browsing, logging in, file downloads, images attached to KB articles
// Doesn't work: posting, file uploads
error_reporting(E_ERROR);
// phpinfo(); exit;
define('OUR_HOST', 'livereload.com');
define('THEIR_HOST', 'livereload.tenderapp.com');
@andreyvit
andreyvit / Rakefile
Created April 16, 2012 11:27
Rake tasks to initialize a new Mac
desc "Install zsh config"
task :zshconfig do
sh 'chsh -s /bin/zsh'
sh 'rm -f ~/.zshrc ~/.zshenv'
sh 'ln -s ~/env/config/zshenv ~/.zshenv'
sh 'ln -s ~/env/config/zshrc ~/.zshrc'
end
desc "Install ssh config"
task :sshconfig do
@andreyvit
andreyvit / gist:2466992
Last active February 13, 2024 07:35
The Open Community Indie Software License

NodeApp UI Architecture

Native side handles the view layer of MVC, while the Node.js backend handles the controller (and model) layers.

Goals:

  • Pleasant and artful code on the backend side
  • No boilerplate code on the native side
  • Keeping the native side to a reasonable minimum (stuff like 'stringByAppendingString' or 'WS_EX_ACCEPTFILES' should still reside in the native land!)
@andreyvit
andreyvit / old-mainwindow.coffee
Created April 27, 2012 05:33
Old RPC-based approach for building the UI (IcedCoffeeScript)
module.exports = class MainWindowUI
show: (callback) ->
@window = new UIWindow 'MainWindow',
addProjectButton: new UIButton
click: =>
LR.log.fyi "Clicked Add Project button"
removeProjectButton: new UIButton
click: =>
LR.log.fyi "Clicked Remove Project button"
@andreyvit
andreyvit / ObjCObject.mm
Created May 5, 2012 04:02
Fake an Objective-C class out of a C++ class
// Fakes an Objective-C class out of a C++ class.
//
// Note that this is a very bad and completely superfluous idea, but after looking up a way
// to build Objective-C classes at run time, I just had to do this no matter what. (Besides,
// I really hated maintaining mutual pointers in UIElement/UIElementDelegate class pairs.)
//
// Building up a whole class from scratch (objc_allocateClassPair) looked like a lot of trouble,
// so I compile a real Objective-C class instead, but instead of instantiating it by regular means
// (alloc/init or class_createInstance), I simply cast a part of a C++ object to (id).
// I've looked at the source code for class_createInstance and this hack should work perfectly,