Skip to content

Instantly share code, notes, and snippets.

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. <[email protected]>
*
* 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
#!/bin/sh
# list primary domains of all
# cPanel backups in the current directory.
for file in $(\ls backup-*); do
tar --occurrence=1 \
--to-stdout \
--extract \
--verbose \
--gzip \
#!/bin/sh
# tail_logs.sh
tail_logs() {
# arguments: IP addresses to search for in logs.
files='/usr/local/apache/access_log
/usr/local/apache/error_log
/var/log/nginx/access.log
/var/log/nginx/error.log'