Skip to content

Instantly share code, notes, and snippets.

View mordka's full-sized avatar
🌏
The future is now.

mordka mordka

🌏
The future is now.
View GitHub Profile
@mordka
mordka / service-worker-ghost-cms.js
Last active July 1, 2022 11:42 — forked from deanhume/service-worker-ghost-cms.js
Service Worker for Ghost CMS - ignore Ghost admin
const cacheName = 'blogCache';
const offlineUrl = '/offline/';
const adminPageSlug = '/ghost';
/**
* The event listener for the service worker installation
*/
self.addEventListener('install', event => {
event.waitUntil(
caches.open(cacheName)
@bdkosher
bdkosher / StackoverflowTagCounter.groovy
Created October 9, 2014 18:54
Counts the number of tagged questions on Stackoverflow for a given tag.
@Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='1.2')
import java.text.*
class SOTagCounter {
def parser = new XmlSlurper(new org.ccil.cowan.tagsoup.Parser())
int count(String tag) {
new URL("http://stackoverflow.com/questions/tagged/${new URI(tag).path}").withReader { page ->
def html = parser.parse(page)
def c = html.body.div.find { it.@class == 'container' }.div.find { it.@id == 'content' }.div.find { it.@id == 'sidebar' }.div.find { it.@class == 'module' }.div[0].text()
@sinkers
sinkers / livestreammonitor.py
Created July 14, 2014 04:50
Script for live video streaming monitoring with notifications
#!/usr/bin/python
'''
Script to monitor live streams and send an Amazon SNS if the stream is down (and possibly take restorative action)
Future:
Black detect: ffmpeg -i out.mp4 -vf blackdetect -f null -
Note the following doesn't seem to fully work without looking at the debug logs
On live ffmpeg -y -i rtmp://cp30129.live.edgefcs.net/live/videoops-videoops@50541 -vf blackdetect -t 10 -loglevel debug -f null -
'''
@KonradIT
KonradIT / readme.md
Last active September 25, 2023 01:55
GoPro Studio for Linux
@tfg13
tfg13 / touchpadconf.sh
Created November 24, 2013 15:50
script to set synaptics configuration for Thinkpad T440p
#!/bin/sh
# this script sets some parameters to get a useable configuration
# these changes are not persistent, you may want to include this in your autostart
# 1 finger = left click, 2 finger = right click, 3 finger = middle click
synclient TapButton2=3
synclient TapButton3=2
synclient ClickFinger2=3
synclient ClickFinger3=2
@andsens
andsens / benchmark-ec2-boottime.sh
Created October 1, 2012 19:02
Starts a single instance and measures the time until SSH connectivity
#!/bin/bash -e
# These need to be set.
#export EC2_HOME="/path/to/ec2-api-tools"
#export AWS_ACCESS_KEY='XXXXXXXXXXXXXXXXXXXX'
#export AWS_SECRET_KEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
#export PATH="$PATH:${EC2_HOME}/bin"
ami_id='ami-123abc12'
availability_zone='eu-west-1a'
keypair="johndoe@example.com"
@johnnypez
johnnypez / 404.html
Created November 14, 2011 11:40
A nicer set of html5 error pages for Rails. Based on HTML5 Boilerplate
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Page Not Found :(</title>
<style>
body { text-align: center;}
h1 { font-size: 50px; text-align: center }
span[frown] { transform: rotate(90deg); display:inline-block; color: #bbb; }
body { font: 20px Constantia, 'Hoefler Text', "Adobe Caslon Pro", Baskerville, Georgia, Times, serif; color: #999; text-shadow: 2px 2px 2px rgba(200, 200, 200, 0.5); }
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}