Skip to content

Instantly share code, notes, and snippets.

@theorm
theorm / .gitconfig
Last active January 19, 2020 15:48
[user]
email = xxx@yyy.com
[alias]
# View the SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph
lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
ls = ls-files
@theorm
theorm / Dockerfile
Last active August 9, 2022 16:34
Serve a fairseq summary model as an API
FROM python:3.6.6-slim
WORKDIR /fia
RUN apt-get update
# the big one
RUN pip install torch
RUN apt-get install -y --no-install-recommends build-essential wget
import { loadSync, Options } from '@grpc/proto-loader'
import { PackageDefinition } from 'grpc'
const ProtoBaseDir = process.env.JETSETTER_SCHEMAS_PATH || `${__dirname}/../../../schemas`
const DefaultLoadOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: false,
@theorm
theorm / KeyUtils.java
Last active June 8, 2020 08:12
Validate web push JWT tokens with VAPID
import com.google.common.io.BaseEncoding;
import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.interfaces.ECPrivateKey;
import org.bouncycastle.jce.interfaces.ECPublicKey;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
import org.bouncycastle.jce.spec.ECParameterSpec;
import org.bouncycastle.jce.spec.ECPrivateKeySpec;
import org.bouncycastle.jce.spec.ECPublicKeySpec;
import org.bouncycastle.math.ec.ECPoint;
// Converts from degrees to radians.
Math.radians = function(degrees) {
return degrees * Math.PI / 180;
};
// Converts from radians to degrees.
Math.degrees = function(radians) {
return radians * 180 / Math.PI;
};

convert array A, B into C where postcode matches:

A:

[
  {
    "id": "1",
    "name": "John Doe",
 "address": {
// RSA encrypt/decrypt using http://travistidwell.com/jsencrypt/demo/
var publicKey = "MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgH/i6o0R9+Y/4gc1S8YVqq+LW8WO ZBATp2QvB0QzrnG1cN7jVnhGSBc8IYWCSjor3y7YGUxS3zOn17Sd1QreTaMqA61a\nEVznt25CCdghsJz0Ctsk/TioQQQ4yL7xMKn/94IoM+ebuuw+/DQjEFo2GgZLcvOfBk2Gjfe6OuDDu3slAgMBAAE=";
var privateKey = "MIICWgIBAAKBgH/i6o0R9+Y/4gc1S8YVqq+LW8WOZBATp2QvB0QzrnG1cN7jVnhGSBc8IYWCSjor3y7YGUxS3zOn17Sd1QreTaMqA61aEVznt25CCdghsJz0Ctsk/TioQQQ4yL7xMKn/94IoM+ebuuw+/DQjEFo2GgZLcvOfBk2Gjfe6OuDDu3slAgMBAAECgYA6SQRXaSIPuXvdhyfSztstCJm570yhmyOGYHyyU8+kmWoo23n0dSu0Ez6/54LHAmnEos7c30RE+bEw62JGgszk9HI6K3EJGV0dP9WWUJieP/jM5YG//rq3im1eP/7e0KsxCFxlMUTreN7bG9VvQIBLMTgAj3LlW4QBGH0z0yHLPQJBALhgoeWisSqChMvL6YwDOvyWkkeUa9YuqQ2ZYakKvG9JUmirp1q57Fr0Q41i1NHcc0JLtdhOvs3ybmXeHCBueUcCQQCxkIs0bsTh3Ku1wt8qEDsGTGFbg5RTnNThfGAbaGMkjTnW/JpV4Z2clRVN8clS7nXW4CPjgJYY1kIPODGp5R4zAkBXJ35/8Ra0FHw3ZY1hXMmOSpKc+WC8HtRUlFNgt615IXyt864pKce6+snP1I7rILzu8qDjvd1dtqJOzt4WyoHTAkAwqncctcdMSBjfxjs34h7rSP/d/yAmEnPeISKOIHwbxoE1xSHfq+hwxAOEy2Hs

Keybase proof

I hereby claim:

  • I am theorm on github.
  • I am kalyakin (https://keybase.io/kalyakin) on keybase.
  • I have a public key whose fingerprint is C7C8 250F 5B91 1F39 6A8D 91E2 A90B E137 CB77 31C9

To claim this, I am signing this object:

@theorm
theorm / TimerRefresher.js
Last active March 10, 2016 15:25
Periodical tasks runner for Angular.js.
// Runs tasks periodically. Is able to freeze when page is not active.
// Requires visibility.js: https://github.com/ai/visibilityjs
angular.module('someting', [])
.run(['$rootScope', function($rootScope) {
// wrapping visibility API into $rootScope.
// page becomes hidden when user switched tabs or minimized the window

Install

Make sure we have Final Cut Pro X and correct version of ffmpeg installed.

brew uninstall ffmpeg
brew install ffmpeg --with-theora --with-libogg --with-libvorbis --with-libvpx

Export