Skip to content

Instantly share code, notes, and snippets.

View vojto's full-sized avatar
🎯
Focusing

Vojtech Rinik vojto

🎯
Focusing
  • Kosice, Slovakia
  • 19:21 (UTC -12:00)
  • X @_vojto
View GitHub Profile
@vojto
vojto / gist:2916332
Created June 12, 2012 09:02
Resource
Mongolian = require('mongolian')
ObjectId = Mongolian.ObjectId
Server = require('./server')
Service = require('./service')
{log, log2, loge} = require('./util')
class ResourcesServer extends Server
constructor: (@app) ->
@service = new ResourcesService(@app)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>mdown</string>
<string>markdown</string>
<string>markdn</string>
<string>md</string>
@vojto
vojto / gist:3954249
Created October 25, 2012 17:41
Cocoa script for getting definitions of words
int main(int argc, const char * argv[])
{
@autoreleasepool {
if (argc == 1) {
return 1;
}
NSString *word = [NSString stringWithCString:argv[1] encoding:NSUTF8StringEncoding];
CFStringRef result = DCSCopyTextDefinition(nil, (__bridge CFStringRef)word, CFRangeMake(0, word.length));
@vojto
vojto / ReloadChrome.scpt
Created October 30, 2012 18:09
Script to refresh Chrome remote Chrome browser
tell application "Google Chrome"
reload of active tab of window 1
end tell
@vojto
vojto / gist:4079439
Created November 15, 2012 16:12
Print titles of pages from 10G of compressed Wikipedia data
var fs = require('fs');
var gunzip = require('gzbz2/bunzipstream');
var XmlStream = require('xml-stream');
var stream = gunzip.wrap('./enwiki-20121101-pages-articles.xml.bz2', {});
var xml = new XmlStream(stream);
var countPages = 1;
xml.on('text: page > title', function(el) {
console.log(el.$text);
@vojto
vojto / gist:4110276
Created November 19, 2012 11:53
Python ETL
# Create instance of cleaner
cleaner = Cleaner()
cleaner.table = 'articles'
# Remove leading and trailing whitespace from column 'content'
trim = TrimTransformer()
cleaner.transform_field('content', trim)
# From column 'content', derive word count and store result into column 'word_count'
count = CountDeriver('word_count')
@vojto
vojto / gist:4502928
Created January 10, 2013 15:38
Ruby simulator of Turing Machine with two stacks.
# encoding: utf-8
require "parslet"
require "pp"
require "ap"
require "colored"
program = "q0, (¢,Z,Z), (¢,B,B), q0, (R,-,-)
// Ak pride a, striedavo uklada a raz na 1. raz na 2. zasobnik.
# encoding: utf-8
# Alan
# Two-stack Turing machine simulator
#
# Author: Vojtech Rinik <[email protected]>
# License: MIT
# Example program:
// From anywhere
NKDrawGradientWithHexColors(c, drawingRect, @"f0eef1", @"fbfbfc");
NKDrawBorder(c, drawingRect, NKBorderBottom, 1, @"red");
// From NSView
- (void)style {
[self drawGradientStartColor:@"f0eef1" endColor:@"fbfbfc"];
[self drawBorder:NKBorderBottom lineWidth:1 color:@"red"];
}
@interface NKStyle : NSObject
@property (assign) CGRect frame;
- (id)initWithFrame:(CGRect)frame;
// Background
@property (nonatomic, strong) NKColor *backgroundColor;
// Border
@property (assign) CGFloat borderRadius;