Skip to content

Instantly share code, notes, and snippets.

@marnitto
marnitto / http_request.py
Created February 24, 2021 04:04
Jython example script to send POST request which size is over 65536 byte
# -*- coding: utf-8 -*-
# HTTP POST request example to resolve post size bug in Jython.
#
# Jython from 2.7.1 can't use synchronous socket to send data more than
# 65536 bytes at once (sends first socket and blocks infinitely), because
# jython didn't catch if socket.sendall() sends successfully. This bug was
# reported at 2017 but until now(2021.2.) there is no official fix, so
# instead of waiting I made a simple script using Java's native
# `java.net.URLConnection` class.
@marnitto
marnitto / app.py
Created April 25, 2020 15:56
Zappa: get 'context' variable from asynchronous task function
# -*- coding: utf-8 -*-
import inspect
def get_context():
# *crawl* hidden context variable from stack frame
for fi in inspect.getouterframes(inspect.currentframe()):
local = fi.frame.f_locals
context = local.get('context')

Keybase proof

I hereby claim:

  • I am marnitto on github.
  • I am marnitto (https://keybase.io/marnitto) on keybase.
  • I have a public key ASAPkSINNBP-P2KTbzhJA78QuARLUb-hYILfD6DFj2i0Lwo

To claim this, I am signing this object:

@marnitto
marnitto / Dockerfile
Created May 25, 2018 01:11
Dockerfile for symgdb+pwndbg
FROM ubuntu:16.04
MAINTAINER marnitto@gmail.com
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo wget git python make ca-certificates && \
wget https://bootstrap.pypa.io/get-pip.py -O /tmp/get-pip.py && \
python /tmp/get-pip.py
# symgdb installation step from symgdb repo
# -*- coding: utf-8 -*-
import codecs
from bs4 import BeautifulSoup
import requests
html = requests.get('https://slackmojis.com/').text
soup = BeautifulSoup(html, 'html.parser')
@marnitto
marnitto / taskmem.py
Created February 20, 2017 09:03
List processes, sort by memory usage, group by image name on Windows
# Tested on Windows 7~, Python 2.7 and 3.6.
#
# -*- coding: utf-8 -*-
import subprocess
import operator
res = subprocess.check_output(['tasklist'])
res = res.split(b'\r\n')[2:]
@marnitto
marnitto / player.py
Created August 19, 2016 11:33
PyCon 2016 APAC 가위바위보 코딩배틀
def show_me_the_hand(records):
try:
class AF(str): # for p2
def __eq__(self, *args, **kwarg):
return False
def __ne__(self, *args, **kwarg):
return True
class OTF(str): # for p1
@marnitto
marnitto / slack-download.py
Last active February 2, 2022 18:25
Slack file downloader from export archive
# -*- coding: utf-8 -*-
#
# Slack file downloader from export archive
#
# Requirements:
# Python 2 (or Python3 if you can use six)
#
# How to use:
# 1. Log in as admin, export your chat logs, and download archive.
# 2. Unarchive archive to directory (ex. TeamName export Apr 24 2016)
@marnitto
marnitto / sudoku.py
Created May 4, 2016 15:49
Simple sudoku solver using z3
# -*- coding: utf-8 -*-
# Tested on z3 4.4.0, Python 2.7.9
#
# $ time python sudoku.py
# 5 3 4 6 7 8 9 1 2
# 6 7 2 1 9 5 3 4 8
# 1 9 8 3 4 2 5 6 7
# 8 5 9 7 6 1 4 2 3
# 4 2 6 8 5 3 7 9 1
@marnitto
marnitto / gini.py
Created December 8, 2015 12:48
Simple Github Issue to IRC notification bot
# -*- coding: utf-8 -*-
import datetime
import os
import time
import github
import irc.bot
import schedule