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
#[pyfunction] | |
fn process_file(file: &PyAny, callback: &PyAny) { | |
assert!(callback.is_callable()); | |
let file = file.to_string(); | |
if let Ok(lines) = read_lines(file) { | |
for line in lines { | |
Python::with_gil(|py| { | |
let pool = unsafe { py.new_pool() }; | |
let py = pool.python(); | |
for msg in line.unwrap().replace("}{", "}\n{").split("\n") { |
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
diff --git a/config/webpack/production.js b/config/webpack/production.js | |
index cec810184..a5807830a 100644 | |
--- a/config/webpack/production.js | |
+++ b/config/webpack/production.js | |
@@ -15,8 +15,9 @@ const sharedConfig = require('./shared'); | |
const root = resolve(__dirname, '..', '..'); | |
module.exports = merge(sharedConfig, { | |
+ parallelism: 1, | |
mode: 'production', |
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
for f in (ls /sys/bus/usb/devices/*/product) | |
echo $f && cat $f | |
end |
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
// Compile with -O3 | |
#include <string> | |
#include <stdlib.h> | |
#include <iostream> | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
string greeting("Hello, "); | |
string name = argv[1]; | |
cout << greeting.append(name) << endl; | |
return 0; |
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
#lang racket/base | |
(require racket/contract/base "unix_rand.rkt" "windows_rand.rkt" (only-in file/sha1 bytes->hex-string)) | |
(provide (contract-out [crypto-random-bytes (-> exact-positive-integer? (or/c bytes? string?))] | |
[crypto-random (-> exact-positive-integer? exact-positive-integer?)])) | |
(define bytes->number (compose (lambda (s) (string->number s 16)) bytes->hex-string)) | |
; (: crypto-random-bytes (-> Positive-Integer Bytes)) | |
; returns n random bytes from the os. | |
(define (crypto-random-bytes n) |
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
#lang racket/base | |
(require ffi/unsafe | |
racket/runtime-path | |
(for-syntax racket/base) | |
"libcrypto.rkt") | |
(define _BIGNUM-ptr (_cpointer/null 'BIGNUM)) | |
(define _BN_CTX-ptr (_cpointer/null 'BN_CTX)) | |
(define _BN_GENCB-ptr (_cpointer/null 'BN_GENCB)) |
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
(define (make-adder increment) | |
(define (adder x) | |
(+ x increment)) | |
adder) | |
(define adder (make-adder 2)) | |
(adder 1) |
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
#lang racket | |
; An implementation of the von Neumann unbiasing algorithm. | |
; The unbias procedure takes a pseudo-random bit generator and extracts entropy from the sequence of generated bits | |
; thereby creating a "more random" sequence. | |
; The catch here is that the pairs 01 and 10 have to be equally likely, and there can't be correlation between successive bits. | |
(define (extract-entropy bit-generator) | |
(let ([x (bit-generator)] | |
[y (bit-generator)]) | |
(cond [(or (and (= x 1) (= y 1)) | |
(and (= x 0) (= y 0))) |
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
#lang racket | |
(require openssl/sha1) | |
(struct node (value left right) #:transparent) | |
(define (hash s) | |
(sha1 (open-input-string s))) | |
(define (build-foundation l [hash hash]) | |
(let loop ([l l]) |
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
#lang racket | |
; groups.rkt is located in the repository https://github.com/eu90h/elgamal-signature | |
(require math "groups.rkt") | |
(define (diffie-hellman in out [p ike-2048] [g 2]) | |
; Alice uniformly chooses a random integer a s.t. 1 <= a < p - 1 | |
; and then computes A := g^a mod p | |
(let* ([a (random-integer 1 (- p 1))] | |
[A (modular-expt g a p)]) | |
; Alice then sends A to her interlocutor Bob. |
NewerOlder