Skip to content

Instantly share code, notes, and snippets.

@teasherm
teasherm / s3_multipart_upload.py
Last active March 4, 2025 21:55
boto3 S3 Multipart Upload
import argparse
import os
import boto3
class S3MultipartUpload(object):
# AWS throws EntityTooSmall error for parts smaller than 5 MB
PART_MINIMUM = int(5e6)
@jdelafon
jdelafon / hierholzer.py
Created June 29, 2016 11:45
Hierholzer's algorithm for Eulerian graphs
# Hierholzer's algorithm for Eulerian graphs #
"""
EXAMPLE
V = [1,2,3,4,5,6]
E = [(1,2),(2,3),(3,4),(4,5),(5,6),(6,1),(2,6),(6,4),(4,2)]
returns [1, 2, 6, 4, 2, 3, 4, 5, 6, 1]
V = ["AA","AB","BC","CD","DE","EF"]
E = [("AA","AB"),("AB","BC"),("BC","CD"),("CD","DE"),("DE","EF"),("EF","AA"),("AB","EF"),("EF","CD"),("CD","AB")]
@bruienne
bruienne / create_osx_pbkdf2_plist.py
Created April 24, 2016 15:52
Create an MDM-compatible PBKDF2 hash and plist for use with AccountConfiguration
#!/usr/bin/python
# Requires passlib: pip install passlib
from passlib.hash import pbkdf2_sha512
from passlib.util import ab64_decode
from biplist import *
# Checksum size must be 128 bytes for use as OS X password hash!
pbkdf2_sha512.checksum_size = 128
hash = pbkdf2_sha512.encrypt("password", rounds=38000, salt_size=32)
@staltz
staltz / introrx.md
Last active December 1, 2025 11:31
The introduction to Reactive Programming you've been missing
@karthikselva
karthikselva / run_ruby
Created March 14, 2013 11:34
Whenever I need to run ruby from VIM I used to exit and run the script and load back VIM. ( Bad ) Then learned to use **:!ruby** which would execute the supplied command in shell and return back. ( Better ) But the below gist would help you run with press of F6 key.
" Save the current file and run current ruby script
function! RunRuby()
:w
let name = input('Enter Argument (if any): ')
execute ':!ruby % '.name
endfunc
" Use F6 to trigger a run
@Vedrana
Vedrana / MedianOfIntegerStream.java
Created September 8, 2012 14:30
Median of stream of integers
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
// Given a stream of unsorted integers, find the median element in sorted order at any given time.
// http://www.ardendertat.com/2011/11/03/programming-interview-questions-13-median-of-integer-stream/
public class MedianOfIntegerStream {
public Queue<Integer> minHeap;
public Queue<Integer> maxHeap;