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
import { useForm, Controller } from "react-hook-form"; | |
const re = /^[-+]?\d*(\.\d*)?$/; | |
function NumCtrl({ name, onChange, value }: any) { | |
return <input | |
name={name} | |
value={value} | |
onChange={(e) => { | |
if (re.test(e.target.value)) onChange(e); |
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
(defn <sqrt [n] | |
(range 3 (+ (int (Math/sqrt n)) 1))) | |
(defn prime-inner | |
[n] | |
(nil? (some #(= (mod n %) 0) (<sqrt n)))) | |
(defn is-prime? [n] | |
(cond | |
(< n 2) false |
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 PIL import Image, ImageDraw, ImageFont | |
with Image.open("img.jpeg").convert("RGBA") as base: | |
font_size = 100 | |
txt = Image.new("RGBA", base.size, (255, 255, 255, 0)) | |
fnt = ImageFont.truetype("/home/mar/.fonts/FiraMono-Regular.ttf", font_size) | |
d = ImageDraw.Draw(txt) | |
d.text( | |
(10, base.size[1] - font_size - 10), |
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 Foo { | |
data: Vec<f64>, | |
} | |
trait FileData { | |
fn new(raw_data: &[u8]) -> Self; | |
fn get_data(&self) -> &Vec<f64> { | |
&self.data | |
} | |
fn default_method(&self) -> f64 { |
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 <cassert> | |
#include <cstdio> | |
#include <vector> | |
#include <gdal/gdal_priv.h> | |
__global__ void | |
vector_add(const int16_t* in, int16_t* out, int num_elements) | |
{ | |
int i = blockDim.x * blockIdx.x + threadIdx.x; |
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 <iostream> | |
#include <functional> | |
enum Dir { H, V }; | |
template<Dir d> | |
void call(double x, double y) { | |
std::function<double(double, double)> f; | |
if constexpr (d == H) { | |
f = [](double x, double y) -> double { |
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 <iostream> | |
#include <memory> | |
#include <cstdlib> | |
#include <vector> | |
void incr(float *arr) { | |
arr[5] += 1; | |
arr[7] += 1; | |
} |
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
[alias] | |
st = status | |
co = checkout | |
l = log | |
d = diff | |
db = !git diff -w origin/master... | |
ci = commit | |
br = !git --no-pager branch --sort=committerdate | |
ca = !git commit --amend --no-edit --date=now | |
uw = !git reset @~ |
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
template all[T](arg: ptr T): T = arg[] | |
var x = 10 | |
echo x.addr.all |
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
use NativeCall; | |
sub routine(int64) returns Str is native('mydll') { * } | |
my $start = now; | |
my $foo = routine(100_000); | |
say $foo; | |
say now - $start, " seconds"; |
NewerOlder