Skip to content

Instantly share code, notes, and snippets.

View Snawoot's full-sized avatar

Vladislav Yarmak Snawoot

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
@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
@chkuendig
chkuendig / LD_PRELOAD_nvidia-patch.c
Last active March 15, 2023 09:15
Quick Hack to test out 32bit nvfbc without having to patch the driver or rebuild the affected app
#define _GNU_SOURCE
// compile:
// gcc -m64 -shared -I../Capture_Linux_v7.1.9/NvFBC/inc -fPIC dl_prog3.c -o nvfbc_preload.64.so -ldl
// gcc -m64 -shared -I../Capture_Linux_v7.1.9/NvFBC/inc -fPIC dl_prog3.c -o nvfbc_preload.32.so -ldl
// Run:
// LD_PRELOAD="$PWD/nvfbc_preload.32.so $PWD/nvfbc_preload.64.so" DISPLAY=:0 ../Capture_Linux_v7.1.9/NvFBC/samples/NvFBCToGLEnc/NvFBCToGLEnc -f 10
#include "NvFBC.h"
@takurx
takurx / log_about_date_command_format.md
Created May 24, 2020 05:42
about date command format

1 and 2 is equivalent.

  • 1
sharo@kirima:~$ date "+%Y-%m-%dT%H:%M:%S%:z"
2020-05-24T14:38:26+09:00
  • 2
sharo@kirima:~$ date --iso-8601='seconds'