Skip to content

Instantly share code, notes, and snippets.

View mpapierski's full-sized avatar

Michał Papierski mpapierski

View GitHub Profile
class TestView(LoginRequiredMixin, UserPassesTestMixin, View):
model = Foo
def make_dataset(self):
"""This method returns an instance of tablib.Dataset."""
pass
def get(self, request, **kwargs):
# Create empty dataset
dataset = self.make_dataset()
@mpapierski
mpapierski / models.py
Last active January 7, 2019 09:25
Custom delete in Django
class FooManager(models.Manager):
"""A manager for foos with custom filter.
Adds a clause to default query to ignore removed entries.
"""
def get_queryset(self):
"""Filter out all removed entries by default."""
return super().get_queryset().filter(removed_at__isnull=True)
@mpapierski
mpapierski / fake_babel.py
Created December 20, 2018 16:31
fake babeld
#!/usr/bin/env python
import socket
import threading
TCP_IP = '::1'
TCP_PORT = 6872
BUFFER_SIZE = 20
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
@mpapierski
mpapierski / NotesToEvernote.applescript
Created December 15, 2018 09:42
Convert iCloud Notes to Evernote using Apple Script
tell application "Notes"
set theMessages to every note
repeat with thisMessage in theMessages
set myTitle to the name of thisMessage
set myText to the body of thisMessage
@mpapierski
mpapierski / Dockerfile
Last active October 14, 2018 16:33
concraft-pl
FROM haskell:8
RUN mkdir -p /src
RUN cd /src && git clone https://github.com/kawu/concraft-pl
WORKDIR /src/concraft-pl
RUN stack setup
RUN stack install
ENTRYPOINT ["/root/.local/bin/concraft-pl"]
@mpapierski
mpapierski / replacements.sed
Created March 24, 2018 11:32
MFC to wxWidgets
s/ON_BN_CLICKED/EVT_BUTTON/g
s/AfxGetApp()/::wxGetApp()/g
s/CObject/wxObject/g
s/CRect/wxRect/g
s/CSize/wxSize/g
s/CDC/wxDC/g
s/CPoint/wxPoint/g
s/CFont/wxFont/g
s/CPen/wxPen/g
script = '''#!/bin/sh
tail -c{} $0|gunzip
exit
'''
with open('pwning2017.sh', 'wb') as fout:
with open('payload', 'rb') as fin:
payload = fin.read()
fout.write(script.format(len(payload)))
fout.write(payload)
if [ x$INCEPTION != 'x' ]; then
echo "We need to go deeper..."
echo "This was built inside docker container" > /build/hello.txt
exit 0
fi
# For storing .deb
VOLUME="$(docker volume create)"
echo "Volume is $VOLUME"
#include <iostream>
#include <string>
#include <system_error>
#include "sqlite3.h"
#include "git2.h"
struct sqlite_error_category
: std::error_category
{
const char *name() const noexcept override
{
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <array>
int
main()
{
std::ifstream ifs("/etc/passwd");