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 / 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
@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 / 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 / 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 / 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 / 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 / main.cpp
Created December 24, 2015 21:32
String GetHashCode from mscorlib (.NET)
#include <iostream>
using namespace std;
typedef unsigned short u16;
typedef unsigned int u32;
typedef int s32;
typedef wchar_t wc;
static s32
@paiv
paiv / ml-audiofix.sh
Last active March 18, 2016 07:40
Coursera ML: download lectures and fix audio volume
#!/bin/bash
set -e
mkdir -p "source"
curl -RL# "https://class.coursera.org/ml-005/lecture/download.mp4?lecture_id=[1-114]" -o "source/lecture#1.mp4"
rm "source/lecture94.mp4"
mkdir -p "fixed"
@paiv
paiv / mathcalc.js
Last active October 29, 2023 11:13
Expression parser in JavaScript
//
// MathCalc: a parser for basic mathematical expressions
// From here: https://paiv.github.io/blog/2016/03/23/js-calc.html
//
//
// Copyright (c) 2016, Pavel Ivashkov, github.com/paiv
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
@paiv
paiv / bign.hpp
Created April 23, 2016 15:12
BigDigits C++ starter code
#include <iostream>
#include <bigd.h> // http://www.di-mgt.com.au/bigdigits.html
using namespace std;
namespace paiv
{
typedef uint32_t u32;
class Big
{