Skip to content

Instantly share code, notes, and snippets.

@polonskiy
polonskiy / transmission-remote-magnet.bash
Created March 24, 2018 19:05 — 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.

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 February 7, 2018 12:13
Transparent Git Encryption

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 August 23, 2016 12:04 — forked from lyrixx/segfault-finder.php
How to find a segfault in 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 January 21, 2016 09:24 — forked from bernik/array_of_example.php
array_of realization in php
<?php
class User {
public
$name,
$lastName;
public function __construct($name, $lastName) {
$this->name = $name;
$this->lastName = $lastName;
@polonskiy
polonskiy / git-del.sh
Created September 22, 2015 11:22
remove file from git
#!/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 February 24, 2016 07:49
remove old kernels
#!/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 July 28, 2017 05:03
xkcd password generator
#!/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'
@polonskiy
polonskiy / csv-decode.php
Last active August 29, 2015 14:23
csv decode
<?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 August 29, 2015 14:16
comma deciaml separator
<?php
setlocale(LC_ALL, 'uk_UA.UTF-8');
$float = 1.2345;
echo "$float\n";
@polonskiy
polonskiy / init.sh
Created February 12, 2015 14:33
forward signals
#!/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