Skip to content

Instantly share code, notes, and snippets.

View zobzn's full-sized avatar

Semyon Tokarev zobzn

View GitHub Profile
@zobzn
zobzn / example.js
Created July 30, 2013 15:49
Parsing URLs with the DOM!
var myURL = parseURL('http://abc.com:8080/dir/index.html?id=255&m=hello#top');
myURL.file; // = 'index.html'
myURL.hash; // = 'top'
myURL.host; // = 'abc.com'
myURL.query; // = '?id=255&m=hello'
myURL.params; // = Object = { id: 255, m: hello }
myURL.path; // = '/dir/index.html'
myURL.segments; // = Array = ['dir', 'index.html']
myURL.port; // = '8080'
@zobzn
zobzn / notify-apache-errors.sh
Created September 3, 2013 09:10
apache error notify
#!/bin/bash
# use ubuntu's notification system to let us know when there's something new in the apache error log
# requires package libnotify-bin
# tail -n0 -f /var/log/apache2/error.log | egrep 'Notice|Warning|Error|Fatal' | while read line
tail -n0 -f /var/log/apache2/error.log | while read line
do
body=`echo $line | cut -f 9- -d ' '`
notify-send -c im.received -i error "Apache / PHP error" "$body"
@zobzn
zobzn / index.php
Last active August 29, 2015 14:27 — forked from ziadoz/index.php
Simple PHP HTTP Handling
<?php
// See Error Handling in PHP: https://nomadphp.com/2015/02/25/nomadphp-2015-02-us-lt2/#
$display = function ($status, $headers = array(), $content = '') {
http_response_code($status);
foreach ($headers as $key => $value) {
header($key . ': ' . $value);
}
@zobzn
zobzn / gmap.php
Last active August 29, 2015 14:27 — forked from ziadoz/gmap.php
Generating a Static Google Map with PHP
<?php
$url = 'http://maps.googleapis.com/maps/api/staticmap?';
$bits = array(
'center' => 'Calgary Tower, Calgary, AB, Canada',
'zoom' => '16',
'size' => '800x600',
'maptype' => 'roadmap',
'markers' => 'color:0x576d4e|label:N|49.6967179,-112.8450119',
'sensor' => 'false',
);
@zobzn
zobzn / ymaps-remote-object-manager-with-data-events.js
Created March 1, 2016 16:16
События загрузки данных у RemoteObjectManager Яндекс.Карт
// @see https://yandex.ru/blog/mapsapi/54098
// свой загрузчик данных для RemoteObjectManager
// отличия от базового — генерируется события загрузки данных: dataloadbefore и dataloadafter
ymaps.modules.define('objectManager.component.ReloadOnZoomChangeControllerWithEvents', [
'util.defineClass',
'objectManager.component.ReloadOnZoomChangeController'
], function (provide, defineClass, ReloadOnZoomChangeController) {
var ReloadOnZoomChangeControllerWithEvents = function (remoteObjectManager) {
ReloadOnZoomChangeControllerWithEvents.superclass.constructor.call(this, remoteObjectManager);
@zobzn
zobzn / dockerhost.sh
Last active December 26, 2016 21:05
dockerhost
#!/bin/bash
if [[ -z $(grep dockerhost /etc/hosts) ]]
then
echo $(printf "%d." $(echo $(awk '$2 == "00000000" {print $3}' /proc/net/route) | sed 's/../0x& /g' | tr ' ' '\n' | tac) | sed 's/\.$/\n/') dockerhost >> /etc/hosts
fi
sudo apt install dkms git
git clone https://github.com/cilynx/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959.git
cd rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959
VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf)
sudo rsync -rvhP ./ /usr/src/rtl88x2bu-${VER}
sudo dkms add -m rtl88x2bu -v ${VER}
sudo dkms build -m rtl88x2bu -v ${VER}
sudo dkms install -m rtl88x2bu -v ${VER}
sudo modprobe 88x2bu
#!/bin/bash
pushd ~
sudo apt update
sudo apt upgrade
# remove unused
sudo apt remove -y thunderbird
sudo apt remove -y libreoffice-core
"use strict";
class Batcher {
constructor(size = 10, callback = () => {}) {
this.size = size;
this.queue = [];
this.callback = callback;
}
static create(size = 10, callback = () => {}) {
@zobzn
zobzn / test-send-google-analytics.php
Created October 15, 2019 13:53
Отправка данных в google analytics из php скрипта
<?php
/**
* @see https://developers.google.com/analytics/devguides/collection/protocol/v1/?hl=ru
* @see https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide?hl=ru
* @see https://developers.google.com/analytics/devguides/collection/protocol/v1/email?hl=ru
* @see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=ru
*/
use Ramsey\Uuid\Uuid;