Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Shining Bright Diamond graphicagenda

💭
I may be slow to respond.
View GitHub Profile
@graphicagenda
graphicagenda / hb_all_books_dl.js
Created Nov 17, 2020 — forked from barrywoolgar/hb_all_books_dl.js
Humble bundle book bundles - download all books at once
View hb_all_books_dl.js
/*
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 Oct 24, 2020
Listing out Humble Bundles from the home page
View humble-bundle-home.py
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 Oct 4, 2020
Code Wars Kata: Numbers in Expanded Form
View kata-module.py
# 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 Sep 4, 2020
Output a chart of crypto value and percent change in the last 1h, 24h, 7d
View echocryptonumbers.sh
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 Aug 24, 2020
Using your CMC api token, retrieve the symbol and price for selected tokens
View cryptonumbers.sh
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 Nov 29, 2019 — forked from joshcarr/window-height-width.js
[vanilla JS window width and height] #unlabeled
View window-height-width.js
// 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 Nov 29, 2019 — forked from mtx-z/wp-bootstrap4.4-pagination.php
[Wordpress Bootstrap 4.1 pagination (with custom WP_Query() and global $wp_query support)] #unlabeled
View wp-bootstrap4.1-pagination.php
<?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 Nov 29, 2019 — forked from ediamin/bootstrap-pagination.php
[Bootstrap Pagination for WordPress] #WordPress #Bootstrap #unlabeled
View bootstrap-pagination.php
/*
* 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 Nov 29, 2019 — forked from paulgambill/import_json_appsscript.js
[Import JSON Apps Script] #unlabeled
View import_json_appsscript.js
/**
* 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 Nov 29, 2019 — forked from tlc/humble_bundle_file_downloader.js
[Download HumbleBundle book bundles easier.] Puts 'curl' statements on the page for you to copy. #unlabeled
View humble_bundle_file_downloader.js
/* 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())) {