Skip to content

Instantly share code, notes, and snippets.

View guerrato's full-sized avatar

Pedro Guerrato guerrato

View GitHub Profile
@guerrato
guerrato / jsonval.sh
Created February 6, 2019 12:39 — forked from cjus/jsonval.sh
Extract a JSON value from a BASH script
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
echo ${temp##*|}
}
json=`curl -s -X GET http://twitter.com/users/show/$1.json`
prop='profile_image_url'
picurl=`jsonval`
@guerrato
guerrato / luhn_checksum_generator.php
Created May 10, 2018 19:39
This file contains a PHP code to generate a checksum based in Luhn Algorithm.
/**
* This file contains a PHP code to generate a checksum based in Luhn Algorithm.
* To learn more about Luhn algorithm: https://en.wikipedia.org/wiki/Luhn_algorithm
* To validate the generated code: https://www.dcode.fr/luhn-algorithm
*
* @param string $code
* @return int
*
* Example: $code = '7992739871'
* function returning: 3