Skip to content

Instantly share code, notes, and snippets.

Orestes Sanchez miceno

Block or report user

Report or block miceno

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
miceno /
Created Apr 5, 2019
Disk usage human sorted on HDFS
#!/usr/bin/env bash
hdfs dfs -du -s -h $1/* | sed -e 's/ \([GMTK]\)/\1/g' | sort -h
miceno /
Created Jan 8, 2019
Show how a file size changes overtime
while true;
ls -s $FILE;
sleep 1;
done | awk 'BEGIN{ previous=0;}{ current=$1; if(previous==0) previous=current; d=current-previous; previous=current; print d;}'
miceno / email-confirm.js
Created Aug 18, 2018
Email confirmation for Wordpress Contact Form 7 plugin
View email-confirm.js
// Put this file inside your theme in folder js (js/email-confirm.js)
// First we add a hook to the form submit event
jQuery( document ).ready( function () {
jQuery('.wpcf7-submit').click(function () {
// We remove the error to avoid duplicate errors
// We create a variable to store our error message
var errorMsg = jQuery('<span class="error">Your emails do not match.</span>');
miceno / update_json.sql
Created Feb 12, 2018
Massively update in place json in PostgreSQL
View update_json.sql
UPDATE sns_log_testing AS u
SET message = jsonb_set(t.message, '{type}', JSONB '"DEVICE_EVENT"')
FROM sns_log_testing AS s
WHERE s.message ->> 'type' = 'CLIENT_EVENT'
AND s.message ->> 'event_type' = 'NOTIF_REQUEST'
LIMIT 10000) AS t
miceno / export-import-csv.sql
Created Feb 2, 2018
Export and import CSV in postgres
View export-import-csv.sql
-- On the server.
-- \copy is run on the client side, so if you run in your local machine to connect to the remote
-- server, you will transfer the results probably in plain. So better run it on local.
\copy (Select * From sns_log where received > '2018-01-01') To '/tmp/log-20180101.csv' With CSV delimiter ','
-- On the client side.
\COPY sns_log FROM 'log-20180101.csv' WITH delimiter as ',' csv
miceno /
Created Jan 5, 2018
Sniff HTTP headers directly with tcpdump
#!/usr/bin/env bash
tcpdump -i $INTERFACE -A -s 10240 'tcp port '$PORT' and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
| egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " \
| sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'
miceno /
Created Jan 4, 2018
Bulk remove elasticsearch indexes
#!/usr/bin/env bash
curl "$SERVER/_cat/indices?v" | awk '{ print $3}' | sort > /tmp/indexes.txt
while read -u 3 f;
echo $f
miceno /
Last active Dec 28, 2017
Number of documents of an elasticsearch index
# elasticsearch url
curl -s $URL/logstash-nginx-*/_count | sed -e 's/^.*"count":\([^,]*\),.*$/\1/'
miceno /
Created Dec 27, 2017
Extract json text value
echo '{"count":"7363","_shards":{"total":1,"successful":1,"failed":0}}' | sed -e 's/^.*"count":"\([^"]*\)".*$/\1/'
miceno /
Created Dec 27, 2017
Extract number value from json
echo '{"count":7363,"_shards":{"total":1,"successful":1,"failed":0}}' | sed -e 's/^.*"count":\([^,]*\),.*$/\1/'
You can’t perform that action at this time.