Skip to content

Instantly share code, notes, and snippets.

@denji
denji / unbound-osx-homebrew.md
Last active November 27, 2022 08:33
Install unbound DNS(SEC) resolver on OS X, on the basis of https://www.spatof.org/blog/unbound-dns-resolver-on-osx.html
To install unbound you can use homebrew
$ brew install unbound ldns
Now we can edit the configuration file of unbound which by default is located in /usr/local/etc/unbound/unbound.conf:
@justinatcamfil
justinatcamfil / play_stream
Last active May 5, 2023 08:17
stream linux audio from sound card through netcat
#!/bin/bash
# run on mac in terminal
while TRUE; do
nc <server_address> 15000 | play -q -t mp3 - || echo Attempting to connect...
sleep 1;
done
@boylea
boylea / livespec.py
Last active August 22, 2024 02:22
pyqtgraph live running spectrogram from microphone
"""
Tested on Linux with python 3.7
Must have portaudio installed (e.g. dnf install portaudio-devel)
pip install pyqtgraph pyaudio PyQt5
"""
import numpy as np
import pyqtgraph as pg
import pyaudio
from PyQt5 import QtCore, QtGui
@fredrikaverpil
fredrikaverpil / treewidget_example.py
Last active July 27, 2021 07:24
Tree widget example #python #pyside
from PySide import QtCore, QtGui
import sys
app = QtGui.QApplication(sys.argv)
QtGui.qApp = app
folderTree = QtGui.QTreeWidget()
header = QtGui.QTreeWidgetItem(["Virtual folder tree","Comment"])
#...
@AdolfVonKleist
AdolfVonKleist / compute-best-mix.py
Last active May 29, 2020 08:50
compute-best-mix.py : Python port of the venerated SRILM tool
#!/usr/bin/python
import re, math
def LoadPPLFile (pplfile) :
"""
Load up the salient info from a -debug 2 PPL file
generated by the SRILM ngram tool.
"""
ppl_info = []
@ReactiveRaven
ReactiveRaven / gist:9348401
Last active December 16, 2022 18:30
Ubuntu memory tuning

Add these lines to the end of /etc/sysctl.conf:

vm.swappiness=5
vm.min_free_kbytes=122880
vm.vfs_cache_pressure=500

Run these commands as root:

sudo sysctl -w vm.swappiness=5;

sudo sysctl -w vm.min_free_kbytes=122880

@joyrexus
joyrexus / README.md
Last active December 13, 2024 00:46
Perl one-liners

Hi:

perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

@Danik
Danik / capslock_remap_alt.ahk
Last active April 11, 2025 11:13
Autohotkey Capslock Remapping Script. Makes Capslock function as a modifier key to get cursor keys etc. on the left side of the keyboard, so you never have to move your hand to the right.
; Autohotkey Capslock Remapping Script
; Danik
; More info at http://danikgames.com/blog/?p=714
; danikgames.com
;
; Functionality:
; - Deactivates capslock for normal (accidental) use.
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
; - Access the following functions when pressing Capslock:
; Cursor keys - J, K, L, I
import requests, random, datetime, sys, webbrowser, console
def main():
song_page = None
if (len(sys.argv) > 0):
try:
song_page = sys.argv[1]
except Exception:
song_page = None
if not song_page:
@ozanturksever
ozanturksever / get_uncompressed_size.py
Last active August 25, 2020 14:10
python get uncompressed size of a .gz file
def get_uncompressed_size(self, file):
fileobj = open(file, 'r')
fileobj.seek(-8, 2)
crc32 = gzip.read32(fileobj)
isize = gzip.read32(fileobj) # may exceed 2GB
fileobj.close()
return isize