Skip to content

Instantly share code, notes, and snippets.

k1000

  • Spain Tenerife
Block or report user

Report or block k1000

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View replaceTags.js
// remove hard spaces
let bodyHTML = document.body.innerHTML;
bodyHTML = bodyHTML.replace(/ /gim, ' ');
bodyHTML = bodyHTML.replace(/\u00a0/gim, ' '); //  
bodyHTML = bodyHTML.replace(' ', ' ');
bodyHTML = bodyHTML.replace(/<[^/>]+>[ \n\r\t]*<\/[^>]+>/gim, ''); // remove empry tags
bodyHTML = bodyHTML.replace(/,([^ ])/gim, ', $1'); // fixes commas not followed by space
//bodyHTML = bodyHTML.replace(/”([^ ])/gim, '” $1'); // fixes not followed by space
//bodyHTML = bodyHTML.replace(/\.([^ <\d])/gim, '\. $1'); // fixes dot stops not followed by space
//bodyHTML = bodyHTML.replace(/\:([^ ])/gim, '\: $1');
View ffmpeg-tookit
#FFmpeg
downsample many mp3 many files
for i in *.mp3; do ffmpeg -i "$i" -ac 1 -ab 64000 -ar 22050 "${i%.mp3}-64kbps.mp3"; done
#concat many files
ffmpeg -safe 0 -f concat -i <(find . -type f -name '*' -printf "file '$PWD/%p'\n" | sort) -c copy output.mkv
@k1000
k1000 / honeypot.py
Created Jan 11, 2018
Django HoneypotFormMixin
View honeypot.py
from django import forms
class HoneypotFormMixin(object):
"""Keep away spam bots trying to submit name"""
def __init__(self, *args, **kwargs):
super(HoneypotFormMixin, self).__init__(*args, **kwargs)
self.fields.update(
{"name": forms.CharField(required=False)}
View get_snapshot.sh
#!/bin/bash
filename=$(basename "$1")
segment_times=$2
extension="${filename##*.}"
filename="${filename%.*}"
output=$2_$filename.jpg
ffmpeg -ss $2 -i "$1" -vframes 1 -q:v 2 "$output"
@k1000
k1000 / split_video.sh
Last active Jul 25, 2016
Split an input video into multiple output video chunks
View split_video.sh
#!/bin/bash
START=$(date +%s);
filename=$(basename "$1")
segment_times=$2
extension="${filename##*.}"
filename="${filename%.*}"
output=$filename_%d.$extension
ffmpeg -i "$1" -f segment -segment_times "$segment_times" -vcodec copy -acodec copy "$output"
END=$(date +%s);
View fix_permissions.py
# -*- coding: utf-8 -*-
"""Add permissions for proxy model.
This is needed because of the bug https://code.djangoproject.com/ticket/11154
in Django (as of 1.6, it's not fixed).
When a permission is created for a proxy model, it actually creates if for it's
base model app_label (eg: for "article" instead of "about", for the About proxy
model).
What we need, however, is that the permission be created for the proxy model
itself, in order to have the proper entries displayed in the admin.
@k1000
k1000 / darky.kateschema
Created Mar 4, 2016
My datk kate schme
View darky.kateschema
[Default Item Styles - Schema darky]
Alert=ffda4453,ffda4453,1,,,,fffae9eb,-,,---
Annotation=ff7f8c8d,ffbdc3c7,,,,,-,-,,---
Attribute=ff2980b9,fffdbc4b,,,,,-,-,,---
Base-N Integer=fff67400,fff67400,,,,,-,-,,---
Built-in=ff7f8c8d,ffbdc3c7,,,,,-,-,,---
Character=ff3daee9,fffcfcfc,,,,,-,-,,---
Comment=ff7f8c8d,ffeff0f1,,,,,-,-,,---
Comment Variable=ff7f8c8d,ffbdc3c7,,,,,-,-,,---
Constant=ff31363b,ffeff0f1,1,,,,-,-,,---
View volumio_pulse_audio.sh
#https://rootprompt.apatsch.net/2013/02/20/raspberry-pi-network-audio-player-pulseaudio-dlna-and-bluetooth-a2dp-part-1-pulseaudio/
#https://github.com/volumio/Volumio2/issues/159
#https://github.com/masmu/pulseaudio-dlna
# Set pulse daemon config
cat <<EOF > /etc/default/pulseaudio
PULSEAUDIO_SYSTEM_START=1
DISALLOW_MODULE_LOADING=0
EOF
@k1000
k1000 / lighttpd_rev_proxy.conf
Created Mar 14, 2015
Lighttpd configuration for reverse proxy and static media
View lighttpd_rev_proxy.conf
$HTTP["host"] =~ "www.domain.org" {
server.name = "www.domain.org"
server.document-root = "/path/to/media/"
$HTTP["url"] !~ "^/(static|media)" {
proxy.server = ( "" =>
(( "host" => "127.0.0.1", "port" => 8008 ))
)
}
}
@k1000
k1000 / upstart.conf
Last active Aug 29, 2015
Server instrumentation with Upstart, Gunicorn, Django
View upstart.conf
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
script
NAME=app_name
PORT=8002
NUM_WORKERS=3
TIMEOUT=120
You can’t perform that action at this time.