Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Kirkegaard kirkegaard

View GitHub Profile
View getWeekNumber.js
const getWeekNumber = (date) => {
const pd = new Date(date);
const sj = new Date(pd.getFullYear(), 0, 1);
const wk = Math.ceil((((pd - sj) / 86400000) + sj.getDay() + 1) / 7);
return wk;
}
console.log(
getWeekNumber('2020-01-01'),
getWeekNumber('2020-01-14'),
View table_fadeout.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hader georgehale</title>
<style>
tr:nth-last-child(9) { opacity: 0.9; }
tr:nth-last-child(8) { opacity: 0.8; }
tr:nth-last-child(7) { opacity: 0.7; }
tr:nth-last-child(6) { opacity: 0.6; }
View peakdetect.py
import math
import struct
import wave
import sys
w = wave.open(sys.argv[1], 'rb')
sum = 0
value = 0;
delta = 0;
amps = []
View bonanza.py
import argparse
import os
import re
import string
import subprocess
import sys
from shutil import which, copyfileobj
from urllib import request
from html.parser import HTMLParser
@kirkegaard
kirkegaard / tamagotchi.py
Last active Feb 12, 2020
a tamagotchi simulator in python
View tamagotchi.py
import os
import time
import sched
import threading
import inquirer
class Tamagotchi:
age = 0
bored = 0
View np.sh
#!/bin/bash
json=$(curl -s "http://ws.audioscrobbler.com/2.0/?method=user.getRecentTracks&api_key=$LASTFM_APIKEY&user=$LASTFM_USERNAME&format=json")
artist=$(echo $json | jq -r '.recenttracks.track[0].artist["#text"]')
song=$(echo $json | jq -r '.recenttracks.track[0].name')
echo "$artist - $song"
@kirkegaard
kirkegaard / news.ycombinator.com.css
Last active May 31, 2020
hackernews dark mode
View news.ycombinator.com.css
::selection {
background-color: #111;
color: #eee;
}
body {
background-color: #222;
}
#hnmain {
@kirkegaard
kirkegaard / plex-streams.sh
Last active Jul 30, 2019
Displays the current streams on plex
View plex-streams.sh
#!/bin/sh
PLEX_TOKEN=$(curl -H "Content-Length: 0" -H "X-Plex-Client-Identifier: my-app" -u $PLEX_USERNAME:$PLEX_PASSWORD -X POST https://my.plexapp.com/users/sign_in.xml --silent | xmllint --xpath "/user/authentication-token/text()" -)
XML=$(curl --silent http://$PLEX_HOST:32400/status/sessions -H "X-Plex-Token: $PLEX_TOKEN")
STREAMS=$(echo $XML | xmllint --xpath 'string(//MediaContainer/@size)' -)
echo "Current streams: ${STREAMS}"
for (( i=1; i <= $STREAMS; i++ )); do
USER=$(echo $XML | xmllint --xpath 'string(//Video['$i']/User/@title)' -)
View m2embed.php
<?php
$title = (isset($_GET['t'])) ? $_GET['t'] : false;
$content = (isset($_GET['s'])) ? $_GET['s'] : false;
$providers = [
'drop' => [
'regex' => '/https?:\/\/files\.m2film\.dk\/(.*)/',
'embed' => '<video controls src="https://files.m2film.dk/{code}&video=true"></video>',
],
View reddit_subscription.py
import requests
import praw
import time
import sqlite3
from urllib.request import pathname2url
class Subscriptions():
subscriptions = []
You can’t perform that action at this time.