Skip to content

Instantly share code, notes, and snippets.

fn a(_:u64,_:u64){print!("{}",0x50f0000003bb8u64)}fn b(_:u64,_:u64){}fn h<'a,'b,T>(_:&'a&'b(),v:&'b mut[T])->&'a mut[T]{v}#[inline(never)]fn g<'a,T:Copy>(x:T)->&'a mut[T]{let f:fn(_,_)->_=h;print!("{:p}",&x);f(&&(),&mut[x;0x100])}pub fn main(){let x=g(0u64);let y=g(if x.as_ptr()as u64>>1>0{a}else{b});x[4]+=0x18f8;y[4]("/bin/sh\0".as_ptr()as _,0)}
@nomissbowling
nomissbowling / gist:353c1918537dd73d6c249856aa3e7384
Created April 15, 2023 00:42 — forked from omasanori/gist:7858569
Rustのパターンマッチの話

Rustのパターンマッチの話

既に穴だらけですが、やれるだけやっていきます。今回はパターンマッチの話です。

TL;DR(経験者向け)

はい、あなたのよく知るパターンマッチです。ガードも使えますが、他の言語でガードを使うパターンの一部はOCamlのorパターンと同等の機能や範囲を表す機能によって置き換えることができます。

@nomissbowling
nomissbowling / HowToSDL2WithRust.md
Created April 12, 2023 07:47 — forked from aita/HowToSDL2WithRust.md
SDL2の手引き with Rust
@nomissbowling
nomissbowling / Dockerfile
Created March 30, 2023 21:08 — forked from Liam-Deacon/Dockerfile
My WSL Setup
# A compilation of Jupyter kernels for DataScience
# Copyright (c) Light Bytes Technology Ltd.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/tensorflow-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Liam Deacon <[email protected]>"
# Install
@nomissbowling
nomissbowling / SimpleHTTPServer.py
Created March 30, 2023 00:41 — forked from two06/SimpleHTTPServer.py
Python SImpleHttpServer with cookie support
#Modifed SimpleHTTPServer which returns cookies passed on the request
import SimpleHTTPServer
import logging
cookieHeader = None
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
self.cookieHeader = self.headers.get('Cookie')
@nomissbowling
nomissbowling / main.rs
Created March 26, 2023 06:55 — forked from toshimasa-nanaki/main.rs
Rust if文
fn main() {
let x = 5;
//if(x == 5) { //←こうも書けるが、コンパイル時に警告が出る
if x == 5 {
println!("x is 5");
} else {
println!("x isn't 5");
}
//ifは式だからこんなこともできる。(三項演算子はない)
import fruitbase, future, sequtils, algorithm
# (copied from http://goran.krampe.se/2014/12/03/nim-seq/)
# Collections are very important in Smalltalk, and they offer a huge protocol
# for working with them. The workhorse in Smalltalk is OrderedCollection - which
# together with Dictionary probably covers 90% of all collection use.
# In Nim the equivalent of an OrderedCollection is the type `seq`.
#
# This is a little rundown of what you can do with seq using stdlib.
import math
# copied from http://goran.krampe.se/2014/12/03/nim-seq/
# Dollars and Kgs
type
Dollar* = distinct float
Kg* = distinct float
proc `$`*(x: Dollar) :string =
@nomissbowling
nomissbowling / argc-argv.nim
Created November 8, 2022 09:00 — forked from kekeho/argc-argv.nim
argc/argv at nim-lang
import os
let argc = paramCount()
# プログラム名以外(C言語等におけるargv[1]以降)
let argv = commandLineParams()
# プログラム名のフルパス(C言語等におけるargv[0])
let programName = getAppFilename()
@nomissbowling
nomissbowling / index.md
Created November 4, 2022 15:54 — forked from voluntas/index.md
Zig 言語リファレンス
  • これは Zig ドキュメント 0.10.0 を DeepL Pro を利用して翻訳したものです。
  • 自分用に翻訳しています
  • そのうち GitHub リポジトリ管理に切り替えます