Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dvapelnik's full-sized avatar

Dmitry Vapelnik dvapelnik

  • Ukraine, Vinnitsa
View GitHub Profile
<?php
class Text {
/**
* Limits a phrase to a given number of characters.
*
* $text = Text::limit_chars($text);
*
* @param string $str phrase to limit characters of
@dvapelnik
dvapelnik / notify-send-transalte
Created August 12, 2014 23:45
Using Google Translate service for translate selected text on Ubuntu Unity (tested) via notify-send
#!/usr/bin/env bash
notify-send "$(xsel -o)" "$(wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=$(xsel -o | sed "s/[\"'<>]//g")&sl=auto&tl=ru" | sed 's/\[\[\[\"//' | cut -d \" -f 1)" -i accessories-dictionary -t 2000
#!/bin/bash
# Allowed commndline arguments:
# --prev Previous track
# --next Next track
# --pause Toggle pause
# --show Show info about current track (only for NuvolaPlayer3)
# empty argumetns
if [[ $# -eq 0 ]]; then exit 1; fi
#!/bin/sh
vlc -Idummy v4l2:// \
:v4l-vdev="/dev/video0" \
:input-slave=alsa://hw:0,0 :v4l-norm=3 \
:v4l-frequency=-1v4l-caching=300 \
:v4l-chroma="" \
:v4l-fps=-1.000000 \
:v4l-samplerate=44100 \
:v4l-channel=0 \

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@dvapelnik
dvapelnik / EventEmitter.js
Last active August 29, 2015 14:19
Simple EventEmitter and ingeriter like a Node.js EventEmitter and util.inherits
/** EventEmitter */
function EventEmitter() {
var registry = {};
this.getRegistry = function () {
return registry;
}
}
EventEmitter.prototype.emit = function (event, eventArgs) {
@dvapelnik
dvapelnik / config.py
Last active April 27, 2018 12:25
Translate in command line using YandexTranslateAPI
YandexApiKey = 'Your.Yandex.Translate.API.Key.Should.Be.Here'
@dvapelnik
dvapelnik / ms.sh
Last active August 29, 2015 14:22
Run the command several times per minute
#!/bin/bash
# Script can start few command instances in one minute
# with automatic sleep and count per second
# Created for run multiple commands each mimute with cron on linux OS
# Author: Dmitry Vapelnik <dvapelnik@gmail.com>
# Created: 2015-06-01 23:26:43
function help {
HELP="You must use two arguments: first - how many time to execute command in next minute; second - commant to execute"
@dvapelnik
dvapelnik / .vimrc
Last active August 29, 2015 14:24
.vimrc
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent
set smartindent
@dvapelnik
dvapelnik / run.sh
Created July 5, 2015 15:24
make file container with some filesystem
#!/bin/bash
# Make file container with 100Gb size
dd if=/dev/zero of=container.ext4 bs=1M count=102400
# Format with ext4 fs
mkfs ext4 -F container.ext4
# Make mount-directory
sudo mkdir -p /mnt/container_dir