Skip to content

Instantly share code, notes, and snippets.

View nberserk's full-sized avatar

darren ha nberserk

View GitHub Profile
@nberserk
nberserk / parse_blogger.py
Created August 31, 2017 12:29
parse blogger xml with python
from xml.etree import ElementTree
prefix = '{http://www.w3.org/2005/Atom}'
tree = ElementTree.parse('/blog-08-22-2017.xml')
root = tree.getroot()
def real_tag(tag):
return prefix+tag
int kadane2d(int[][] m){
int row = m.length;
if(row==0)return 0;
int col = m[0].length;
int ret = Integer.MIN_VALUE;
for (int left = 0; left < col; left++) {
int[] sum = new int[row]; // reuse this
for (int right = left; right < col; right++) {
@nberserk
nberserk / calculatingS3Size.py
Last active January 31, 2024 11:02
calculating S3 file size containing <your_filter> in <your_bucket> using boto3 python library.
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('<your_bucket>')
size = 0
for o in bucket.objects.all():
if '<your_filter>' in o.key:
print o, o.size
size += o.size
print 's3 size = %.3f GB' % (size/1024/1024/1024)