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/python | |
## Percentage area overlap between circles in Python. | |
## Inspired by PHP code by JP Hastings-Spital: | |
## https://gist.github.com/jphastings/316058 | |
import math | |
def circle_overlap(centers_distance, radius1, radius2): | |
# Make sure the larger circle is left-most (for convenience) |
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
#ifndef _RING_BUFFER_ | |
#define _RING_BUFFER_ | |
// Source: https://embeddedartistry.com/blog/2017/4/6/circular-buffers-in-cc | |
#include <memory> | |
#include <mutex> | |
template <class T> | |
class RingBuffer { |
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 python3 | |
import os, sys, hashlib | |
MD5 = True | |
def md5sum(fn): | |
hasher = hashlib.md5() | |
with open(fn, 'rb') as f: | |
hasher.update(f.read()) |
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
/* | |
* Play duo melody with Arduino | |
* ============================ | |
* | |
* Description: | |
* This sketch simultaneously plays two separate melodies on two (passive) | |
* speakers or buzzers. This creates effect of a "choir". | |
* For simplicity, it uses function play2Tones(), which only plays two notes | |
* of equal duration simultaneosly. | |
* The actual melody here is the Anthem of Ukraine. |
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
# .config file for compiling toybox on MacOS | |
# 1) make defconfig | |
# 2) replace the .config file | |
# 3) make | |
# Also: don't forget to install gsed (GNU sed) | |
# Adding CPUS=1 in scripts/make.sh might also be needed | |
# | |
# ----------------------------------------------- | |
# | |
# Automatically generated make config: don't edit |
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 | |
# Copyright 2019 Google Inc. | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# http://www.apache.org/licenses/LICENSE-2.0 |
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
Weights←{ | |
⍝ 2020 APL Problem Solving Competition Phase II | |
⍝ Problem 9, Task 1 - Weights | |
⍝ 1) Read the diagram of a mobile from the file as a vector of lines (M). | |
⍝ 2) Find lines which exactly repeat the preceding lines and contain only | |
⍝ vertical bars (│) and spaces. Such lines don't bring any useful | |
⍝ information. (This filtering step allows to process files which are | |
⍝ very deep without running out of memory. For example, 10K characters | |
⍝ wide, 100K lines deep. Without filtering, such a file would be |
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
<html> | |
<body> | |
<h2>32-bit DJB2 hash in JavaScript demo</h2> | |
<input type="file" id="file-input" /> | |
<h3 id="result">Select file to calculate DJB2 hash</h3> | |
</body> | |
<script> | |
// DJB2 hash function. Takes ArrayBuffer | |
function hash_buf_djb2_32(buf) { |
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
/* Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org> | |
* (c) 2021 Andrii Makukha | |
* | |
* Permission to use, copy, modify, and distribute this software for any | |
* purpose with or without fee is hereby granted, provided that the above | |
* copyright notice and this permission notice appear in all copies. | |
* | |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
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
/* | |
* Solution of the Jon Bentley's k most frequent words problem using a prefix tree and | |
* a heap of size k. Worst case time complexity is O(N log k), where N is the total | |
* number of words. | |
* | |
* The problem is formulated in the Communications of the ACM 29,5 (May 1986), 364-369: | |
* "Given a text file and an integer k, you are to print the k | |
* most common words in the file (and the number of their | |
* occurrences) in decreasing frequency." | |
* |
OlderNewer