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 / force-font-smoothing.sh
Created December 24, 2018 16:07
macOS force font smoothing subpixel antialiasing
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
@paiv
paiv / conway.py
Last active November 30, 2017 15:42
Conway's Game of Life
#!/usr/bin/env python3
import numpy as np
from PIL import Image
def conway():
size = (421, 1263)
iterations = 19780
data = np.random.randint(0, 2, size, dtype=np.uint8)
#!/bin/sh
# From: https://github.com/cielavenir/flashupdate/
#Note: use for installing to ~/Library or updating globally.
#New global installation should use normal installer.
if [ `whoami` == "root" ];then
export HOME=""
fi
@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
{
@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 / 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 / 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 / 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 =