This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct strnsplit { | |
const char* ptr; | |
size_t len; | |
}; | |
const char* strnsplit( | |
const char* restrict str, | |
int c, | |
size_t len, | |
size_t *part_len, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <threads.h> | |
/** | |
* @brief A single unit of data in a opusbuffer, that is capable of | |
* containing a contigous sequence of bytes being arbitrarily large. | |
*/ | |
struct opuspacket { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
#include <opus/opus.h> | |
#include <assert.h> | |
//#define M_E 2.3504023872876028 | |
#define M_E_1 0.36787944117144233 | |
#define M_E_NEG_M_E_1 2.3504023872876028 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.fftpack import dctn,idctn | |
from numpy import any, clip, floor, array, asarray, zeros, round, resize | |
from functools import partial | |
# Orthonormal DCT is required for JPEG quantisation else | |
# the default one is quite crap and useless (cannot | |
# reproduce values after transformation). | |
dctn = partial(dctn, type=2, norm='ortho') | |
idctn = partial(idctn, type=2, norm='ortho') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# https://gist.github.com/tripulse/e319d24bbc7b8b48f73336f7bc230e0c | |
""" | |
yt-thumb: a script to download thumbnails of YouTube videos of quantized set | |
of qualities (lowest, low, mid, high, highest). This tool nor the method it | |
uses imposes any restrictions on downloading thumbnails. | |
Qualities and their co-respoding width, height dimensions: | |
* lowest 120x90 | |
* low 320x180 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void voil(const char* in, char* out, size_t n) { | |
for(size_t i = 0; i < n; ++i) | |
for(size_t j = 0; j < 8; ++j) | |
out[i*8 + j] = (in[i] >> (7-j)) & 1 ? '-' : '\''; | |
} | |
int unviol(const char* in, char* out, size_t n) { | |
for(size_t i = 0; i < n/8; ++i) { | |
char acc = 0; | |
for(size_t j = 0; j < 8; ++j) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cinttypes> | |
#include <tuple> | |
template<class> | |
struct function_traits {}; | |
template<class R, class... Args> | |
struct function_traits<R(Args...)> { | |
typedef R ret_t; | |
typedef std::tuple<Args...> args_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice, choices | |
def upvote(upvote = '^', | |
numbers = '93475100809635819407912381031', | |
others = '~!@#$%^&*()`{}|":?><][;/.,', | |
weights = [0.2, 0.75, 0.05]): | |
"""Generate Guru Rajshekhar style upvotes. | |
:param upvote: a character representing upvote | |
:param numbers: random numbers (possibly phone numbers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* (c) Copyright 2020 Tripulse. | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* range(...args) { | |
var start = 0; | |
var stop = 0; | |
var step = 1; | |
if(args.length == 1) | |
stop = args[0]; | |
else if(args.length == 2) { | |
start = args[0]; | |
stop = args[1]; |
NewerOlder