Skip to content

Instantly share code, notes, and snippets.

Avatar

Viktor Manyushin vmanyushin

View GitHub Profile
View sample.rb
port = 10051
s = Zabbix::Sender.new 'zabbix-server', port
pp s.send('host', 'key', 'value')
# => {"response"=>"success",
# "info"=>"Processed 1 Failed 0 Total 1 Seconds spent 0.000042"}
pp s.to('host') {
send 'key', 'value'
View show-all-256-colors.py
#!/usr/bin/python
def hrun(start, width, padding=0):
return [None] * padding + range(start, start+width) + [None] * padding
def vrun(start, width, height, padding=0):
return [hrun(s, width, padding)
for s in range(start, start+width*height, width)]
layout = [
View cors-nginx.conf
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@vmanyushin
vmanyushin / gist:5c04002d0309e0554af0
Last active Aug 29, 2015
Склонятор на ruby
View gist:5c04002d0309e0554af0
#!/usr/bin/env ruby
require 'uri'
require 'open-uri'
require 'nokogiri'
uri = URI.parse('http://export.yandex.ru/inflect.xml')
params = { :name => "#{ARGV[0]}" }
uri.query = URI.encode_www_form( params )
View gist:b385ce215e572d11e7db
#!/usr/bin/php
<?php
$url = "http://habrahabr.ru/post/242657/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
View gist:e7c2394bca9888ab8abe
.video-responsive {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow:hidden;
}
.video-responsive iframe,
.video-responsive object,
.video-responsive embed {
position: absolute;
View fix debian locale
$ sudo locale-gen "en_US.UTF-8"
$ dpkg-reconfigure locales
@vmanyushin
vmanyushin / gist:9dd40d70ff4c90c8324a
Last active Aug 9, 2018
Install php 5.6 on Debian7
View gist:9dd40d70ff4c90c8324a
apt-get install software-properties-common python-software-properties
add-apt-repository 'deb http://packages.dotdeb.org wheezy-php56 all'
add-apt-repository 'deb-src http://packages.dotdeb.org wheezy-php56 all'
~~~~~~~~~~~~ jessy
add-apt-repository 'deb http://packages.dotdeb.org jessie all'
add-apt-repository 'deb-src http://packages.dotdeb.org jessie all'
~~~~~~~~~~~~
wget http://www.dotdeb.org/dotdeb.gpg
View Чистка виря с Eval в первой строке
find ./ -name '*.php' -exec grep -l '^<?php.*eval' {} \; | xargs sed -i '1s/.*/<?php/'
find ./ -name '*.php' -o -name '*.html' -exec grep -l '<script id="data:text/javascript;charset=utf-8;base64' {} \; | xargs sed -i 's#^<script id="data:text/javascript;charset=utf-8;base64.*$##g'
View gist:a1829c1ac15ed55bd7ac
function isMobile() {
var a = (navigator.userAgent||navigator.vendor||window.opera);
if(/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu