Skip to content

Instantly share code, notes, and snippets.

Anton Polonskiy polonskiy

Block or report user

Report or block polonskiy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@polonskiy
polonskiy / transmission-remote-magnet.bash
Created Mar 24, 2018 — forked from sbisbee/transmission-remote-magnet.bash
Quick and easy way of making Chrome send bittorrent magnet links to a remote Transmission instance using its API on Ubuntu with xdg.
View transmission-remote-magnet.bash

Quick and easy way of making Chrome send bittorrent magnet links to a remote Transmission instance using its API on Ubuntu with xdg. This method does not require modifying any system files or xdg's scripts, whereas most of the examples I found on the Internet did require such hacks.

Chrome does not handle default applications, instead relying on the OS to manage that. The default handler in Ubuntu is xdg, which maps the MIME type to the default application. Extra tooling is required because xdg requires a registered desktop file, so you can't simply give it a command to run.

Steps:

  1. Install the shell script transmission-remote-magnet ideally in /usr/local/bin: ln -s ~/src/transmission-remote-magnet.bash transmission-remote-magnet

  2. Install the desktop file, which is required for xdg to work and will likely require sudo: desktop-file-install ./transmission-remote-magnet.desktop

@polonskiy
polonskiy / encrypted-git-repo.md
Created Feb 7, 2018
Transparent Git Encryption
View encrypted-git-repo.md

Transparent Git Encryption

This document has been modified from its [original format][m1], which was written by Ning Shang (geek@cerias.net). It has been updated and reformatted into a [Markdown][m2] document by [Woody Gilk][m3] and [republished][m4].

Description

When working with a remote git repository which is hosted on a third-party storage server, data confidentiality sometimes becomes

@polonskiy
polonskiy / segfault-finder.php
Created Aug 23, 2016 — forked from lyrixx/segfault-finder.php
How to find a segfault in PHP
View segfault-finder.php
<?php
register_tick_function(function() {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$last = reset($bt);
echo sprintf("%s +%d\n", $last['file'], $last['line']);
});
declare(ticks=1);
@polonskiy
polonskiy / array_of_example.php
Last active Jan 21, 2016 — forked from bernik/array_of_example.php
array_of realization in php
View array_of_example.php
<?php
class User {
public
$name,
$lastName;
public function __construct($name, $lastName) {
$this->name = $name;
$this->lastName = $lastName;
@polonskiy
polonskiy / git-del.sh
Created Sep 22, 2015
remove file from git
View git-del.sh
#!/bin/bash
git filter-branch --prune-empty --index-filter "git rm --cached -f --ignore-unmatch $1" --tag-name-filter cat -- --all
@polonskiy
polonskiy / 1.sh
Last active Feb 24, 2016
remove old kernels
View 1.sh
#!/bin/bash
dpkg -l | awk '/linux-image-[0-9]/ {print $2}' | grep -vF "$(uname -r)" | xargs -r apt-get -y purge
@polonskiy
polonskiy / xkcd-pass.sh
Last active Jul 28, 2017
xkcd password generator
View xkcd-pass.sh
#!/bin/bash
LC_ALL=C grep '^[a-z]\+$' /usr/share/dict/words | shuf --random-source=/dev/urandom -n 4 | paste -s -d-
grep '^[abcdefghijklmnopqrstuvwxyz]\{3,7\}$' /usr/share/dict/words | shuf -n 6 | xargs | sed 's/ /-/g'
View csv-decode.php
<?php
function csv_decode($csv, $columns = [], $delimiter = ',', $enclosure = '"', $escape = '\\') {
$tmp = fopen('php://temp', 'rb+');
fwrite($tmp, $csv);
rewind($tmp);
$result = [];
$assoc = (bool) $columns;
@polonskiy
polonskiy / float-comma.php
Last active Aug 29, 2015
comma deciaml separator
View float-comma.php
<?php
setlocale(LC_ALL, 'uk_UA.UTF-8');
$float = 1.2345;
echo "$float\n";
@polonskiy
polonskiy / init.sh
Created Feb 12, 2015
forward signals
View init.sh
#!/bin/bash
#enable job control
set -m
#propagate INT/TERM signals
trap 'kill -TERM $(jobs -p); wait' TERM
trap 'kill -INT $(jobs -p); wait' INT
#services
You can’t perform that action at this time.