Skip to content

Instantly share code, notes, and snippets.

View ximik777's full-sized avatar

Grigoriy Stratov ximik777

View GitHub Profile
# Install dependencies
#
# * checkinstall: package the .deb
# * libpcre3, libpcre3-dev: required for HTTP rewrite module
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \
mkdir -p ~/sources/ && \
# Compile against OpenSSL to enable NPN
@ximik777
ximik777 / otrs.conf
Created December 9, 2016 15:04 — forked from rdoursenaud/otrs.conf
OTRS FCGIWRAP SSL+HSTS NGINX configuration
server {
listen 443 ssl;
listen [::]:443 ssl;
keepalive_timeout 70;
server_name otrs.example.com;
root /opt/otrs/var/httpd/htdocs;
index index.html;
# SSL
@ximik777
ximik777 / json_parser.c
Created November 22, 2016 00:24 — forked from alan-mushi/json_parser.c
Examples for the json-c tutorial.
/*
* A simple example of json string parsing with json-c.
*
* clang -Wall -g -I/usr/include/json-c/ -o json_parser json_parser.c -ljson-c
*/
#include <json.h>
#include <stdio.h>
int main() {
struct json_object *jobj;
@ximik777
ximik777 / version_compare.js
Created October 8, 2016 00:42 — forked from TheDistantSea/version_compare.js
Function to compare two version strings (e.g. "1.6.1" is smaller than "1.7"). Developed in order to answer http://stackoverflow.com/a/6832721/50079.
/**
* Compares two software version numbers (e.g. "1.7.1" or "1.2b").
*
* This function was born in http://stackoverflow.com/a/6832721.
*
* @param {string} v1 The first version to be compared.
* @param {string} v2 The second version to be compared.
* @param {object} [options] Optional flags that affect comparison behavior:
* <ul>
* <li>
@ximik777
ximik777 / card.js
Last active July 7, 2016 15:30
Conversion ID cards in all formats
function cardList(card_id, upeercase) {
if (!card_id) return [];
card_id += '';
upeercase = !!(upeercase);
var arr = [],
dechex = function (number) {
return parseInt(number < 0 ? 0xFFFFFFFF + number + 1 : number, 10).toString(16)
}, str_split = function (str, split) {
if (!str) return false;
split = split || 1;
@ximik777
ximik777 / card.php
Created July 7, 2016 15:26
Conversion ID cards in all formats
<?php
function cardList($card_id, $uppercase = false)
{
if (!$card_id) return [];
$arr = [];
$arr[0] = $card_id;
$arr[1] = implode(array_reverse(str_split($card_id, 2)));
if (preg_match('/^[0-9]*$/', $card_id)) {
@ximik777
ximik777 / installphp7.sh
Created March 4, 2016 21:48 — forked from tronsha/installphp7.sh
Install PHP7 to Ubuntu
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
apt-get update
apt-get install -y git-core autoconf bison libxml2-dev libbz2-dev libmcrypt-dev libcurl4-openssl-dev libltdl-dev libpng-dev libpspell-dev libreadline-dev make
mkdir -p /etc/php7/conf.d
mkdir -p /etc/php7/cli/conf.d
mkdir /usr/local/php7
//http://stackoverflow.com/questions/10717190/convert-svg-polygon-to-path
//Open your SVG in a web browser.
//Run this code:
var polys = document.querySelectorAll('polygon,polyline');
[].forEach.call(polys,convertPolyToPath);
function convertPolyToPath(poly){
var svgNS = poly.ownerSVGElement.namespaceURI;
<?php
/*! @class SocketServer
@author Navarr Barnier
@abstract A Framework for creating a multi-client server using the PHP language.
*/
class SocketServer
{
/*! @var config
@abstract Array - an array of configuration information used by the server.
*/
@ximik777
ximik777 / php-start-stop-daemon.sh
Created November 2, 2015 22:03
Run a PHP script as a service/daemon using start-stop-daemon
#! /bin/sh
# Installation
# - Move this to /etc/init.d/myservice
# - chmod +x this
#
# Starting and stopping
# - Start: `service myservice start` or `/etc/init.d/myservice start`
# - Stop: `service myservice stop` or `/etc/init.d/myservice stop`