Skip to content

Instantly share code, notes, and snippets.

@mathwo
mathwo / duck-semicircle-simulation.js
Last active April 23, 2025 18:45
Monte Carlo simulation of the probability of number of ducks in the same semi-circle in Javascript
function getProbability(numDucks = 4, numSimulations = 100000) {
let successCount = 0;
for (let i = 0; i < numSimulations; i++) {
// For each duck, generate a random angle in (0, 2 * Math.PI) then sort the array
const angles = Array.from({length: numDucks}, () => Math.random() * 2 * Math.PI)
.sort((a, b) => a - b);
// Take each angle as the start of a semicircle,
// check if all other angles fall within the semicircle of start.
// If there exists such a start angle for all other angles,
@mathwo
mathwo / gist:4958a7e50be85743615c18d9e34109e9
Created July 10, 2024 18:39
How to add MathJax support to Zola Static Site Generator
Step 1: follow the instructions on this [starting guide](https://www.getzola.org/documentation/getting-started/overview/)
Step 2: add following piece of code in templates/blog-page.html (before the last line):
```
{% if page.extra.math %}
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
@mathwo
mathwo / gist:43424d88dbe5b4acdd676f94c02ca7aa
Last active February 26, 2024 20:04
App list for new Mac
Install homebrew - this will install command line tools for Xcode, then install yt-dlp and ffmpeg via brew
Install chrome browser
Install Arc browser
Install Office 365
Install Warp terminal
Install Raycast launcher: https://www.raycast.com/
Install OhMyZsh - copy paste and run the installation command in warp
Install BetterDisplay - need pay $15
Install vscode - download zip and drag to app folder - sync settings, then config:
1. Open Visual Studio Code
@mathwo
mathwo / yt-dlp_ffmpeg.md
Last active July 21, 2025 01:11
yt-dlp & ffmpeg common usages
@mathwo
mathwo / work-with-multiple-github-accounts.md
Created October 31, 2023 20:50 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
import urllib.request
from datetime import date, timedelta
start_date = date(2020, 1, 1)
end_date = date(2023, 6, 23)
delta = end_date - start_date
f = open("results.csv","w+")
@mathwo
mathwo / cloudSettings
Last active September 13, 2021 19:41 — forked from kingvagabond/cloudSettings
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-09-13T19:41:03.139Z","extensionVersion":"v3.4.3"}
@mathwo
mathwo / javascript_resources.md
Created May 5, 2014 19:51 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@mathwo
mathwo / 0_reuse_code.js
Created May 5, 2014 19:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console