Skip to content

Instantly share code, notes, and snippets.

View vrthra's full-sized avatar

Rahul Gopinath vrthra

View GitHub Profile
@vrthra
vrthra / gdb.rb
Created October 15, 2017 13:06 — forked from martinlindhe/gdb.rb
For gdb to execute python3 script on OSX 10.10 or later
class UniversalBrewedPython < Requirement
satisfy { archs_for_command("python").universal? }
def message; <<-EOS.undent
A build of GDB using a brewed Python was requested, but Python is not
a universal build.
GDB requires Python to be built as a universal binary or it will fail
if attempting to debug a 32-bit binary on a 64-bit host.
EOS
@vrthra
vrthra / gll.py
Created December 9, 2018 11:51 — forked from cheery/gll.py
GLL recognizer/parser
# A GLL recognizer with a twist.
# The parser builds up a list of reduction rules when it is parsing.
# Once sorted, the list can be used to build parse trees.
class GSS(object):
def __init__(self, label, index=0):
self.label = label
self.index = index
self.edges = set()
self.nodes = {}
@vrthra
vrthra / GhidraDecompiler.java
Created April 11, 2019 11:53 — forked from guedou/GhidraDecompiler.java
Call the Ghidra decompiler from the command line
// Copyright (C) 2019 Guillaume Valadon <guillaume@valadon.net>
// This program is published under a GPLv2 license
/*
* Decompile a function with Ghidra
*
* analyzeHeadless . Test.gpr -import $BINARY_NAME -postScript GhidraDecompiler.java $FUNCTION_ADDRESS -deleteProject -noanalysis
*
*/
@vrthra
vrthra / README.md
Created July 7, 2020 07:23 — forked from MineRobber9000/README.md
Import Python modules from GitHub

githubimport

Allows you to import Python modules from the top level of a GitHub repository. Basically, golang's import semantics but in Python fashion.

>>> import githubimport
>>> from MineRobber9000.test_modules import blah
>>> blah.foo()
"bar"
Q: Who are you?
A: (I assume you're wondering about my name, but maybe also what I do.) I'm an AI that they call GPT-3.
Q: What is human life expectancy in the United States?
A: (The global life expectancy is 72.3 years so it should be around there.) Human life expectancy in the United States is 78 years.
Q: Who was president of the United States in 1955?
A: (Dwight D. Eisenhower served as president from 1953 to 1961.) Dwight D. Eisenhower was president of the United States in 1955.
Q: What party did he belong to?
@vrthra
vrthra / donotuse3.py
Created September 18, 2020 07:11 — forked from MineRobber9000/donotuse3.py
How to NEVER use lambdas - Python 3 edition
###########################################################
# How to NEVER use lambdas. An inneficient and yet educa- #
# tonal [sic] guide to the proper misuse of the lambda #
# construct in Python 3.x. [DO NOT USE ANY OF THIS EVER] #
# original by (and apologies to): e000 (13/6/11) #
# now in Python 3 courtesy of: khuxkm (17/9/20) #
###########################################################
## Part 1. Basic LAMBDA Introduction ##
# If you're reading this, you've probably already read e000's
@vrthra
vrthra / capture.py
Created February 10, 2022 08:13 — forked from oinume/capture.py
Capture stdout/stderr in Python
import cStringIO
import sys
class IOCapture(object):
def __init__(self, stdout = True, stderr = True):
self.captured_stdout = None
self.captured_stderr = None
if stdout:
self.captured_stdout = cStringIO.StringIO()
if stderr:
@vrthra
vrthra / markdown-flavors.md
Created March 2, 2022 13:14 — forked from vimtaai/markdown-flavors.md
Comparison of features in various Markdown flavors

Comparison of syntax extensions in Markdown flavors

I created a crude comparison of the syntax of the various common Markdown extensions to have a better view on what are the most common extensions and what is the most widely accepted syntax for them. The list of Markdown flavors that I looked at was based on the list found on CommonMark's GitHub Wiki.

Flavor Superscript Subscript Deletion*
Strikethrough
Insertion* Highlight* Footnote Task list Table Abbr Deflist Smart typo TOC Math Math Block Mermaid
GFM
@vrthra
vrthra / gantt.py
Created May 16, 2022 01:18 — forked from Thiagobc23/gantt.py
Gantt Chart with Matplotlib v2
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
from pandas import Timestamp
##### DATA #####
data = {'Task': {0: 'TSK M',
1: 'TSK N',
2: 'TSK L',
@vrthra
vrthra / Working GDB on macOS 11.md
Created August 19, 2022 22:44 — forked from mike-myers-tob/Working GDB on macOS 11.md
Steps to get GDB actually working in April 2021 on macOS

Debug with GDB on macOS 11

The big reason to do this is that LLDB has no ability to "follow-fork-mode child", in other words, a multi-process target that doesn't have a single-process mode (or, a bug that only manifests when in multi-process mode) is going to be difficult or impossible to debug, especially if you have to run the target over and over in order to make the bug manifest. If you have a repeatable bug, no big deal, break on the fork from the parent process and attach to the child in a second lldb instance. Otherwise, read on.

Install GDB

Don't make the mistake of thinking you can just brew install gdb. Currently this is version 10.2 and it's mostly broken, with at least two annoying bugs as of April 29th 2021, but the big one is https://sourceware.org/bugzilla/show_bug.cgi?id=24069

$ xcode-select install  # install the XCode command-line tools