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
# A template to run ubuntu using vmType: vz instead of qemu (Default) | |
# This template requires Lima v0.14.0 or later and macOS 13. | |
vmType: "vz" | |
rosetta: | |
# Enable Rosetta for Linux. | |
# Hint: try `softwareupdate --install-rosetta` if Lima gets stuck at `Installing rosetta...` | |
enabled: true | |
# Register rosetta to /proc/sys/fs/binfmt_misc | |
binfmt: true |
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
function dive | |
set repo $argv[1] | |
if test -z (echo $repo | cut -d '/' -f3) | |
set repo github.com/$repo | |
end | |
set path ~/repos/$repo | |
if test -d $path | |
cd $path | |
echo "Moved to existing directory $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
require 'benchmark' | |
require 'json' | |
require 'active_support/notifications' | |
require 'active_support/cache' | |
array = (1..1000).map { rand } | |
TIMES = 1000 | |
Benchmark.bmbm do |x| | |
cache = ActiveSupport::Cache::FileStore.new("./tmp/cache") |
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 ConstructorArgs { | |
namespace: string[] = ["default", "values"] | |
} | |
class Base extends ConstructorArgs { | |
constructor(opts: ConstructorArgs = new ConstructorArgs) { | |
super() | |
Object.assign(this, opts) | |
} | |
} |
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
# views/fields/belongs_to_scoped/_form.html.erb | |
<div class="field-unit__label"> | |
<%= f.label field.permitted_attribute %> | |
</div> | |
<div class="field-unit__field"> | |
<%= f.select(field.permitted_attribute) do %> | |
<%= options_for_select(field.associated_resource_options(f.object.send("#{field.name}_candidates")), field.selected_option) %> | |
<% end %> | |
</div> |
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 <stdio.h> | |
#include <time.h> | |
#include <stdlib.h> | |
#define N 16 | |
#define M 16 | |
#define NN 2 | |
unsigned char x0[N]={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
#include <stdio.h> | |
#include <time.h> | |
#include <stdlib.h> | |
#define N 16 | |
#define M 16 | |
#define NN 2 | |
unsigned char xx[N]; |
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
require 'matrix' | |
gem 'ruby-numtheory' | |
require 'numtheory' | |
def IntegerModRing(mod) | |
class_name = "IntegerModRing#{mod}" | |
return Kernel.const_get class_name rescue nil | |
cls = Class.new do |cls| |
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 functools, itertools, random, math | |
from sympy.combinatorics import Permutation | |
def cycle_rounds(p1, p2, verbose = False): | |
'''detect all cycles in p1 how many times rounded in p2 | |
Usage: | |
>>> p = Permutation(10)(2,3,4,5)(6,7) | |
>>> cycle_rounds(p,p**3) | |
[(1, 2), (3, 4)] |
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
=LET(LX, LAMBDA(X, A, BITXOR(X, BITLSHIFT(BITAND(X, 2^(32-A)-1), A))), RX, LAMBDA(X, A, BITXOR(X, BITRSHIFT(X, A))), LX(RX(LX(input, 13), 17), 5)) |
NewerOlder