This file contains hidden or 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 python3 | |
| from bs4 import BeautifulSoup | |
| from readability import Document | |
| import click | |
| from click import echo | |
| import requests | |
| import slugify | |
| import os |
This file contains hidden or 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
| import bpy | |
| import numpy as np | |
| from mathutils import noise | |
| img = bpy.data.images['some-img'] | |
| w, h = img.size | |
| # 4 channel image (RGBA), f64 | |
| a = np.array(img.pixels).reshape((h, w, 4)) |
This file contains hidden or 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
| import pandas as pd | |
| @pd.api.extensions.register_dataframe_accessor("rel") | |
| class RelationshipAccessor: | |
| ''' | |
| Add a relationship accessor to dataframe objects allowing Rails-like | |
| access to related dataframes. e.g. | |
| >>> authors = pd.DataFrame({'name': ['C. S. Lewis', 'Lewis Carroll']}) | |
| >>> books = pd.DataFrame({'title': ["Alice's Adventures in Wonderland", |
This file contains hidden or 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
| ''' | |
| Expects probes to be defined in the target process, e.g.: | |
| import stapsdt | |
| provider = stapsdt.Provider('game') | |
| frame_begin_probe = provider.add_probe('frame_begin') | |
| frame_end_probe = provider.add_probe('frame_end') | |
| provider.load() | |
| ... |
This file contains hidden or 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
| const std = @import("std"); | |
| pub const BlockIterator = struct { | |
| buffer: []const u8, | |
| block_size: usize, | |
| index: usize, | |
| pub fn next(self: *BlockIterator) ?[]const u8 { | |
| if (self.index == self.buffer.len) { | |
| return null; |
This file contains hidden or 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
| # decodes hexahue images | |
| import cv2 | |
| import numpy as np | |
| codewords = {'mrgybc': 'a', | |
| 'rmgybc': 'b', | |
| 'rgmybc': 'c', | |
| 'rgymbc': 'd', | |
| 'rgybmc': 'e', | |
| 'rgybcm': 'f', |
This file contains hidden or 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
| #!/sbin/openrc-run | |
| description="daemon required by the guix package manager" | |
| command=/root/.config/guix/current/bin/guix-daemon | |
| command_args="--build-users-group=guixbuild" | |
| command_background="yes" | |
| pidfile="/run/${RC_SVCNAME}.pid" |
This file contains hidden or 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 typing import Callable, Any | |
| from dataclasses import dataclass | |
| class _CpsA: # (x, k) -> () | |
| @staticmethod | |
| def lift(f) -> '_CpsA': | |
| return _CpsA(lambda x, k: k(f(x))) | |
| def __init__(self, cps: Callable[[Any, Callable], None]): | |
| self.cps = cps |
This file contains hidden or 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
| FILES=$(wildcard *.cpp) | |
| NJOBS=$(shell echo $$(nproc) + 1 | bc) | |
| all: | |
| g++ $(FILES) | |
| generate_empty: | |
| echo "int main() {}" > main.cpp | |
| for i in `seq 500`; do touch f$$i.cpp; done |
This file contains hidden or 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
| NB. Port of https://scipy-cookbook.readthedocs.io/items/KalmanFiltering.html | |
| require 'stats/distribs/normal' | |
| n =: 50 NB. number of steps to compute | |
| x =: _0.37227 NB. real value | |
| z =: (x , 0.1) rnorm n NB. readings (normal distribution) | |
| Q =: 1e_5 NB. process variance | |
| R =: 0.1^2 NB. estimate of variance |