Skip to content

Instantly share code, notes, and snippets.

'''
dive
open a gdb session targeting a python compiled with gdb debugging enabled
alias dive='gdb -iex '\''add-auto-load-safe-path .'\'' /opt/cpython/python'
in gdb:
b 1
r
s
#!/bin/sh
FORMAT="{
\"name\": \"%n\",
\"access\": \"%A\",
\"size\": \"%s\"
},
"
printf "$(stat --printf="${FORMAT}" $*)"
printf "\b"
const { map, filter, reduce } = require('lodash');
// array from 0 to 9
const data = [0,1,2,3,4,5,6,7,8,9];
// helper functions
const doubled = val => val * 2;
const isEven = val => val % 2;
const isOverTen = val => val >= 10;
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}() [${PIPESTATUS[*]}] }'
@classmember
classmember / file_perms_eq.sh
Created May 9, 2018 15:32
file_perms_eq.sh
# function: file_perms_eq
# description: checks first option (filename) to see if the file perms equals the second option (permissions)
# usage example:
# $ if file_perms_eq mail 700
# > then echo 'good'
# > fi
file_perms_eq() { (( $(stat -c "%a" $1) == $2 ));}
<!DOCTYPE html>
<html>
<body>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<style>
h1,h2,h3,h4,h5,h6,p,label,input {font-family: 'Lato', sans-serif;}
body {padding: 2rem;}
</style>
#!/usr/bin/python
def main():
'''
This is the Python equivalent to the following C code:
int n;
printf("Enter a Number");
scanf("&d",n);
if(n==1)
printf("true");
#!/usr/bin/env python
'''
Inspired by https://xkcd.com/1930/
'''
from random import randint
class CalendarFact:
def __init__(self):
self.date = ['The Fall Equinox',
/**
* Large numbers example using built-in data types
*
* Author:
* Kolby H. <kolby@fasterdevops.com>
*
* Published:
* November 24, 2017
*
* Usage:
next feature:
- import statement
- store and retrieve hashmaps
- variable handling (list of dictionaries)
technical features:
- function statement
- argument parsing
- commands:
- print statement