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
| def preprocess_config(s: str): | |
| """Remove imports from a string representation of a python file""" | |
| # We assume that imports are not multi-line. | |
| lines = s.splitlines() | |
| out_lines = [] | |
| for line in lines: | |
| # Skip lines with import in them: | |
| if 'import' in line: | |
| continue |
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
| // Count elements of an array by using a lookup table. | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdbool.h> | |
| #include <time.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| // Generate random array of integers, with | |
| // size given by args. |
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 re | |
| def reduce_precision_of_constants_in_string(s, precision=3): | |
| # Find all constants in the string: | |
| constants = re.findall(r"\b[-+]?\d*\.\d+|\b[-+]?\d+\.?\d*", s) | |
| for c in constants: | |
| reduced_c = "{:.{precision}g}".format(float(c), precision=precision) | |
| s = s.replace(c, reduced_c) | |
| return s |
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
| #main-window[titlepreface*="[Sidebery]"] #TabsToolbar { | |
| visibility: collapse !important; | |
| } | |
| #sidebar-header { | |
| display: none; | |
| } | |
| #main-window #TabsToolbar { | |
| overflow: hidden; | |
| transition: height .3s .3s !important; |
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
| <?php | |
| require_once 'vendor/autoload.php'; | |
| use Gregwar\Captcha\CaptchaBuilder; | |
| // Create a captcha with the text "MilesCranmer@mastodon.social" | |
| $builder = new CaptchaBuilder('MilesCranmer@mastodon.social'); | |
| $builder->setMaxBehindLines(10); | |
| $builder->setMaxFrontLines(10); |
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 argparse import ArgumentParser | |
| import time | |
| import numpy as np | |
| import torch | |
| from torch import nn | |
| from torch.utils.data import DataLoader, TensorDataset | |
| from torch.optim import Adam | |
| from torch.nn import functional as 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
| using BenchmarkTools | |
| using ForwardDiff | |
| using ReverseDiff | |
| using Random | |
| using Plots | |
| using Statistics: mean, quantile, std | |
| using Measurements | |
| using Printf: @sprintf | |
| using Colors |
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
| using Flux | |
| using Fluxperimental: @compact | |
| nf = 10 | |
| nb = 32 | |
| nt = 100 | |
| d_attn = 64 | |
| d_value = 128 | |
| d_head = 16 | |
| d_out = 256 |
This file has been truncated, but you can view the full file.
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
| ┌ Warning: Recursive type | |
| │ T = Node{Float64} | |
| └ @ Enzyme /dev/shm/.julia/packages/GPUCompiler/BxfIW/src/utils.jl:56 | |
| ┌ Warning: Recursive type | |
| │ T = Node{Float64} | |
| └ @ Enzyme /dev/shm/.julia/packages/GPUCompiler/BxfIW/src/utils.jl:56 | |
| ┌ Warning: Recursive type | |
| │ T = Node{Float64} | |
| └ @ Enzyme /dev/shm/.julia/packages/GPUCompiler/BxfIW/src/utils.jl:56 | |
| ┌ Warning: Recursive type |
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
| # Apply a function to any slurm job matching a regexp. | |
| # For example, `son 'my_job_32.*' scancel {}` would run `scancel <job>` on any | |
| # job matching the regexp. | |
| function son { | |
| squeue -u $USER --format="%i %j" | awk "/${1}/"' {print $1}' | xargs -I {} ${@:2} | |
| } | |
| # Watch a detailed `squeue` output (from Siavash Golkar) | |
| function sqw { |