Skip to content

Instantly share code, notes, and snippets.

@cryocaustik
cryocaustik / findtables.py
Last active January 2, 2019 23:48
quick script to find names of tables used in .sql queries
import os
import re
class FindTables:
"""Finds SQL files in directory tree and returns and SQL tables found.
String searches are case in-sensitive and are only considered if they follow a [from|into|join] string.
Returns:
@cryocaustik
cryocaustik / README.md
Created December 19, 2018 20:21
Django using Jinja2 template engine and importing Django filters

Django using Jinja2 Template Engine + Django Filters

quick example of the setup files to allow the use of Jinja2 template engine within Django, while still being able to import Django template filters (e.g. Humanize).

Initial Setup

Following the Django Built-in Template docs, you will need to insure you have Jinja2 installed and then we need to create a jinja2.py setup file in our main app directory (same locaiton of our settings.py file).

@cryocaustik
cryocaustik / discourse-dark.css
Created August 21, 2018 18:33
simple modification to alter the discourse dark theme
/* common */
body {
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
#main-outlet{
background-color: rgba(30, 30, 30, 0.9);
}
@cryocaustik
cryocaustik / PythonicSlack.py
Last active October 8, 2018 19:48
python script to apply dark theme to the latest Slack Chat app
import requests
import os
class PythonicSlack():
"""Identified latest version of Slack App and applies dark theme to it.
Raises:
Exception: Exception raised in the event that the Slack Root directory is not found
Exception: Exception is raised in event that the Slack App directory is not found in the Slack Root direcotry
ValueError: Exception is raised in the event that the slack theme is blank
data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAGuAAAAtACAIAAADCDSTtAAAYhXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZppciW3kqX/YxW9BDgmB5aD0ax30Mvv7wQpqaT3qsyqrJJSkrx5bwTgwxkcEe7/+78v/B/+1FZLKNV7G61F/pRRRpr80OPPn5/vFsv39/fnRpu/r/7t9cDP6/sp8VLme/75h3Z/vvMxi/WvD3j5fX39/fXg++eH1H8v9PsPXPj7k3Vn/fz7vv57oZx+Xrff38P4/dws/2E7v/+n/XvZ34v/8/fiBONUrpdTSDdbjvyddJfMCnLPk+/623LSm3L+8xX+/PvYhT9//Efw2vpzi3+LXZy/78h/D0WI7fcN7R8x+n3d6j9e/+OCitB/XJH98WP6+z+890cY/zV2753+3v3Z3SyNSLXwu6k/Qmg/FzlsrPxEo/Hl/F/52b+vwVdni5tbHbK5+NrBhiWizf3t2LRn9/u+bbPEkm5yvqe0U/5e69nTSPtLStGXveR55BPIRcqbrGVeTn+uxb77ju9+2zp3PsY7k3ExcvmvX+Hfvfg/+frzQu+pdM0UzLa+WLGupJpmGcqc/uZdpMDeb0zrF9/vK/yZ1r/+KLGZDNYvzJ0Nzrh+LrGq/VVb+ctz5n01lhB/kmx+fi9AiLh3ZTGWyUBslqs1i56SmxHHTn4mK0+5pEUGrNZ0LDxyk3MjOT3p3nzG7XtvqunnZaCFRNTcspOakSfJKqVSP146NTRrBo9qBZa89jrqbLmVVltr3oRR07MXr97cvfvw2XMvvfbWvfc++hxpZCCsjjY8jD7GmJObTi49+fTkHXOutPIqq662fPU11tyUzy677rZ99z32POnkQ/ufdjycfsaZ1y6ldMutt12//Y47H7X28iuvvvb89Tfe/DNrv1n9e9bsH5n7r7Nmv1lTxsr3Pv8ra7zs/sclTHBSlTMyloqRcVcGBE7KWexWSlLmlLM4BFc1k
@cryocaustik
cryocaustik / dateAdd.js
Created June 19, 2018 23:23
JS Date Addition/Subtraction function
function dateAdd(interval, qty, _date) {
if(!_date){_date = new Date();}
if (interval.toLowerCase() === 'd') {
if(qty >= 0){
_date.setDate(_date.getDate() + qty);
} else {
_date.setDate(_date.getDate() - Math.abs(qty));
}
return _date;
@cryocaustik
cryocaustik / copypasta.py
Created May 17, 2018 06:16
copy return delimited string from clipboard and then paste and submit each entry
def copypaste():
_list = pc.paste().split('\n')
for indx, _item in enumerate(_list):
if indx == 0:
_cd = list(range(5))
_cd.reverse()
for _c in _cd:
print('copy pasta in {}...'.format(_c))
sleep(1)
pc.copy(_item)
@cryocaustik
cryocaustik / README.md
Last active May 29, 2021 15:12
finds all CSV files in specified directory and loads them into specified sqlite database, using a row limit for reading large files
@cryocaustik
cryocaustik / asyncAjaxRequest.js
Last active February 23, 2018 18:49
example of async ajax request
function asyncRequest() {
var url = 'https://api.github.com/users/narenaryan';
return new Promise(function (resolve, reject) {
$.ajax({
url: url,
type: "GET"
})
.done(function(data){
resolve(data);
})