Skip to content

Instantly share code, notes, and snippets.

View alexey-detr's full-sized avatar
🦉

Alexey Ponomarev alexey-detr

🦉
View GitHub Profile
@alexey-detr
alexey-detr / index.js
Created June 6, 2019 10:28
Читаем заголовок WAV файла на Node.js из STDIN
const inputStream = process.stdin;
function readHeader(stream) {
let buffer = stream.read(44);
const chunkId = buffer.slice(0, 4).toString();
const chunkSize = buffer.readUInt32LE(4);
const format = buffer.slice(8, 12).toString();
const subchunk1Id = buffer.slice(12, 16).toString();
const subchunk1Size = buffer.readUInt32LE(16);
@alexey-detr
alexey-detr / prepare-commit-msg.sh
Created April 25, 2019 15:04
Modify a commit message hook
#!/usr/bin/env bash
BRANCH=`git branch | grep '^\*' | cut -b3-`
REFS=`echo "$BRANCH" | sed -E 's/^[^_]+_([0-9]+)_.+$/\1/'`
echo "Refs #$BRANCH - " > $1
@alexey-detr
alexey-detr / downloader.js
Created September 1, 2018 08:31
Downloads most popular lodash dependents
const axios = require('axios');
const cheerio = require('cheerio');
const childProcess = require('child_process');
(async () => {
const {data: npmListHtml} = await axios.get('https://www.npmjs.com/browse/depended/lodash');
const $ = cheerio.load(npmListHtml);
const npmPackageLinks = $('section a').map((i, elem) => $(elem).attr('href')).get();
childProcess.execSync(`rm -rf ${__dirname}/packages`);
@alexey-detr
alexey-detr / base64urldata.fish
Created March 6, 2017 08:35
Fish function to get CSS background-url compatible base64 encoded file data, where filename specified as argument
# You have to install mime package
# npm install -g mime
function base64urldata
set filename $argv[1]
echo "data:"(mime $filename)";base64,"(cat $filename | openssl enc -base64 | tr -d '\n')
end
@alexey-detr
alexey-detr / npm_selfupdate.sh
Created November 25, 2014 06:29
How to update brew version of npm
npm install -g npm@latest
@alexey-detr
alexey-detr / VerifyCodeSignature.reg
Created August 20, 2014 14:40
Fix 1password for Firefox on Windows when there is no menu when addon button was pressed
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\AgileBits\1Password 4]
"VerifyCodeSignature"=dword:00000000
@alexey-detr
alexey-detr / .zshrc
Created August 20, 2014 04:59
Chrome run alias to fix sound jittering / stuttering while using Google Music in OS X
# Existing stuff
alias chrome-audio="osascript -e \"do shell script \\\"open '/Applications/Google Chrome.app' --args --audio-buffer-size=8192\\\"\""
@alexey-detr
alexey-detr / iptables_init.sh
Last active August 29, 2015 14:03
Allow any traffic for loopback. Allow 22, 80 ports. Deny others. Install iptables-persistent to load rules when server boot. I'm using it for default web server configuration.
#!/bin/sh
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -j DROP
sudo iptables -I INPUT 1 -i lo -j ACCEPT
sudo apt-get install iptables-persistent
#!/bin/sh
# Extract certificate
openssl pkcs12 -clcerts -nokeys -in apns-prod-cert.p12 -out apns-prod-cert.pem
# Extract key
openssl pkcs12 -nocerts -in apns-prod-key.p12 -out apns-prod-key.pem
# Remove password from PEM key
openssl rsa -in apns-prod-key.pem -out apns-prod-key-noenc.pem
@alexey-detr
alexey-detr / gist:1382e07ec1986a8d2e42
Created May 30, 2014 10:08
Media query for small screens
only screen and (-webkit-min-device-pixel-ratio: 1) and (max-device-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 1) and (max-device-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 1/1) and (max-device-width: 320px),
only screen and ( min-device-pixel-ratio: 1) and (max-device-width: 320px),
only screen and ( min-resolution: 96dpi) and (max-device-width: 320px),
only screen and ( min-resolution: 1dppx) and (max-device-width: 320px),
only screen and (-webkit-min-device-pixel-ratio: 2) and (max-device-width: 640px),
only screen and ( min--moz-device-pixel-ratio: 2) and (max-device-width: 640px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (max-device-width: 640px),