Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
enjoying

Alex Pavlov alexpts

🤘
enjoying
View GitHub Profile
View parseIpv4.go
func parseIpv4(s string) [4]byte {
var ip [4]byte
// первые три байта парсим
for i := 0; i < 3; i++ {
for p := 0; p < 4; p++ {
if s[p] == '.' {
number, _ := strconv.ParseUint(s[:p], 10, 8)
ip[i] = byte(number)
View flatToTree.php
<?php
$flat = [
['id' => 1, 'parentId' => 0],
['id' => 2, 'parentId' => 0],
['id' => 3, 'parentId' => 1],
['id' => 4, 'parentId' => 1],
['id' => 5, 'parentId' => 2],
['id' => 6, 'parentId' => 2],
['id' => 7, 'parentId' => 3],
@alexpts
alexpts / tmp.js
Created Jan 31, 2020
tampermonkey Auto click optmize map.js
View tmp.js
// ==UserScript==
// @name Auto click optmize map
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://yandex.ru/maps/*
// @grant none
// ==/UserScript==
@alexpts
alexpts / test_zend_emitter.php
Last active Nov 19, 2019
test_zend_emitter.php
View test_zend_emitter.php
<?php
$response = new JsonResponse(['message' => 'ok'], 200, [
'header-1' => 'via reponse'
]);
$emitter = new SapiEmitter;
ob_start();
header('header-2: via global `header()` method'); // add header to buffer from global
@alexpts
alexpts / victora.json
Last active Aug 16, 2019
victora.json
View victora.json
{"status":"success","data":{"resultType":"matrix","result":[{"metric":{"__name__":"dev_value","db":"victoria","host":"server01","region":"us-west"},"values":[[1565948799,"NaN"],[1565948800,"NaN"],[1565948801,"NaN"],[1565948802,"NaN"],[1565948803,"NaN"],[1565948804,"NaN"],[1565948805,"NaN"],[1565948806,"NaN"],[1565948807,"NaN"],[1565948808,"NaN"],[1565948809,"NaN"],[1565948810,"NaN"],[1565948811,"NaN"],[1565948812,"NaN"],[1565948813,"NaN"],[1565948814,"NaN"],[1565948815,"NaN"],[1565948816,"NaN"],[1565948817,"NaN"],[1565948818,"NaN"],[1565948819,"NaN"],[1565948820,"NaN"],[1565948821,"NaN"],[1565948822,"NaN"],[1565948823,"NaN"],[1565948824,"NaN"],[1565948825,"NaN"],[1565948826,"NaN"],[1565948827,"NaN"],[1565948828,"NaN"],[1565948829,"NaN"],[1565948830,"NaN"],[1565948831,"NaN"],[1565948832,"NaN"],[1565948833,"NaN"],[1565948834,"NaN"],[1565948835,"NaN"],[1565948836,"NaN"],[1565948837,"NaN"],[1565948838,"NaN"],[1565948839,"NaN"],[1565948840,"NaN"],[1565948841,"NaN"],[1565948842,"NaN"],[1565948843,"NaN"],[156594884
View gist:c6258ded10c51ef70912635dfbf89ba2
export default () => {
return {
component: new Promise((resolve, reject) => {
setTimeout(() => {
reject(new Error('Can`t create component'));
resolve({
template: "<div>1234444</div>",
name: 'appMain2',
});
}, 100);
@alexpts
alexpts / config.json
Last active Jan 14, 2017 — forked from anonymous/config.json
Bootstrap avto
View config.json
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "#3B72B1",
"@brand-success": "#5cb85c",
View gist:0d9d60df234e7aed7caba37e8c6ede35
#### GET /penza/users
{
"data": {
"userIds": [1, 2, 3, 4, 5]
},
"status": 200
}
#### POST /penza/users
Добавить пользователя в комнату
@alexpts
alexpts / popover.js
Last active Aug 16, 2016
Example js module 2
View popover.js
(function ($, $popover) {
/**
* @param {{}|undefined}options
* @returns {{on: Function, off: Function}}
* @constructor
*/
var Popover = function (options) {
options = $.extend({
delegateElement: document,
@alexpts
alexpts / content.play-mp4.js
Created May 23, 2016
Example jquery module
View content.play-mp4.js
(function ($) {
var $document = $(document);
var PlayMp4 = function () {
/**
* @param {Event} event
* @private
*/