Skip to content

Instantly share code, notes, and snippets.

View dustins's full-sized avatar

Dustin Sweigart dustins

View GitHub Profile
#!/bin/bash
if [[ -n "$1" && "$1" == "1M" ]]; then
echo "Benchmark 1M Async (throughput)" | tee /dev/tty >> results.txt
for mode in "read" "write" "randrw"; do
if [[ "$mode" == "randrw" ]]; then
echo " # rand" | tee /dev/tty >> results.txt
else
echo " # sequential" | tee /dev/tty >> results.txt
fi
use async_std::channel;
use async_std::net::{SocketAddr, UdpSocket};
use async_std::sync::Arc;
use async_std::task;
use async_std::task::JoinHandle;
use async_trait::async_trait;
use crate::config::Config;
use crate::error::Result;
use crate::mux::{CHANNEL_CAP, Mux};
@dustins
dustins / stuff.md
Last active November 10, 2019 03:05
my memory of gpu passthrough

find BDF and PCI ID

lspci -vvnn | less
    0a:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Baffin [Radeon RX 550 640SP / RX 560/560X] [1002:67ff] (rev cf) (prog-if 00 [VGA controller])
    0a:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Baffin HDMI/DP Audio [Radeon RX 550 640SP / RX 560/560X] [1002:aae0]

find aliases using BDF

cat /sys/bus/pci/devices/0000\:0a\:00.*/modalias 
@dustins
dustins / Penn Treebank II Tags.md
Created August 18, 2016 00:10 — forked from nlothian/Penn Treebank II Tags.md
Penn Treebank II Tags
@dustins
dustins / gist:1083972
Last active August 18, 2016 18:28
js singleton
var SingletonClass = function () {
if (SingletonClass.prototype.instance) {
console.log("returning existing instance");
return SingletonClass.prototype.instance;
}
console.log("initial instance setup");
SingletonClass.prototype.instance = this;
};
diff --git a/AppKit/CPMenu/_CPMenuManager.j b/AppKit/CPMenu/_CPMenuManager.j
index 18d1021..b7ade82 100644
--- a/AppKit/CPMenu/_CPMenuManager.j
+++ b/AppKit/CPMenu/_CPMenuManager.j
@@ -364,6 +364,9 @@ var SharedMenuManager = nil;
[menuWindow setBackgroundStyle:_CPMenuWindowPopUpBackgroundStyle];
[menuWindow setFrameOrigin:aGlobalLocation];
+ if ([[newMenu delegate] respondsToSelector:@selector(menuWillOpen:)]) {
+ [[newMenu delegate] menuWillOpen:newMenu];
diff --git a/AppKit/CPMenu/CPMenu.j b/AppKit/CPMenu/CPMenu.j
index 39203df..d8f90af 100644
--- a/AppKit/CPMenu/CPMenu.j
+++ b/AppKit/CPMenu/CPMenu.j
@@ -695,7 +695,7 @@ var _CPMenuBarVisible = NO,
var delegate = [self delegate];
if ([delegate respondsToSelector:@selector(menuWillOpen:)])
- [delegate menuWillOpen:aMenu];
+ [delegate menuWillOpen:self];
diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j
index d6f2602..0a034ca 100644
--- a/Foundation/CPURLConnection.j
+++ b/Foundation/CPURLConnection.j
@@ -248,8 +248,21 @@ var CPURLConnectionDelegate = nil;
[_delegate connection:self didReceiveResponse:[[CPURLResponse alloc] initWithURL:URL]];
else
{
+ var rawHeaders = [[CPString stringWithString:_HTTPRequest.getAllResponseHeaders()]
+ componentsSeparatedByString:@"\n"],