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 | |
from __future__ import annotations | |
import hashlib | |
import sys | |
from pathlib import Path | |
import click |
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 | |
from __future__ import annotations | |
import argparse | |
import hashlib | |
import sys | |
from pathlib import Path |
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
# .xonshrc | |
# use t() like this or in similar contexts: | |
# | |
# >>> diff -u @(t("ls -1 foo/")) @(t("ls -1 bar/")) | |
def t(args, *, shell=None, **kwargs): | |
import builtins | |
import pathlib |
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 <cstdint> | |
#include <cstdlib> | |
#include <iomanip> | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <typeinfo> | |
#include <cxxabi.h> |
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 base64 | |
import pickle | |
import sys | |
from binascii import crc32 | |
from datetime import timezone | |
import pathvalidate |
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
private static void sweepLinear(double min, double max, int num_intervals) { | |
for (int i = 0; i <= num_intervals; i++) { | |
int j = num_intervals - i; | |
double value = (max * i + min * j) / num_intervals; | |
doSomethingWithValue(value); | |
} | |
} | |
/* Output: |
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
private static void sweepLinear(double min, double max, int num_intervals) { | |
for (int i = 0; i <= num_intervals; i++) { | |
double p = (double)i / (double)num_intervals; | |
double q = 1.0 - p; | |
double value = max * p + min * q; | |
doSomethingWithValue(value); | |
} | |
} |
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
private static void sweepLinear(double min, double max, int num_intervals) { | |
double step = (max - min) / num_intervals; | |
double value = min; | |
for (int i = 0; i <= num_intervals; i++) { | |
doSomethingWithValue(value); | |
value += step; | |
} | |
} |
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
private static void sweepLinear(double min, double max, int num_intervals) { | |
double step = (max - min) / num_intervals; | |
double value = min; | |
while (value <= max) { | |
doSomethingWithValue(value); | |
value += step; | |
} | |
} |
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
class Loop { | |
public static void main(String[] args) { | |
sweepLinear(1.5, 2.5, 2); | |
System.out.println(); | |
sweepLinear(1.5, 2.5, 10); | |
} | |
private static void doSomethingWithValue(double value) { |
NewerOlder