Skip to content

Instantly share code, notes, and snippets.

View atomize's full-sized avatar
🎹
♩♩

Berti atomize

🎹
♩♩
View GitHub Profile
@atomize
atomize / printonlyafterstring.sed
Created March 13, 2017 07:14
Prints only what is after printonlywhatsafterme
sed -n -e 's/^.*printonlywhatsafterme //p' textfile.txt
@atomize
atomize / 16_colors_and_formatting.sh
Created May 28, 2017 19:12
Bash 16 colors and formatting escape sequences.The following shell script displays a lot of possible combination of the attributes (but not all, because it uses only one formatting attribute at a time). [SOURCE: http://misc.flogisoft.com/bash/tip_colors_and_formatting]
#!/bin/bash
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#Background
for clbg in {40..47} {100..107} 49 ; do
@atomize
atomize / 256-colors.sh
Created May 28, 2017 19:13
Bash terminal 256 colors escape sequences. The following script display the 256 colors available on some terminals and terminals emulators like XTerm and GNOME Terminal.
#!/bin/bash
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
for fgbg in 38 48 ; do #Foreground/Background
for color in {0..256} ; do #Colors
@atomize
atomize / spreadOperatorSyntax.js
Created September 23, 2017 19:03
Example of concatenating arrays using spread syntax in pure Javascript.
var arr1 = [0, 1, 2];
var arr2 = [3, 4, 5];
arr1 = [...arr2, ...arr1]; // arr1 is now [3, 4, 5, 0, 1, 2]
// source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator
@atomize
atomize / AWSCORS.xml
Created October 16, 2017 01:52
Allow Dangerous Public JSON from S3
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>5000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@atomize
atomize / i3_wm_application_specific_rules.config
Created October 22, 2017 21:16
Rules for enabling floating on specific applications in i3wm
#### RULES FOR SPECIFIC APPLICATIONS ####
# from: http://www.linuxlusers.com/2012/12/24/i3-window-manager-tip-making-specific-applications-and-child-windows-open-in-floating-mode-or-with-other-custom-settings/
# by APPLICATION (WM_CLASS)
# Note: class is typically useful for applying custom settings to
# to entire applications, including child windows. If this
# isn't want you want see the ROLE section, below.
# Tip: To find out what these values might be run:
# xprop | grep -i 'class'
for_window [class="File-roller"] floating enable, border normal
for_window [class="Speedcrunch"] floating enable, border normal
<!DOCTYPE html>
<ol contenteditable oninput="">
<li>Press enter</li>
</ol>
<script>
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var list = document.querySelector('ol');
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
@atomize
atomize / CSVtoJSON.sh
Created October 28, 2017 22:13
CSV to JSON converter using BASH -- best one from updates in comments of https://gist.github.com/dsliberty/3de707bc656cf757a0cb
#!/bin/bash
# CSV to JSON converter using BASH
# original script from https://gist.github.com/dsliberty/3de707bc656cf757a0cb
# Usage ./csv2json.sh input.csv > output.json
#set -x
shopt -s extglob
input="${1:-}"
@atomize
atomize / LookupTablesShorthand.js
Created November 3, 2017 00:20
Lookup tables shorthand in javascript.
// Longhand
if (type === 'aligator') {
aligatorBehavior();
}
else if (type === 'parrot') {
parrotBehavior();
}
else if (type === 'dolphin') {
dolphinBehavior();
}
@atomize
atomize / SCPtoS3.sh
Last active November 9, 2017 19:45
SCP to S3 bucket (requires AWS cli tools)
#!/bin/sh
# Original: https://github.com/dial-once/docker-crons/blob/master/scripts/scp-to-s3.sh
# SCP script to make a remote folder sent to AWS S3!
#
# # # # # # #
# Env vars #
# # # # # # #
# - SCP_HOST - server hostname
# - SCP_PORT - server port
# - SCP_USER - server username