Skip to content

Instantly share code, notes, and snippets.

@pinge
pinge / tcpdump.md
Created February 11, 2016 20:29
tcpdump

dumping request and response headers from tcpdump in a human readable way:

sudo stdbuf -oL -eL /usr/sbin/tcpdump -A -s 10240 "tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)" | egrep -a --line-buffered ".+(GET |HTTP\/|POST )|^[A-Za-z0-9-]+: " | perl -nle 'BEGIN{$|=1} { s/.*?(GET |HTTP\/[0-9.]* |POST )/\n$1/g; print }'
# -*- coding: utf-8 -*-
import pytest
from validation import *
from fixtures import *
CASES = [
{
# -*- coding: utf-8 -*-
import json
import requests.models
from deepdiff import DeepDiff
def validate_status_code(response, status_code):
"""
# -*- coding: utf-8 -*-
import json
import pytest
import validation
CASES = [
npinge@content5-testing:~$ sudo dpkg -l | grep nginx
npinge@content5-testing:~$ sudo dpkg -l | grep openresty
npinge@content5-testing:~$ sudo dpkg -i ./openresty_1.9.3.2-1_amd64.deb
Selecting previously unselected package openresty.
(Reading database ... 89249 files and directories currently installed.)
Preparing to unpack .../openresty_1.9.3.2-1_amd64.deb ...
Unpacking openresty (1.9.3.2-1) ...
dpkg: dependency problems prevent configuration of openresty:
openresty depends on libgd2-xpm-dev; however:
Package libgd2-xpm-dev is not installed.
@pinge
pinge / openresty.sls
Created December 8, 2015 22:28
NGINX OpenResty salt formula
{% set local_source = '/usr/local/src' -%}
{% set output_folder = '/tmp' -%}
{% set nginx = pillar.get('nginx', {}) -%}
{% set openresty_config = nginx.get('openresty', {}) -%}
{% set openresty_version = openresty_config.get('version', '1.9.3.2') -%}
{% set openresty_checksum = openresty_config.get('checksum', 'sha1=5a20c096250b8fc22b01c003ed5929bb4b07e960') -%}
{% set openresty_package = 'ngx_openresty-' + openresty_version + '.tar.gz' -%}
@pinge
pinge / gist:d03f051b6d493ea98ef6
Last active August 29, 2015 14:14
custom directives for extracting info from the request and logging
trait ApiWithLoggingDirective extends HttpService {
def clientIPOrLoopbackAddress: Directive1[RemoteAddress] = Directives.clientIP | provide(RemoteAddress("127.0.0.1"))
def clientIPAndUri: Directive[RemoteAddress :: Uri :: HNil] = clientIPOrLoopbackAddress & requestUri
def detachAndLogRequest: Directive0 = (detach(()) & clientIPAndUri).hflatMap {
case (ip :: uri :: HNil) => RequestLog.requestLoggingDirective(ip, uri)
}
@pinge
pinge / mysql.md
Created December 8, 2014 17:23
mysql
sorting table columns by column name
SELECT c.column_name
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE c.table_name = 'some_table'
ORDER BY c.column_name;
@pinge
pinge / partition.md
Created December 1, 2014 08:06
restoring partitions on usb drives using linux

connect the usb stick.

tools
sudo apt-get install testdisk e2fsprogs parted gdisk util-linux
backup the entire drive with dd if possible
@pinge
pinge / spray_api.md
Last active August 29, 2015 14:07
ideas for an api structure with spray

com.compstak.models.Comp

package com.compstak.models

import com.github.nscala_time.time.Imports._

case class Comp(id: Int, createdAt: DateTime)

com.compstak.models.Market