Skip to content

Instantly share code, notes, and snippets.

@syndicut
syndicut / har_parser.py
Created February 4, 2012 23:40
HAR format parser
#!/usr/bin/env python
import json
import sys
har = open(sys.argv[1])
parsed = json.load(har)
parsed['request']['url'] = '/'+'/'.join(parsed['request']['url'].split('/')[3:])
response = '%(method)s %(url)s %(httpVersion)s\r\n' % parsed['request']
@syndicut
syndicut / backup_vms.py
Last active October 5, 2015 23:38
Replaced check_call with Popen
#!/usr/bin/env python
import contextlib, os, finalize_vm, subprocess
backup_path = '/mnt/backup/tmp/backup'
@contextlib.contextmanager
def flock(path):
while True:
try:
@syndicut
syndicut / gist:3600683
Created September 2, 2012 15:42
Remove variants with duplicate sku's for spree commerce
Variant.where({:is_master => false}).each { |v| Variant.where({:sku => v.sku}).where(['id != ?', v.id]).where({:is_master => false}).delete_all }
@syndicut
syndicut / gist:3729149
Created September 15, 2012 18:21
Regexp to replace hook do end ruby block
^( *)<%= hook :([^ ,]+).*do %>(((?!^\1<% end %>).|\n)+)^\1<% end %>
\1<div data-hook="\2">\3\1</div>
Description: Adds a firstseg option to livehttp streaming module
It is needed to allow segment start from different number then 1,
it can be usefull if vlc is restarted and clients expect segments numbers
to be more then the last they've received
.
vlc (2.0.3-0ubuntu0.12.04.1yandex1) precise; urgency=low
.
* Added firstseg option for livehttp streaming module
Author: Rashit Azizbaev <syndicut@yandex-team.ru>
diff --git a/src/80211.c b/src/80211.c
index c2aff59..202556b 100644
--- a/src/80211.c
+++ b/src/80211.c
@@ -39,8 +39,18 @@ const u_char *next_packet(struct pcap_pkthdr *header)
const u_char *packet = NULL;
/* Loop until we get a valid packet, or until we run out of packets */
+#ifdef __APPLE__
+ struct pcap_pkthdr *pkt_header = NULL;
, opcode: GETATTR (3), nodeid: 1, insize: 56
, success, outsize: 120
, opcode: LOOKUP (1), nodeid: 1, insize: 48
, success, outsize: 144
, opcode: OPEN (14), nodeid: 62289, insize: 48
, success, outsize: 32
, opcode: READ (15), nodeid: 62289, insize: 80
, success, outsize: 135
, opcode: RELEASE (18), nodeid: 62289, insize: 64
, success, outsize: 16
@syndicut
syndicut / Makefile
Last active December 29, 2015 07:59
Problem with parallel writes to moosefs from multiple nodes
CC = g++
PROGRAM = main
#CFLAGS = -g `pkg-config --cflags gtk+-x11-2.0` `pkg-config --cflags gtkextra-2.0`
#LDFLAGS = `pkg-config --libs gtk+-x11-2.0` `pkg-config --libs gtkextra-2.0`
CFLAGS = -g #`pkg-config --cflags gtk+-2.0`
LDFLAGS = -lpthread -lrt#`pkg-config --libs gtk+-2.0`
SOURCE = main.cc
OBJS = main.o
.cpp.o:
#!/usr/bin/env bash
LIBSSL=`dpkg -l libssl* | grep ii | awk '{ print $2 }'`
LIST=$( for i in `dpkg -L $LIBSSL|grep /lib/` ; do if [ -f $i ] ; then echo $i ; fi ; done )
LIST=`for i in $LIST ; do lsof -n $i|tail -n+2 ; done|awk '{print $2}'|sort|uniq`
LIST=$(for i in $LIST ; do echo "`readlink /proc/$i/exe`"; done | sort | uniq)
RESTART=$(for i in $LIST; do
BINARY=$i
#!/bin/bash -eu
runpatch()
{
FILE="$1"
POS=$(grep -obUaP "\xf8\xff\x4d\x85\xe4\x48\x8d\x50\x21\x0f\x84\x83\x03\x00\x00" "$FILE" | cut -d: -f1)
if test -z "$POS"; then
echo "Haystack is missing, aborting..." >&2
return
fi
printf "\xf8\xff\x4d\x85\xe4\x48\x8d\x50\x29\x0f\x84\x83\x03\x00\x00" | dd of="$FILE" bs=1 seek="$POS" conv=notrunc