Skip to content

Instantly share code, notes, and snippets.

@pusateri
pusateri / mio-timer-test.rs
Created April 22, 2019 23:39
mio extra timers don't fire
use std::time::Duration;
use mio::{Events, Ready, Poll, PollOpt, Token};
use mio_extras::channel;
use mio_extras::timer::Timer;
fn main() {
const CHANNEL: Token = Token(0);
let poll = Poll::new().unwrap();
let (tx, rx) = channel::channel::<u32>();
let mut events = Events::with_capacity(1024);
@pusateri
pusateri / mysend.rs
Last active March 23, 2019 15:46
Figuring out how to async send message
lazy_static! {
static ref USMAP: Arc<Mutex<HashMap<String, UpdateServer>>> = Arc::new(Mutex::new(HashMap::new()));
}
#[derive(Debug)]
pub struct UpdateServer {
subdomain: String,
sa: SocketAddr,
sink: SplitSink<UdpFramed<BytesCodec>>,
@pusateri
pusateri / recvmsg.c
Created September 30, 2018 20:47
Example recvmsg() code for Linux and Unix
void
recv_cb(evutil_socket_t fd, short event, void *arg)
{
struct msghdr msg;
struct iovec iov[1];
ssize_t len;
int flags = 0;
struct cmsghdr *cmptr;
sockaddr_union_t sau;
struct unp_in_pktinfo {
@pusateri
pusateri / join_multicast.rs
Created September 4, 2018 12:27
Join a multicast group using Rust with reuse addr & port
#[cfg(unix)]
fn bind_multicast(socket: &Socket, addr: &SocketAddr) -> io::Result<()> {
socket.bind(&socket2::SockAddr::from(*addr))
}
/// Returns a socket joined to the multicast address
fn join_multicast(
multicast_addr: &SocketAddr,
) -> Result<Option<std::net::UdpSocket>, io::Error> {
wget -O - --header="Content-type: application/json" "https://datatracker.ietf.org/api/v1/meeting/session/?meeting__number=95&modified__gt=1970-01-01T22:00:00&limit=200"| python -mjson.tool
--2016-03-19 22:36:35-- https://datatracker.ietf.org/api/v1/meeting/session/?meeting__number=95&modified__gt=1970-01-01T22:00:00&limit=200
Resolving datatracker.ietf.org... 4.31.198.44, 2001:1900:3001:11::2c
Connecting to datatracker.ietf.org|4.31.198.44|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 122639 (120K) [application/json]
Saving to: 'STDOUT'
- 100%[===================>] 119.76K 166KB/s in 0.7s
@pusateri
pusateri / make.out
Created January 11, 2016 05:38
FreeBSD 10.2 build error of dnssec-tools-2.2
===> dnssec-tools-2.2 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by dnssec-tools-2.2 for building
===> Extracting for dnssec-tools-2.2
=> SHA256 Checksum OK for dnssec-tools-2.2.tar.gz.
===> Patching for dnssec-tools-2.2
===> dnssec-tools-2.2 depends on package: bind910>=0 - found
===> dnssec-tools-2.2 depends on package: p5-DateTime-Format-DateParse>=0 - found
===> dnssec-tools-2.2 depends on package: p5-Net-DNS>=0 - found
===> dnssec-tools-2.2 depends on package: p5-Net-DNS-SEC>=0 - found
===> Configuring for dnssec-tools-2.2
@pusateri
pusateri / update.diff
Created May 18, 2015 04:26
libchromiumcontent script/update SSL patch
diff --git a/script/update b/script/update
index 93028c5..df751d2 100755
--- a/script/update
+++ b/script/update
@@ -9,6 +9,7 @@ import subprocess
import tarfile
import tempfile
import urllib2
+import ssl
@pusateri
pusateri / freebsd-atom.diff
Last active August 29, 2015 14:20
2015/05/08 FreeBSD changes for Atom
diff --git a/apm/package.json b/apm/package.json
index 423e31a..1d05587 100644
--- a/apm/package.json
+++ b/apm/package.json
@@ -6,6 +6,6 @@
"url": "https://github.com/atom/atom.git"
},
"dependencies": {
- "atom-package-manager": "0.166.0"
+ "atom-package-manager": "../../apm"
@pusateri
pusateri / package.json.diff
Last active August 29, 2015 14:20
Use local version of node instead of trying to download a new version
diff --git a/package.json b/package.json
index f929d56..a670612 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
},
"scripts": {
"prepublish": "grunt prepublish",
- "install": "node ./script/download-node.js",
+ "install": "ln -s /usr/local/bin/node bin/node",
@pusateri
pusateri / package.json.diff
Created April 23, 2015 17:44
atom editor build package version patch
--- build/package.json.orig 2015-04-23 13:32:14.919342000 -0400
+++ build/package.json 2015-04-23 13:32:58.564682041 -0400
@@ -17,11 +17,11 @@
"grunt-cli": "~0.1.9",
"grunt-coffeelint": "git+https://github.com/atom/grunt-coffeelint.git#cfb99aa99811d52687969532bd5a98011ed95bfe",
"grunt-contrib-coffee": "~0.12.0",
- "grunt-contrib-csslint": "~0.1.2",
+ "grunt-contrib-csslint": "~0.2.0",
"grunt-contrib-less": "~0.8.0",
"grunt-cson": "0.14.0",