Skip to content

Instantly share code, notes, and snippets.

View andreyvit's full-sized avatar

Andrey Tarantsov andreyvit

View GitHub Profile
@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"

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 / gist:2466992
Last active February 13, 2024 07:35
The Open Community Indie Software License
@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 / 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 / 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 / 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 / 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 / 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 / output.txt
Created August 16, 2011 10:03
Node.js (x64) runs out of memory despite using less than 2G
% coffee test.coffee
MEM: rss 0.02 Gb, vsize 2.91 Gb, heapTotal 0.01 Gb, heapUsed 0.01 Gb
File no. 1
process: 2474ms
MEM: rss 0.24 Gb, vsize 3.11 Gb, heapTotal 0.23 Gb, heapUsed 0.22 Gb
File no. 2
process: 4509ms
MEM: rss 0.64 Gb, vsize 3.5 Gb, heapTotal 0.63 Gb, heapUsed 0.6 Gb
File no. 3
process: 3076ms