Skip to content

Instantly share code, notes, and snippets.

View ternus's full-sized avatar

Christian Ternus ternus

View GitHub Profile
@ternus
ternus / fitString.js
Created November 4, 2010 16:28
Fits a string to a given pixel size
function fitString(str, size, strclass) {
// Fits a string to a given pixel size
// Based on a solution from stackoverflow.com
var nstr = str;
var tmp = document.createElement("span");
tmp.className = strclass;
tmp.style.visibility = "hidden";
tmp.style.padding = "0px";
document.body.appendChild(tmp);
tmp.innerHTML = nstr;
cternus@astarael ~/foo> cat errorregex.py 2
import re
class ErrorRegex():
def __init__(self):
self.regex = re.compile(r"[^\\]\{}".format("|"))
def split(self,line):
line = line.replace("\n","")
print line
splitted = self.regex.split(line)

Keybase proof

I hereby claim:

  • I am ternus on github.
  • I am ternus (https://keybase.io/ternus) on keybase.
  • I have a public key whose fingerprint is A163 C976 EAD7 2A6F CEB4 EC7D 5A6B 0839 B7BC F4EA

To claim this, I am signing this object:

@ternus
ternus / ffwaitlist_zephyr.sh
Created April 25, 2015 23:23
Checks where you are on the Firefly waitlist and keeps you logged in so you don't miss out.
#!/bin/bash
ATHENA="ternus"
USERNAME="ternus@cternus.net"
PASSWORD=""
cwaitlistnum=''
while true; do
waitlistnum=$(curl -s -X POST https://tickets.fireflyartscollective.org/cgi-bin/ticketing.pl -F "email=$USERNAME" -F "password=$PASSWORD" -F "action=Log In" | pcregrep -o1 "(\d+) confirmed")
if [[ $waitlistnum == '' ]]; then
#!/usr/bin/env python
import os
import sys
import shutil
import datetime
import pyperclip
clipboard_copy = pyperclip.clipboards.init_osx_clipboard()[0]
from math import sqrt, ceil
def find_primes(n):
primes = list(range(2, n+2))
for c in range(ceil(sqrt(n))):
pp = primes[c]
if pp == -1:
c += 1
continue
for i in range(c+1, len(primes)):
# ==============================================================================
# Packages / M3000
# @file packages/m3000.yaml
# Adapted from https://gist.github.com/dale3h/b1c4e571947438728164dbe2ead728ec
# IMPORTANT: Enable packages in `configuration.yaml`
# @see https://www.home-assistant.io/docs/configuration/packages/
#
# @notes Set `input_text.m3000_host` to the IP address of your Verizon
# Jetpack hotspot.
# @notes Set `input_number.m3000_data_cap` to the amount of data that