Skip to content

Instantly share code, notes, and snippets.

View paiv's full-sized avatar
🇺🇦
StandWithUkraine

Pavel Ivashkov paiv

🇺🇦
StandWithUkraine
View GitHub Profile
@paiv
paiv / addlic.sh
Created November 30, 2015 20:17
Prepend source file with MIT license preserving timestamp
#!/bin/bash
set -e
FILE=$1
TEMPFILE=`mktemp`
cat > "$TEMPFILE" <<'LicenseText'
/*
* Copyright (c) <year> <copyright holders>
*
@paiv
paiv / boost_pick.sh
Last active August 29, 2015 14:24
Pick libraries from boost
# download
curl -RLO "http://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_1_58_0.tar.gz"
tar -xzf boost_1_58_0.tar.gz
cd boost_1_58_0
# build tools
./bootstrap.sh --prefix=./dist
./b2 tools/bcp
# extract selected libraries
@paiv
paiv / nettyasync.scala
Created April 24, 2015 12:49
Netty 4.1: Async connect and DNS name resolving
val boot = new Bootstrap()
.group(new NioEventLoopGroup())
.channel(classOf[NioSocketChannel])
.resolver(new DnsNameResolverGroup(classOf[NioDatagramChannel], DnsServerAddresses.defaultAddresses()))
.option(ChannelOption.TCP_NODELAY, java.lang.Boolean.TRUE)
val channelFuture = boot.connect(host, port)
channelFuture.addListener(new ChannelFutureListener {
override def operationComplete(future: ChannelFuture): Unit =
@paiv
paiv / gist:5065281
Created March 1, 2013 15:14
NSArray to va_list arguments and string format
- (NSString *)stringWithFormat:(NSString *)format args:(NSArray *)args
{
NSMutableData *data = [NSMutableData dataWithLength:(sizeof(id) * args.count)];
[args getObjects:(__unsafe_unretained id *)data.mutableBytes range:NSMakeRange(0, args.count)];
NSString *so = [[NSString alloc] initWithFormat:format arguments:data.mutableBytes];
return so;
}
@paiv
paiv / FontsTableViewController.m
Created December 17, 2012 11:46
iOS Fonts table view
//
// FontsTableViewController.m
//
// Created by Pavel Ivashkov on 3/30/11.
//
@implementation FontsTableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
@paiv
paiv / ppm2mpeg4
Created October 3, 2012 12:34
ffmpeg Gource PPM output (Win)
ffmpeg -y -i track.mp3 -vcodec ppm -r 72 -f image2pipe -i gource.ppm -vcodec mpeg4 -r 29.97 -preset veryslow -q:v 1 -threads 0 -b:v 10000k -bf 0 -comp_duration 204 -ac 2 -acodec copy output.mp4