Skip to content

Instantly share code, notes, and snippets.

View noize-e's full-sized avatar

noiz-e noize-e

View GitHub Profile
@noize-e
noize-e / normalize_str.py
Created February 13, 2019 06:44
Normalize a given string to fit the data it contains, like simple test, or email to a password
def normalize(obj, dict_key=None, regx="text"):
""" This function cleans and normalize a given string. It performs three
main operations: Sets to lower case, strips any trailing whitespace and
finally substracts any character that isn't allowed in the string type
regex, the character is replaced with an empty string.
:param obj: this object can be 'str' or 'dict' instance type.
:type obj:str It performs a directly normalization
:type obj:dict It expects a key ( from 'dict_key' arg ) string
to extract the string to be normalize, otherwise returns None.
@noize-e
noize-e / semanage_fcontext.sh
Last active November 7, 2020 08:05
SELinux file context& permissions( 755 ) fixer
#!/bin/bash
#
# Change file or dir permissions mode and, sets SELinux 'httpd_sys_script_exec_t' file context.
# Permissions mode: (u:7) (g:5) (o:5)
# (u) the user who owns it
# (g) other users in the file's group
# (o) other users not in the file's group
#
# Usage: fix_perms {grp-name} {directory|filename}
@noize-e
noize-e / logging.js
Created March 6, 2019 20:03
Logging Functions toolkit
/**
* Logging Functions Toolkit.
*
* Logs with a prefixed message, if console.log isn't available, none op is performed
* @param {object} arguments
*/
function log(){
if ( window.console && console.log )
console.log.apply( this, prefixedArray( arguments ) );
}
@noize-e
noize-e / firewall.sh
Created May 29, 2019 06:48
macOS socketfilterfw firewall decorator
#!/usr/bin/env bash
set -o errexit
set -o errtrace
usage() {
printf "\
macOS socketfilterfw decorator.
firewall [-command] [args]
@noize-e
noize-e / converter.py
Created August 16, 2019 03:51
Parse JSON maps for Jit.js Interactive Maps & Graphviz Diagrams
import json
import pprint
import sys
if sys.argv[1] is None:
print "JSON source not defined"
exit()
# e.g. _data/source-tree-templates.json
@noize-e
noize-e / curl reference
Created January 31, 2020 03:55 — forked from afair/curl reference.md
Curl command reference with options sorted by category for easier usage than that man page.
==========================================
CURL COMMAND
==========================================
Format curl [options] [URL...]
Quick Ref:
curl -X POST http://example.com/ <= Method option and URL (Options come before or after URL)
-H "Authorization: <data>" <= Add HTTP Header (like Authorization)
@noize-e
noize-e / loads_dynamodb_json_schema.py
Last active October 22, 2023 18:06
Convert a dynamodb JSON schema into a regular JSON
from pprint import pprint
import json
import sys
import os
DATA_TYPES = {
"S": lambda x: str(x),
"B": lambda x: bool(x),
"N": lambda x: str(x),
@noize-e
noize-e / ignore
Last active September 25, 2021 23:30
Create and manage the .gitignore file
#!/usr/bin/env bash
set -o errexit
_FILES_RULES=('.DS_Store' 'node_modules ' '.jekyll-cache' '.sass-cache' '.venv' 'venv')
_USAGE="$(printf """
Git .gitignore file helper tool.
Usage: ignore (filepath) ([OPTIONS])
@noize-e
noize-e / deb-utils.sh
Created November 7, 2020 08:22
Functions toolbox for linux (debian distros)
#!/usr/bin/env bash
# Generate password hash
#
genpwd(){
echo $(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 20 | xargs)
}
# Check internet connection
#
@noize-e
noize-e / jekyll._config.yml
Last active November 16, 2020 01:32
Jekyll boilerplate - build configuration yaml and default html layout
# Site
title: "you site title"
email: webmaster@yoursite.com
description: >- # this means to ignore newlines until "baseurl:"
Your site description
# Env: localhost
url: "http://localhost/" # the base hostname & protocol
baseurl: "/cc" # the subpath, e.g. /parefix
port: 5000