Skip to content

Instantly share code, notes, and snippets.

View johnsnook's full-sized avatar
🏠
Working from home

John Snook johnsnook

🏠
Working from home
View GitHub Profile
@johnsnook
johnsnook / cards.json
Last active October 3, 2019 20:50
Example python with json tarot program
{
"tarot": [
{
"reversed": "Negligence, absence, distribution, carelessness, apathy, nullity, vanity.",
"interpretation": "Folly, mania, extravagance, intoxication, delirium, frenzy, bewrayment. ",
"name": "The Fool",
"description": "With light step, as if earth and its trammels had little power to restrain him, a young man in gorgeous vestments pauses at the brink of a precipice among the great heights of the world; he surveys the blue distance before him-its expanse of sky rather than the prospect below. His act of eager walking is still indicated, though he is stationary at the given moment; his dog is still bounding. The edge which opens on the depth has no terror; it is as if angels were waiting to uphold him, if it came about that he leaped from the height. His countenance is full of intelligence and expectant dream. He has a rose in one hand and in the other a costly wand, from which depends over his right shoulder a wallet curiously embroider
@johnsnook
johnsnook / Youtube vlc playlist bookmarklet.js
Last active March 15, 2019 15:44
Put this in a chrome bookmark url field and click on while on a youtube playlist to download a vlc playlist.
javascript:(function () {
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
vars[key] = value;
});
return vars;
}
@johnsnook
johnsnook / children_ids.sql
Last active September 13, 2018 18:23
Postresql child record ids as an array
-- I don't understand how totally this works but it does so
CREATE AGGREGATE children_ids (anyelement)
(
sfunc = array_append,
stype = anyarray,
initcond = '{}'
);
-- then you can do
#!/usr/bin/python
import os
import sys
import csv
import datetime
import time
import twitter
def test():
@johnsnook
johnsnook / gererate-date-series.sql
Last active August 30, 2018 17:40
Postgresql sql to get all dates in a range even if there's no date, filling it in
with days as (
select *
from generate_series(
(select min(created_at::date) from visits),
(select max(created_at::date) from visits),
'1 day'
) day
)
select d.day, count(distinct v.ip)
from days d
@johnsnook
johnsnook / CardWidget.php
Created July 3, 2018 15:48
Yii2 Bootstrap 4 Card Widget
<?php
namespace johnsnook\ipFilter\widgets;
/**
* @author John Snook
* @date 2018-07-2
* @license https://github.com/johnsnook/yii2-ip-filter/LICENSE
* @copyright 2018 John Snook Consulting
*/
@johnsnook
johnsnook / PanelWidget.php
Created July 3, 2018 15:47
Yii2 bootstrap 3 panel widget
<?php
namespace johnsnook\ipFilter\widgets;
/**
* @author John Snook
* @date 2018-07-2
* @license https://github.com/johnsnook/yii2-ip-filter/LICENSE
* @copyright 2018 John Snook Consulting
*/
@johnsnook
johnsnook / _aStack.html
Last active July 2, 2018 21:13
The problem with tabbed interfaces is you can't see what you're going to get. You just see a boring tab with a stupid label. With stax, your "tab panes" are displayed like a stack of papers, giving the user a peek. Instead of clicking a tab, you click the content you want to view.
<style>
.stack{
position: relative;
/* left: 50px;
right: 50px;*/
border: 5px beige outset;
}
.stackable{
position: absolute;
}
@johnsnook
johnsnook / upvoteAll.js
Created April 4, 2018 17:15
Reddit upvote all bookmark button
/**
* @Author: John Snook
* Installation:
* 1) In Chrome or Firefox, create a bookmark, (eg bookmark this page).
* 2) Then, right click on the bookmark, and select "edit...".
* 3) Change 'Name' field to "Upvote all" or "▲*"
* 4) Copy and paste the code below into the "Url" field. (not the comments)
* 5) Go to https://reddit.com/r/all, log in and click your new bookmark.
*/
javascript: (function() {
@johnsnook
johnsnook / downvoteAll.js
Last active April 4, 2018 17:15
Reddit downvote all bookmark button
/**
* @Author: John Snook
* Installation:
* 1) In Chrome or Firefox, create a bookmark, (eg bookmark this page).
* 2) Then, right click on the bookmark, and select "edit...".
* 3) Change 'Name' field to "Downvote all" or "▼*"
* 4) Copy and paste the code below into the "Url" field. (not the comments)
* 5) Go to https://reddit.com/r/all, log in and click your new bookmark.
*/
javascript: (function() {