Skip to content

Instantly share code, notes, and snippets.

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

J Harley julzhk

🏠
Working from home
  • -
  • canada
View GitHub Profile
@julzhk
julzhk / pass_on_url_parameters.js
Last active August 19, 2020 09:17
pass on url parameters: append all url parameters from the visited page to every anchor tag in that page
<script>
var getParams = function (url) {
var params = {};
var parser = document.createElement('a');
parser.href = url;
var query = parser.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (typeof (pair[1]) !== 'undefined') {
@julzhk
julzhk / find_mode_fields_used_in_template_files.py
Created August 14, 2019 15:43
Are Django fields being used in my templates?
import os
from subprocess import check_output
from django.apps import apps
# Are my django model fields actually being used in my templates? This function lists the unused ones.
# Note - scans for *html and api.py (Django Rest Framework) files
def find_str(needle, full_path='/home/myacct/Projects/my_project/'):
try:
f = check_output(f'/bin/grep -nr --include="*.html" "{needle}" ' +
@julzhk
julzhk / server.py
Last active May 15, 2019 14:15
simple python 3 server
#!/usr/bin/env python3
import time
from datetime import datetime
from http.server import HTTPServer, BaseHTTPRequestHandler
class Server(BaseHTTPRequestHandler):
def do_HEAD(self):
return
import pandas as pd
pieces_position_list = ['A_Red', 'B_Yellow', 'A_Red', 'B_Yellow', 'A_Red', 'B_Yellow', 'G_Red', 'B_Yellow']
def check_winner(df, colours = ['Red', 'Yellow']):
for col in df.columns:
series = df[col]
prev, count = '?', 1
for i in series:
@julzhk
julzhk / digiteyes.py
Last active December 29, 2020 08:07
www.digit-eyes.com Python API
"""
https://www.digit-eyes.com/ has an API, that uses 2 keys: one to access the API, and another to sign each request.
The documentation doesn't appear to have a Python 3.7 implementation of the signing algorithm, hence this gist.
---
Uses the requests HTTP library.
"""
import os
import base64
@julzhk
julzhk / ChromebookDev.md
Last active June 11, 2018 11:35 — forked from iamerikjolson/ChromebookDev.md
How to setup your Chromebook as a dev box

These instructions will not work on Chromebooks with an ARM processor. If you have an ARM processor then you cannot install Chromebrew to get git. You'll need to instead install crouton. Here are instructions that you can follow: https://github.com/macton/arch-linux-install-notes/tree/master/arm-chromebook-chroot

#Configuring Chromebook for Development

After a full Sunday of trial and error, and stepping through many semi-complete or dated blog posts explaining how to do this, I was able to get the Chromebook into developer mode, install git, Node.js, and NPM.

Here's what I did...

  1. Enable Developer Mode
  • Press Esc-Refresh-Power keys which will reboot the Chromebook
@julzhk
julzhk / context_manager_hiding_complexity.py
Last active January 27, 2018 13:54
Using a context manager to hide complexity & separate concerns
class ExcelContext():
def __enter__(self, filename='numbers.xls'):
#..set up an excel document: eg: self.fn = filename..
return self
def write(self,data):
#..do the excel cell writing & any formatting etc etc.
pass
def __exit__(self):
@julzhk
julzhk / Procfile
Last active December 5, 2017 22:28 — forked from avram-dames/Procfile
Heroku Procfile to run airflow webserver
web: airflow webserver --port=$PORT --hostname==0.0.0.0
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.ood_img {
height: 163px;}
</style>
<meta charset="utf-8" />
<script type="text/javascript">if( screen.width<768 ){ document.write('<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1, initial-scale=1">'); }</script>
@julzhk
julzhk / index.html
Last active August 29, 2015 14:05
object of the day demo
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="http://www.vam.ac.uk/_designs/new-squiz/css/main.css" media="all">
<script type='text/javascript' src='http://code.jquery.com/jquery-2.1.1.min.js'></script>
<script type='text/javascript' src='recent_tumblr.js'></script>
<style>