Skip to content

Instantly share code, notes, and snippets.

@z-------------
z------------- / decode.py
Last active August 29, 2015 14:09
Decode latitude/longitude data from CPR-encoded hex strings
import socket
import math
def nround(n):
if n % 0.5 == 0:
return math.ceil(n)
else:
return round(n)
def hex2bin(hex_str):
@z-------------
z------------- / golden-seq.py
Created November 6, 2014 01:34
Golden sequences in Python
#!/usr/bin/python3
import sys
import math
import time
phi = (1+math.sqrt(5))/2
print("Phi = " + str(phi))
@z-------------
z------------- / avg.py
Last active August 29, 2015 14:08
Calculate all three averages in Python. Intended for command-line use.
#!/usr/bin/python3
import sys
import operator
numbers = sys.argv[1].split(",")
if len(sys.argv) > 2:
type = sys.argv[2]
else:
<!-- ... -->
<header>
<img src="//placehold.it/190x190"><!-- img tag represents an image. src attribute tells the browser where the image is located, currently placehold.it, because the new logo hasn't been made yet -->
<h1>Student Council</h1><!-- the h1, h2, h3, h4, h5 and h6 elements represent headers, h1 being the biggest and h6 the smallest -->
<nav><!-- functionally nearly identical to a div, but used for semantic reasons -->
<a href="#introduction">Introduction</a><!-- a, short for anchor, represents a link that, when clicked, takes the user to a different page. in this case, the only change made is to the url hash, which will be handled by javascript and show a different section to the user -->
<a href="#members">Members</a><!-- the code I used to achieve the single-page multiple-page effect will be explained in a blog post after this one -->
<a href="news">News</a>
<a href="#contact">Contact us</a>
</nav>
<!DOCTYPE html><!-- tell the browser that the page is written in HTML5, the latest version of the HTML standard -->
<html><!-- element that contains all the HTML of the page -->
<head><!-- information for the browser about how to read the page -->
<title>Student Council</title><!-- title displayed in tab bar, bookmarks, history etc -->
<meta charset="utf-8"><!-- tell the browser that the file is encoded in UTF-8, a character encoding able to encode all characters in Unicode -->
</head>
<body><!-- the actual content of the page -->
</body>
</html>
@z-------------
z------------- / _baconhawk.txt
Last active December 9, 2019 12:27
Baconhawk tabs/chords/lyrics
Hello, human (or bot).
This the Baconhawk tab thingamajiggy.
Please enjoy, no pressure.
(don't worry about major/minor, just wing it)
@z-------------
z------------- / loremify.js
Created October 10, 2014 00:22
Automically insert placeholder text in every header and paragraph
(function(){
var header = "Lorem Ipsum";
var paragraph = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue.";
var headerElems = document.querySelectorAll("h1, h2, h3, h4, h5, h6");
var pElems = document.querySelectorAll("p");
for (var i = 0; i < headerElems.length; i++) {
headerElems[i].textContent = header;
}
@z-------------
z------------- / nntp-font.html
Created October 7, 2014 02:24
Change font in New New Tab Page
<!-- change all fonts -->
<style>*{font-family: "My scrubby font";}</style>Your text here
<!-- change just the header font -->
<span style="font-family: 'My scrubby font'">Your text here</span>
@z-------------
z------------- / nntpSwagTitle.html
Created September 15, 2014 06:45
Paste this in the "New tab title text" box in options for extreme swag
<marquee scrollamount="100" style="font-family:Impact; text-shadow: 7px 7px 5px black, -7px 7px 5px black, -7px -7px 5px black, 7px -7px 5px black, 0 7px 5px black, 7px 0 5px black, 0 -7px 5px black, -7px 0 5px black, 0 0 5px black">xX_N3wt4b_Xx</marquee>
@z-------------
z------------- / baseConvert.js
Created September 14, 2014 13:34
Convert integers between any two bases
function base(n, from, to) {
if (typeof n === "number") {
n = n.toString();
}
var baseTen = parseInt(n, from);
return baseTen.toString(to);
}
/*
base("f", 16, 10)