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 / main.cpp
Last active April 7, 2024 04:56
Читаем заголовок WAV файла на C++
#include <stdio.h>
#include <tchar.h>
#include <conio.h>
#include <math.h>
// Структура, описывающая заголовок WAV файла.
struct WAVHEADER
{
// WAV-формат начинается с RIFF-заголовка:
@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 / beanstalkd
Created September 20, 2013 10:06
Default beanstalkd start config with persistence.
## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on
## Debian systems. Append ``-b /var/lib/beanstalkd'' for persistent
## storage.
BEANSTALKD_LISTEN_ADDR=127.0.0.1
BEANSTALKD_LISTEN_PORT=11300
DAEMON_OPTS="-l $BEANSTALKD_LISTEN_ADDR -p $BEANSTALKD_LISTEN_PORT -b /var/lib/beanstalkd"
## Uncomment to enable startup during boot.
START=yes
@alexey-detr
alexey-detr / beanstalk-php-worker.sh
Last active December 23, 2015 12:09
Wrapper for PHP scripts to deamonize em. It is allowed to specify user for further passing it to PHP script e.g. app/beanstalk-php-worker.sh start www-data
#!/bin/sh
### BEGIN INIT INFO
# Required-Start: beanstalk-job-server
# Default-Start: 2 3 4 5
# Default-Stop:
# Description: Php workers wrapper
### END INIT INFO
WORKDIR="$( cd "$( dirname "$0" )" && pwd )"
id -u `ps xu | grep -E "([a]pache2|nginx)" | awk '{print $1}' | head -n1`
chsh -s $(which zsh)
@alexey-detr
alexey-detr / install_headers.sh
Last active December 22, 2015 22:09
If installing VirtualBox Guest Additions for Ubuntu fails.
sudo apt-get install build-essential linux-headers-`uname -r` dkms