Skip to content

Instantly share code, notes, and snippets.

View Snawoot's full-sized avatar

Snawoot

  • Odessa, Ukraine
View GitHub Profile
hdparm --user-master u --security-set-pass PasSWorD /dev/sdX
hdparm --user-master u --security-erase PasSWorD /dev/sdX
@laserson
laserson / gist:2689744
Created May 13, 2012 18:56
Generate Redis protocol with python
def gen_redis_proto(*args):
proto = ''
proto += '*' + str(len(args)) + '\r\n'
for arg in args:
proto += '$' + str(len(arg)) + '\r\n'
proto += str(arg) + '\r\n'
return proto
@svdamani
svdamani / pow.py
Last active April 17, 2020 10:44
Fast Power calculation in Python
def power(base, exp):
""" Fast power calculation using repeated squaring """
if exp < 0:
return 1 / power(base, -exp)
ans = 1
while exp:
if exp & 1:
ans *= base
exp >>= 1
base *= base
@eighthave
eighthave / find-https-debian-archives.py
Last active December 25, 2020 19:04
Script to find official Debian mirrors that support HTTPS
#!/usr/bin/env python3
import urllib.request
import re
import ssl
import sys
# # find generic mirrors
mirrors = urllib.request.urlopen('http://www.debian.org/mirror/list')
https = []
0.0.0.0 api.surfeasy.com
0.0.0.0 opera-proxy.net
0.0.0.0 api.sec-tunnel.com
0.0.0.0 sitecheck2.opera.com
0.0.0.0 opera-mini.net
0.0.0.0 exchange.opera.com
0.0.0.0 features.opera-api.com
@sweenzor
sweenzor / logtest.py
Created February 9, 2012 19:59
Writing to syslog with Python's logging library
import logging
import logging.handlers
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
handler = logging.handlers.SysLogHandler(address = '/dev/log')
formatter = logging.Formatter('%(module)s.%(funcName)s: %(message)s')
@un1t
un1t / parse-xml.go
Last active January 3, 2022 09:36
Golang XML stream parser
package main
// https://github.com/dps/go-xml-parse/blob/master/go-xml-parse.go
import (
"fmt"
"os"
"encoding/xml"
)
server {
listen 80;
server_name backend;
root /usr/share/nginx/www;
index index.html index.html;
location / {
header_filter_by_lua '
@jart
jart / illumination.sh
Last active June 20, 2022 18:58
Rational Illumination for PC and TV w/ IBM Scratchpad
#!/bin/sh
fricas -nosman <<EOF
E := [_
-- Standard Illumination Model for Computers_
--_
-- Is defined as a system of linear equations, where negative_
-- colors don't exist and is solved by computing the point at_
-- which they all intersect the one which needs to be defined_
-- as the Planckian locus of the illuminant._
@bamnet
bamnet / .gitlab-ci.yml
Last active January 11, 2023 06:16
Multiarch Go Builds
image: docker:latest
services:
- docker:dind
stages:
- build
variables:
IMAGE: registry.gitlab.com/bamnet/njtdata
DOCKER_CLI_EXPERIMENTAL: enabled