Skip to content

Instantly share code, notes, and snippets.

View DKunin's full-sized avatar
🎯
Focusing

Dmitri Kunin DKunin

🎯
Focusing
View GitHub Profile
@DKunin
DKunin / SlackStatuses.sh
Created March 20, 2020 13:10
Slack Statuses
#!/bin/bash
curl -G -v -X POST --data-urlencode "profile={\"status_text\":\"$1\",\"status_emoji\":\"$2\"}" https://slack.com/api/users.profile.set?token=$SLACK_TOKEN
# SlackStatus Away
curl -X POST https://slack.com/api/users.setPresence --data "token=$SLACK_TOKEN&presence=away"
#!/bin/bash
function rename() {
name=$(echo $1 | sed 's/aifc/mp3/');
ffmpeg -i "$1" -f mp3 -acodec libmp3lame -ab 192000 -ar 44100 "$name"
}
rename "$1"
@DKunin
DKunin / async-interactive.js
Last active June 29, 2017 08:15
Generator Snippets and examples
'use strict';
var stdin = process.stdin;
stdin.setRawMode(true);
stdin.resume();
stdin.setEncoding('utf8');
let sentence = '';
let sentenceTimeout;
@DKunin
DKunin / getPPI.js
Created June 14, 2017 13:54
getPPI
function getPPI(){
// create an empty element
var div = document.createElement("div");
// give it an absolute size of one inch
div.style.width="1in";
// append it to the body
var body = document.getElementsByTagName("body")[0];
body.appendChild(div);
// read the computed width
var ppi = document.defaultView.getComputedStyle(div, null).getPropertyValue('width');
@DKunin
DKunin / performancemeasure
Created May 16, 2017 13:47
Performance measure
performance.mark('costlyFunction Start')
costlyFunction()
performance.mark('costlyFunction End')
performance.measure(
'costlyFunction',
'costlyFunction Start',
'costlyFunction End'
// ==UserScript==
// @name Yandex Disk delete shortcut
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author DKunin
// @match https://disk.yandex.ru/client/disk/*
// ==/UserScript==
(function() {
@DKunin
DKunin / downloadphotos.sh
Last active February 8, 2017 06:57
Download photos with gphoto
#!/bin/bash
mkdir ~/Downloads/$(date +%d-%m-%Y)
cd ~/Downloads/$(date +%d-%m-%Y)
gphoto2 -P
osascript -e 'display notification "Загрузка фотографий в папку '$(date +%d-%m-%Y)' завершена" with title "Фотографии сохранены"'
@DKunin
DKunin / scramble.js
Created February 1, 2017 06:59
Scramble text function
function randomInteger(min, max) {
var rand = min + Math.random() * (max - min)
rand = Math.round(rand);
return rand;
}
function scrabmle(text) {
const lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tincidunt justo at mattis eleifend. Vestibulum feugiat convallis porta. Maecenas convallis nunc bibendum velit luctus, in faucibus nibh venenatis. Nam lacinia pretium orci in elementum. Vivamus pretium risus elit, eleifend venenatis nulla pellentesque et. Proin at placerat arcu. Nunc ac posuere enim. Sed eu volutpat massa.`;
const len = text.length;
const randomStart = randomInteger(0, lorem.length - len);
// ==UserScript==
// @name Add link to piratebay torrents
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Click on the show's name, sends to piratebay with title and episode number
// @author DKunin
// @match http://www.tvshowtime.com/en
// @grant none
// ==/UserScript==

Keybase proof

I hereby claim:

  • I am dkunin on github.
  • I am dkunin (https://keybase.io/dkunin) on keybase.
  • I have a public key whose fingerprint is 27ED 8B59 E575 22D8 55C0 2F4C A145 4B68 071A DA70

To claim this, I am signing this object: