This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| FORMAT="{ | |
| \"name\": \"%n\", | |
| \"access\": \"%A\", | |
| \"size\": \"%s\" | |
| }, | |
| " | |
| printf "$(stat --printf="${FORMAT}" $*)" | |
| printf "\b" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}() [${PIPESTATUS[*]}] }' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 ));} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| Inspired by https://xkcd.com/1930/ | |
| ''' | |
| from random import randint | |
| class CalendarFact: | |
| def __init__(self): | |
| self.date = ['The Fall Equinox', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Large numbers example using built-in data types | |
| * | |
| * Author: | |
| * Kolby H. <kolby@fasterdevops.com> | |
| * | |
| * Published: | |
| * November 24, 2017 | |
| * | |
| * Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| next feature: | |
| - import statement | |
| - store and retrieve hashmaps | |
| - variable handling (list of dictionaries) | |
| technical features: | |
| - function statement | |
| - argument parsing | |
| - commands: | |
| - print statement |