Skip to content

Instantly share code, notes, and snippets.

View jyn514's full-sized avatar
💭
life is action, and life is good only when action is a joy

jyn jyn514

💭
life is action, and life is good only when action is a joy
View GitHub Profile
Currently the behavior is as follows (where stageN <-> stage(N-1) artifacts, except for stage0 libstd):
- `x.py build --stage 0`:
- stage0 libstd
- stage0 rustc (but without putting rustc in stage1/)
This leaves you without any rustc at all except for the beta compiler
(https://github.com/rust-lang/rust/issues/73519). This is never what you want (currently you should use either `x.py check` or `x.py build --stage 0 src/libstd` instead).
- `x.py build --stage 1`:
5 KLPhash
5 a42-__-
5 aabb-quadtree
5 abci-rs
5 abort_on_panic
5 abra
5 absal
5 abstractgraph
5 aces
5 aci_ppm
@jyn514
jyn514 / build.sh
Created December 2, 2019 21:55
Shell script for building a rust crate using rustops/crates-build-env
#!/bin/sh
set -euv
#cargo check # make sure dependencies are installed
CONTAINER="$("docker" "create" \
"-v" "$(realpath ./target):/opt/rustwide/target:rw,Z" \
"-v" "$(realpath .):/opt/rustwide/workdir:ro,Z" \
"-v" ~/.cargo:/opt/rustwide/cargo-home:ro,Z \
"-v" ~/.rustup:/opt/rustwide/rustup-home:ro,Z \
@jyn514
jyn514 / literals-to-file.rs
Last active November 26, 2019 06:13
Convert a bunch of string literals to files. Used for https://github.com/jyn514/rcc/tree/external-tests
extern crate syn;
use syn::Expr;
use std::fs;
use std::path::Path;
const TARGET_DIR: &str = "runner-tests";
fn main() {
let mut args = std::env::args();
import re
import socket
import subprocess
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("ctfchallenges.ritsec.club", 8080))
data = s.recv(1024)
if data == "":
exit(1)
@jyn514
jyn514 / bench.txt
Last active November 5, 2019 14:09
docs.rs benchmarks
# summary
docs.rs is _much_ faster than my hard disk.
Adding concurrency reduces overall time but increases individual time
Most of the delay on current prod is due to network latency, not CPU time
I cannot reproduce the CPU usage locally - requests are just as fast or faster on the version that overloaded prod as on the latest version.
## extended timing info
### Current prod (I _believe_ c3d3ed3d2e0c4274c0c12a7b1f5e56e68eb8b8bf, remote)
@jyn514
jyn514 / fib.s
Created October 22, 2019 21:32
Fibonacci in MIPS assembly without a jump instruction
# fibonacci sequence in MIPS
# $s0 stores the next to last item in the sequence
# $s1 stores the last item in the sequence
# this is just for initialization
li $t0, 1 # F_1 (since F_0 is 0, we don't need to initialize the registers)
seq $t1, $s1, $0 # if s1 == 0 this is the first run
# conditional move: if (t1) s1 = t0
@jyn514
jyn514 / discrete.hs
Last active February 4, 2020 01:28
CLI helper for discrete math, but in haskell
import Prelude hiding (gcd, lcm)
import Data.Bits ((.&.), Bits)
import Data.Semigroup
import System.Exit (die)
import System.Environment (getProgName, getArgs)
import Text.Printf (printf)
-- | Calculate whether a number is odd
isOdd :: (Integral a, Data.Bits.Bits a) => a -> Bool
isOdd n = n .&. 1 == 1
@jyn514
jyn514 / classes.py
Last active October 4, 2019 16:46
Print all the classes of a python object
#!/usr/bin/env python3
from functools import partial
def classtree(cls, indent=0):
return (classtree(type(cls), indent) if type(cls) != type
else (stringy(cls, indent)
+ ''.join(map(partial(classtree, indent=indent+3),
filter(lambda sub: sub != type,
subclasses(cls))))))
#include<pthread.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#define THREADS 4
void *do_nothing(void* _) {
return NULL;
}