Skip to content

Instantly share code, notes, and snippets.

View 0017031's full-sized avatar
🎯
Focusing

fcccp 0017031

🎯
Focusing
View GitHub Profile
@endolith
endolith / peakdet.m
Last active February 14, 2024 21:27
Peak detection in Python [Eli Billauer]
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@endolith
endolith / frequency_estimator.py
Last active July 15, 2024 21:25
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
@sixtenbe
sixtenbe / analytic_wfm.py
Last active May 27, 2024 01:24 — forked from endolith/peakdet.m
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@NicolasT
NicolasT / monad.py
Created March 31, 2012 19:17
Generalized monad comprehensions in Python
import ast
app = lambda name, *args: \
ast.Call(
func=ast.Name(id=name, ctx=ast.Load(), lineno=0, col_offset=0),
args=list(args), keywords=[], vararg=None,
lineno=0, col_offset=0)
abs = lambda arg, body: \
@mkropat
mkropat / knownpaths.py
Last active July 1, 2024 19:21
Python wrapper around the SHGetKnownFolderPath Windows Shell function
import ctypes, sys
from ctypes import windll, wintypes
from uuid import UUID
class GUID(ctypes.Structure): # [1]
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)
@gusty
gusty / trampoline.fsx
Last active February 27, 2024 08:04
Trampolines in F#
let trampoline f c n =
let rec loop = function
| Choice1Of2 x -> x
| Choice2Of2 x -> loop (f x)
loop (Choice2Of2 (c,n))
// Test
let factorial n =
let rec factorialT (current, n) =
if n = bigint 0 then Choice1Of2 current
@tnarik
tnarik / gist:9bc4645f81db8cd22460
Created May 29, 2014 13:00
Using FreeFileSync and RealTimeSync
You can do the following:
1) download and install
2) create the destination folder (I used the following in a mountable disk):
usb_backups (a folder for the backups)
├── huolongjing (a folder for the USB stick)
├── huolongjing_SyncSettings.ffs_batch
├── huolongjing_SyncSettings.ffs_gui
├── huolongjing_SyncSettings.ffs_real
└── huolongjing_version (a folder for versioning, just as a safeguard)
@bitshifter
bitshifter / PurgeStandbyList.cpp
Last active June 19, 2024 19:42
Command line utility for purging Window's standby list. Requires /MANIFESTUAC:"level='highestAvailable'.
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
#define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS)0xC0000061L)
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemMemoryListInformation = 80, // 80, q: SYSTEM_MEMORY_LIST_INFORMATION; s: SYSTEM_MEMORY_LIST_COMMAND (requires SeProfileSingleProcessPrivilege)
} SYSTEM_INFORMATION_CLASS;
@borisdiakur
borisdiakur / case-sensitive-seach.js
Last active April 27, 2023 03:47
Bookmarklet for case-sensitive search in Google Chrome (and other browsers which do not ship this feature). You can find install instruction below the code.
(function () {
'use strict';
var body = document.body,
html = document.documentElement;
var docHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
var findingColor = 'limegreen';