Skip to content

Instantly share code, notes, and snippets.

@erd0s
erd0s / gdb.md
Last active December 28, 2019 16:59
GDB/ASM Notes

CONTINUE FROM 0x271 Memory Segments in C

Commands

  • run
  • break <func name>, always works, break 5 only works if you've compiled with debug symbols (you can do this with gcc -g blah.c.
  • list Show source code if build with debug info.
  • disassemble main Show asm for the main function.
  • x Examine memory, should be x/[number of units to display]<format>[unit size] <mem addr>
    • <format> can be x (hex), o (octal), u (unsigned int), i (instruction), s (string, here we don't need to worry about size, it will just show until it meets a \0)
    • <mem addr> can be 0x8048384, or $rip or $rip+8 or some_var if there's a variable called that and we compiled with debug info.
@erd0s
erd0s / scrape-twitter-retweet-handles.js
Created August 23, 2019 13:51
scrape-twitter-retweet-handles.js
// Find the element
let scrollableElement = document.querySelector("div[aria-label='Timeline: Retweeted by']").parentElement.parentElement.parentElement;
// Get the height
let elementHeight = scrollableElement.scrollHeight;
// Scroll through and grab all divs each time
async function grabthem() {
let scrolls = Array.from(Array(Math.floor(elementHeight/500)).keys()).map(o => o * 500);
let retweeters = [];
@erd0s
erd0s / ubuntu-set-shortcuts-5+.sh
Created January 18, 2018 01:17
Set keyboard shortcuts for switch to workspaces, for more than 4 workspaces, in gnome
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-1 "['<Primary><Alt>1']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-2 "['<Primary><Alt>2']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-3 "['<Primary><Alt>3']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-4 "['<Primary><Alt>4']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-5 "['<Primary><Alt>5']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-6 "['<Primary><Alt>6']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-7 "['<Primary><Alt>7']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-8 "['<Primary><Alt>8']"
@erd0s
erd0s / rowspan-blake.js
Created February 10, 2017 07:58
Extract railway codes (Blake's better method)
(function(){
var setValue = function (row, col, value) {
records[row][col] = value;
// TESTING ONLY
var td = testTable.querySelector('tr:nth-child(' + (row + 1) + ') > td:nth-child(' + (col + 1) + ')');
td.innerText = value;
// EOF TESTING
};
@erd0s
erd0s / rowspan.js
Last active February 24, 2023 16:04
Turn an HTML table with rowspans into a csv with rowspan data duplicated
var rows = document.querySelectorAll("table div table > tbody tr");
var records = [];
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var cells = row.querySelectorAll("td");
cells.forEach((o, j) => {
// Put in the forward rows data
if (o.rowSpan > 1) {
@erd0s
erd0s / scrape-jira-tickets.js
Created January 30, 2017 22:48
Scrape tickets from jira in the sprints/details view
/**
* Plop this into chrome dev console, once it's done the var tickets will be populated with ticket details.
*
* Handy if you need to get a bunch of jira tickets to offline versions for reading on a plane!
*/
var tickets = [];
var cards = document.querySelectorAll(".ghx-backlog-card");
var cardsLength = cards.length;
var currentCard = 0;
<?php
namespace Seatfrog\WebservicesBundle\Command;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Tools\SchemaTool;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
function getDepth(ArrayCollection $set, $currentItem, $currentDepth) {
@erd0s
erd0s / ValidateLuhnString.swift
Last active February 12, 2016 02:37
Validate credit card number with Luhn algorithm
/**
* String extension to validate credit card number.
* Automatically strips any whitespace from the string but otherwise the string
* should not contain and non-numeric characters.
*/
extension String {
func validateLuhn() -> Bool {
let nsStringVersionNoSpaces = (self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet()) as NSString)
if (self.rangeOfString("^[0-9]+$", options: .RegularExpressionSearch) == nil) {
return false