Skip to content

Instantly share code, notes, and snippets.

View mk-fg's full-sized avatar

Mike Kazantsev mk-fg

View GitHub Profile
@mk-fg
mk-fg / skype-notify.py
Created March 2, 2012 14:05 — forked from vanuch/skype-notify.py
Python script to make Skype co-operate with GNOME3 notifications
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python script to make Skype co-operate with GNOME3 notifications.
#
# Copyright (c) 2012, Mike Kazantsev
# Copyright (c) 2011, John Stowers
# Copyright (c) 2009, Lightbreeze
#
# This program is free software: you can redistribute it and/or modify
@mk-fg
mk-fg / gist:3319062
Created August 10, 2012 23:52
ssl_optional_no_ca.patch
commit 29456da2042759c7e8a0c18671b798eab0d2b860
Author: Mike Kazantsev <[email protected]>
Date: Sat Sep 22 16:30:02 2012 +0600
Add "optional_no_ca" option to ssl_verify_client to enable app-only CA chain validation
diff --git a/src/event/ngx_event_openssl.h b/src/event/ngx_event_openssl.h
index cd6d885..97da051 100644
--- a/src/event/ngx_event_openssl.h
+++ b/src/event/ngx_event_openssl.h
@mk-fg
mk-fg / Usage (linux zsh console)
Last active January 1, 2016 15:29
Script to adjust costs in KSP tree.cfg file
% ./tree_change_costs.py -h
usage: tree_change_costs.py [-h] [-r path] [-f float] [-m int] [-d]
file_src [file_dst]
Change tech tree node cost values.
positional arguments:
file_src File to edit. In-place, if no file_dst specified.
file_dst File to output results to (optional). "-" for output
to stdout.
#!/usr/bin/env python3
import itertools as it, operator as op, functools as ft
import os, sys, errno, argparse, logging, secrets, re, json, shutil
import contextlib, inspect, tempfile, pathlib, collections, enum
import asyncio, asyncio.subprocess, socket, signal, heapq, struct
import aiohttp
% cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
0: 8163 34453 302107 16401340 IO-APIC 2-edge timer
1: 0 0 0 2 IO-APIC 1-edge i8042
8: 0 0 0 1 IO-APIC 8-edge rtc0
9: 0 0 0 2 IO-APIC 9-fasteoi acpi
12: 0 0 0 4 IO-APIC 12-edge i8042
16: 12 132 16341 1209542 IO-APIC 16-fasteoi snd_hda_intel:card0
17: 7 37 3501 251541 IO-APIC 17-fasteoi ehci_hcd:usb1, ehci_hcd:usb2, ehci_hcd:usb3
18: 0 0 0 4 IO-APIC 18-fasteoi ohci_hcd:usb4, ohci_hcd:usb5, ohci_hcd:usb6, ohci_hcd:usb7
UIWorkshiftUpdate = function(self, building, shift)
-- function num : 0_56 , upvalues : shift_names, _ENV, WorkerSlot, OpenSlot, ClosedSlot
self:SetRolloverTitle(shift_names[shift])
local training = not building:IsKindOf("TrainingBuilding") or building.max_visitors > 0
local workplace = not building:IsKindOf("Workplace") or building.max_workers > 0
local shift_active = building:IsShiftUIActive(shift)
local shift_closed = building:IsClosedShift(shift)
if workplace then
local shift_overtime = (building.overtime)[shift]
end
import time, contextlib, struct, json
import uwsgi
def token_bucket(interval, burst=1):
token_fmt = '>dL'
token_len = struct.calcsize(token_fmt)
token_get = lambda: struct.unpack(token_fmt, uwsgi.sharedarea_read(0, token_len))
token_set = lambda *v: uwsgi.sharedarea_write(0, struct.pack(token_fmt, *v))
token_set(time.monotonic(), burst)
@mk-fg
mk-fg / dec.py
Last active March 24, 2018 03:18
import lz4.block
import struct, pathlib, sys
file_src = sys.argv[1]
file_dst = sys.argv[1] + '.dec'
data = pathlib.Path(file_src).read_bytes()
size, = struct.unpack('=I', data[4:8])
payload = data[16:]
payload_dec = lz4.block.decompress(payload, size)
function run_my_mod()
...
end
function OnMsg.LoadGame()
xpcall(run_my_mod, function(err)
WaitCustomPopupNotification(
'ERROR when running mod',
string.format('----- Details:\n%s\n%s\n----- :end\n', err, debug.traceback()),
{'Oops!'})
result = sin(degrees*60) / 4096
the argument should be multiplied by 60
the result should be divided by 4096
this is because both the argument and results are integers
so
sin(90 * 60) will be 4096
cos(0 * 60) will be again 4096
and sin(45 * 60) / 4096.0 will be around 0.70710678