Skip to content

Instantly share code, notes, and snippets.

View graphicagenda's full-sized avatar
🥳
Just upgraded to GIt Pro

Shining Bright Diamond graphicagenda

🥳
Just upgraded to GIt Pro
View GitHub Profile
@graphicagenda
graphicagenda / hb_all_books_dl.js
Created November 17, 2020 20:00 — forked from barrywoolgar/hb_all_books_dl.js
Humble bundle book bundles - download all books at once
/*
After purchasing a humble book bundle, go to your download page for that bundle.
Open a console window for the page and paste in the below javascript.
This will download all the books in all the formats available.
*/
$('a').each(function(i){
if (['MOBI', 'PDF', 'EPUB'].indexOf($.trim($(this).text())) >= 0) {
$('body').append('<iframe id="dl_iframe_'+i+'" style="display:none;">');
document.getElementById('dl_iframe_'+i).src = $(this).data('web');
}
@graphicagenda
graphicagenda / humble-bundle-home.py
Created October 24, 2020 10:43
Listing out Humble Bundles from the home page
from collections import namedtuple
from bs4 import BeautifulSoup as Soup
import requests
import json
from datetime import datetime, timedelta
import webbrowser
from collections import Counter
HB = 'https://www.humblebundle.com'
CONTENT = requests.get(HB).text
@graphicagenda
graphicagenda / kata-module.py
Created October 4, 2020 06:13
Code Wars Kata: Numbers in Expanded Form
# https://www.codewars.com/kata/5842df8ccbd22792a4000245/train/python
def expanded_form(num):
num = list(str(num))
store = []
for i in range(len(num)):
x = int(num[i])
if x > 0:
store.append(str(int(x * ( 10 ** (len(num) - int(i) - 1)) )))
return ' + '.join(store)
@graphicagenda
graphicagenda / echocryptonumbers.sh
Created September 4, 2020 01:45
Output a chart of crypto value and percent change in the last 1h, 24h, 7d
function echocryptonumbers {
printf ' %-5s: %21s %7s %10s %9s\n' "COIN" "CURRENT VALUE" "1H" "24H" "7D"
# echo -e "Coin : Current Value 1h 24h 7d"
curl -s -H 'X-CMC_PRO_API_KEY: {CMC_PRO_API_KEY}' \
-H 'Accept: application/json' \
-d 'symbol=BTC,ETH,LTC' \
-G https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest | \
jq -r '.data | .[] | .symbol, .quote.USD.price, .quote.USD.percent_change_1h, .quote.USD.percent_change_24h, .quote.USD.percent_change_7d' | \
while read -r SYMBOL; do
read -r PRICE
@graphicagenda
graphicagenda / cryptonumbers.sh
Created August 24, 2020 23:53
Using your CMC api token, retrieve the symbol and price for selected tokens
function cryptonumbers {
curl -H 'X-CMC_PRO_API_KEY: {CMC_PRO_API_KEY}' \
-H 'Accept: application/json' \
-d 'symbol=BTC,ETH,LTC' \
-G https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest | \
jq -r '.data | .[] | .symbol, .quote.USD.price' | \
while read -r SYMBOL; do
read -r PRICE
echo -e "${SYMBOL} - \$${PRICE}"
done
@graphicagenda
graphicagenda / window-height-width.js
Last active November 29, 2019 22:54 — forked from joshcarr/window-height-width.js
[vanilla JS window width and height] #unlabeled
// vanilla JS window width and height
var w=window,
d=document,
e=d.documentElement,
g=d.getElementsByTagName('body')[0],
x=w.innerWidth||e.clientWidth||g.clientWidth,
y=w.innerHeight||e.clientHeight||g.clientHeight;
@graphicagenda
graphicagenda / wp-bootstrap4.1-pagination.php
Last active November 29, 2019 22:53 — forked from mtx-z/wp-bootstrap4.4-pagination.php
[Wordpress Bootstrap 4.1 pagination (with custom WP_Query() and global $wp_query support)] #unlabeled
<?php
/**
* @param WP_Query|null $wp_query
* @param bool $echo
*
* @return string
* Accepts a WP_Query instance to build pagination (for custom wp_query()),
* or nothing to use the current global $wp_query (eg: taxonomy term page)
* - Tested on WP 4.9.5
@graphicagenda
graphicagenda / bootstrap-pagination.php
Last active November 29, 2019 22:53 — forked from ediamin/bootstrap-pagination.php
[Bootstrap Pagination for WordPress] #WordPress #Bootstrap #unlabeled
/*
* custom pagination with bootstrap .pagination class
* source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
*/
function bootstrap_pagination( $echo = true ) {
global $wp_query;
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
@graphicagenda
graphicagenda / import_json_appsscript.js
Last active November 29, 2019 22:44 — forked from paulgambill/import_json_appsscript.js
[Import JSON Apps Script] #unlabeled
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@graphicagenda
graphicagenda / humble_bundle_file_downloader.js
Last active November 29, 2019 22:44 — forked from tlc/humble_bundle_file_downloader.js
[Download HumbleBundle book bundles easier.] Puts 'curl' statements on the page for you to copy. #unlabeled
/* 11/27/2017 - Tweaked for a page redesign.
* 1/6/2018 - Handle videos in book bundle.
*/
var pattern = /(MOBI|EPUB|PDF( ?\(H.\))?|CBZ)$/i;
var pattern2 = /(Download)$/;
var nodes = document.getElementsByTagName('a');
var downloadCmd = '';
for (i in nodes) {
var a = nodes[i];
if (a && a.text && pattern.test(a.text.trim())) {