Skip to content

Instantly share code, notes, and snippets.

View akeinhell's full-sized avatar
:bowtie:

Алексей Дорохов akeinhell

:bowtie:
  • vsemayki.ru
  • Новосибирск
View GitHub Profile
@akeinhell
akeinhell / showNews.java
Created November 27, 2013 17:09
sample JSoup XMLHttpRequest with cookies
Document doc = Jsoup.connect(jurl)
.header("Accept","text/html, */*; q=0.01")
.header("Accept-Encoding","gzip,deflate,sdch")
.header("Accept-Language","ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4")
.header("Connection","keep-alive")
.header("Cookie",cookie)
.header("Host","rivalregions.com")
.header("Referer","http://rivalregions.com/")
.header("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36")
.header("X-Requested-With", "XMLHttpRequest")
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
ads:adUnitId="@string/admob_publisher_id"
ads:adSize="BANNER"
ads:loadAdOnCreate="false"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
$('param[name=flashvars]').attr('value').split("&")[2].split("=")[1];
@akeinhell
akeinhell / Select Random row
Created February 11, 2015 08:10
Выбор случайной строки в Mysql
SELECT FLOOR(count(*)*RAND()) INTO @max FROM table;
PREPARE STMT FROM 'SELECT * FROM table LIMIT ?,1';
EXECUTE STMT USING @max;
@akeinhell
akeinhell / ip check mask
Created February 11, 2015 09:54
Проверка IP В диапазоне
function matchCIDR($addr,$cidr) {
list($ip,$mask) = explode('/',$cidr);
return (ip2long($addr) >> (32 - $mask) == ip2long($ip) >> (32 - $mask));
}
function cidr_match($ip, $range)
{
list ($subnet, $bits) = explode('/', $range);
@akeinhell
akeinhell / CPP API WoT
Last active August 29, 2015 14:17
CPP API WoT
//---------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "curl/curl.h"
//#pragma comment(lib,"curllib.lib") // для VC++
//--------------------------------------------------------------------------
const size_t BUF_SIZE= 5000000;
char wr_buf[5000001];
size_t wr_index=0;
@akeinhell
akeinhell / test
Created March 30, 2015 04:49
test wg
<?php
require 'src/WotApi/Api.php';
require 'vendor/autoload.php';
use WotApi\Api;
Api::create()->setApplicationId('demo');
Api::onSuccess(
function($response, $args){
print '->'.sizeof(explode(',',$args[0]['clan_id'])).' OK'.PHP_EOL;
@akeinhell
akeinhell / installphp7.sh
Last active December 9, 2015 07:37 — 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
mkdir -p /etc/php7/conf.d
mkdir -p /etc/php7/cli/conf.d
mkdir /usr/local/php7
@akeinhell
akeinhell / 1c.bat
Created December 31, 2015 02:13
Созданеие бекапа
set PATH=%PATH%;%ProgramFiles(x86)%\PostgreSQL\9.1.9-1.1C\bin;%ProgramFiles%\7-Zip
echo %PATH%
set DAT=%date:~6,4%%date:~3,2%%date:~0,2%
cd C:\backup
pg_dump -U postgres unf14 > %DAT%-unf14.pgsql.backup
7z a -tzip %DAT%-unf14.pgsql.zip %DAT%-unf14.pgsql.backup
Резервное копирование баз данных PostgreSQL.
http://interface31.ru/tech_it/2013/07/rezervnoe-kopirovanie-bez-dannyh-postgresql.html
https://gist.github.com/akeinhell/763617fae52fdacfec48
http://goo.gl/SCScpd