Skip to content

Instantly share code, notes, and snippets.

View garex's full-sized avatar
🏒
❄️

Alexander Ustimenko garex

🏒
❄️
View GitHub Profile
@garex
garex / arena.sh
Created August 10, 2023 15:41
Check tickets.sibir-arena.ru is alive
# Remember to chmod +x
while true; do
echo -n .
HTTP_CODE=$(curl --silent -I -X GET https://tickets.sibir-arena.ru/ | head -1 | awk '{print $2}')
[[ 200 = $HTTP_CODE ]] && break
sleep 15
done
notify-send "Sibir arena alive!"
@garex
garex / traccar
Created March 17, 2020 04:16
Traccar init.d service script. Save it as /etc/init.d/traccar and chmod +x it
#! /bin/sh
### BEGIN INIT INFO
# Provides: traccar
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Modern GPS Tracking Platform
# Description: Manages traccar server for getting device's data and showing at web-interface
### END INIT INFO
@garex
garex / git-commit-file.php
Last active April 18, 2019 15:13
Git interactive rebase with changed files below commits
#!/usr/bin/env php
<?php
//
// To use this file run this:
// git config --global sequence.editor git-commit-file.php
//
// Then just:
// git rebase -i develop
//
@garex
garex / vtt-concat.php
Created September 26, 2018 04:12
nhl vtt concat
<?php
function vtt_concat($t1, $t2) {
for ($i = 1; $i < strlen($t1); $i++) {
$t1_part = substr($t1, -$i);
$t2_has_t1_part = (strstr($t2, $t1_part) !== false);
if ($t2_has_t1_part) {
continue;
} elseif ($i == 1) {
break;
@garex
garex / vk-subtitles.php
Created January 9, 2018 07:57
vkontakte wall comments into subtitles (SBV)
#!/usr/bin/env php
<?php
$options = getopt('', [
'url:',
'first-comment-to:'
]);
if (empty($options['url']) || empty($options['first-comment-to'])) {
exit('Parameters: --url=https://vk.com/sibhl?w=wall-96808993_127304 --first-comment-to=00:00:00'.PHP_EOL);
}
@garex
garex / wtf.php
Created June 30, 2017 08:51
Typed collection with phpdoc
<?php
// @see https://www.sitepoint.com/creating-strictly-typed-arrays-collections-php/
class Wtf
{
public function wow()
{
echo __METHOD__;
}
}
@garex
garex / summary.xsl
Last active November 15, 2016 12:18
pdepend summary.xml to HTML xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/metrics">
<html>
<body>
<style>
body { font-family: consolas; }
ul.methods { -webkit-column-count: 3; }
sup { margin: 0 0.2em; font-weight: normal; padding: 0.4em 0.3em; background: gainsboro; color: gray; }
.position-top-20 { color: red; }
@garex
garex / CommandDefinition.php
Created September 27, 2016 09:49
Transform "Vendor\FooBundle\Command\BarCommand" transforms to "vendor_foo.command.bar" id
/**
* Transforms "Vendor\FooBundle\Command\BarCommand" transforms to "vendor_foo.command.bar" id
*
* @param string $className
* @return string
*/
private function convertClassToId($className)
{
$id = preg_replace('/^(\w+)\\\(\w+)Bundle.*\\\(\w+)(Command)$/', '$1_$2.$4.$3', $className);
@garex
garex / AppExtension.php
Created June 10, 2016 12:24
Tree-like parameters from services into flat
<?php
namespace Vendor\AppBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
class VendorAppExtension extends Extension
{
@garex
garex / .gitconfig
Last active May 25, 2016 10:21
Git aliases
# To get yours:
# history | grep ' git ' | sed 's/^.* git //' | awk '{print $1}' | sort | uniq -c | sort -h
[alias]
s = status
c = commit -m
p = push origin
pf = push origin -f
d = diff
r = rebase