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
use llvm_sys::analysis::*; | |
use llvm_sys::core::*; | |
use llvm_sys::execution_engine::*; | |
use llvm_sys::prelude::*; | |
use llvm_sys::target::*; | |
use llvm_sys::*; | |
use std::ptr; | |
macro_rules! c { | |
($s:expr) => { |
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
use std::{ | |
alloc::{GlobalAlloc, Layout}, | |
ptr::{self}, | |
}; | |
use boa::JsString; | |
struct BadAllocator<A: GlobalAlloc>(A); | |
// Implementing the GlobalAlloc trait is unsafe by nature because one could "just" return any invalid pointer |
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
use std::future::Future; | |
use std::pin::Pin; | |
use std::task::{Context, Poll}; | |
use std::time::Duration; | |
#[tokio::main] | |
async fn main() { | |
struct Abortable<T, Fut: Future<Output = T> + Unpin> { | |
aborted: bool, | |
future: Fut, |
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
/// std::intrinsics::{likely, unlikely, assume} in stable Rust | |
mod predict { | |
#[inline(never)] | |
#[cold] | |
fn unlikely_inner() {} | |
pub fn unlikely<B: Into<bool>>(b: B) -> bool { | |
let b = b.into(); | |
if b { unlikely_inner(); } | |
b |
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
use std::ops::{Drop, Deref}; | |
#[derive(Debug)] | |
struct ManualDrop<T>(*mut T); | |
impl<T> ManualDrop<T> { | |
pub fn new(data: T) -> ManualDrop<T> { | |
Self(Box::into_raw(Box::new(data))) | |
} | |
} |
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
[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405 |
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
const {NodeVM} = require('vm2'); | |
const {isMainThread, Worker, parentPort} = require('worker_threads'); | |
if (isMainThread) { | |
const worker = new Worker(__filename); | |
let lastMessage = null; | |
worker.on('message', () => lastMessage = Date.now()); | |
worker.on('online', () => lastMessage = Date.now()); |
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
const {Isolate} = require('isolated-vm'); | |
const isolate = new Isolate({memoryLimit: 16}); | |
const ctx = isolate.createContextSync(); | |
ctx.eval("Math.max('1'.repeat(1024 ** 2 * 127));"); | |
process.exit(); |
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
// https://github.com/y21/embedded-console | |
import EmbeddedConsole from './EmbeddedConsole'; | |
import React from 'react'; | |
export default class Console extends React.Component { | |
state = {}; | |
componentDidMount() { | |
const element = document.getElementById('console'); | |
if (!element) return console.error('Console element not found'); |
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
const { Paginator } = require('detritus-pagination'); | |
const { ShardClient } = require('detritus-client'); | |
const client = new ShardClient('token'); | |
const paginator = new Paginator(client, { | |
maxTime: 300000, | |
// ... | |
}); | |
// Wrapper function |
NewerOlder