Skip to content

Instantly share code, notes, and snippets.

@echoz
echoz / events.js
Last active November 14, 2020 08:48
Monitor Docker Engine (Node JS)
let http = require('http')
const options = {
socketPath: "/var/run/docker.sock",
path: "/events?type=container"
}
const request = http.request(options, (res) => {
res.on('data', (data) => {
let json = JSON.parse(data.toString())

Keybase proof

I hereby claim:

  • I am echoz on github.
  • I am echoz (https://keybase.io/echoz) on keybase.
  • I have a public key whose fingerprint is A971 029E 7794 63E0 42B8 1092 D2B3 1656 DA85 342D

To claim this, I am signing this object:

// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
//
// RSPlayPauseButton.h
//
// Created by Raphael Schaad on 2014-03-22.
// This is free and unencumbered software released into the public domain.
//
#import <UIKit/UIKit.h>
[jeremy@swift ~]$ traceroute6 0x.sg
traceroute6 to 0x.sg (2001:d98:4800:20::2) from 2001:470:1f07:c73:bd1b:46e9:e352:3999, 64 hops max, 12 byte packets
1 2001:470:1f07:c73::1 2.680 ms 0.881 ms 0.705 ms
2 echoz-1.tunnel.tserv4.nyc4.ipv6.he.net 15.809 ms 14.530 ms 15.863 ms
3 ge3-8.core1.nyc4.he.net 15.288 ms 11.999 ms 10.522 ms
4 10ge10-3.core1.lax1.he.net 75.288 ms 70.462 ms 73.411 ms
5 10ge1-3.core1.lax2.he.net 72.460 ms 80.198 ms 73.922 ms
6 2001:504:13::1e 69.000 ms 75.047 ms 70.997 ms
7 2001:c10:80:1::1b1 71.064 ms
2001:c10:80:1::1a1 76.777 ms 70.941 ms
@echoz
echoz / parser.js
Last active December 19, 2015 18:29
NTU Campus bus parser
function versionString() {
return "1.0";
}
function parseURL() {
return "http://campusbus.ntu.edu.sg/ntubus";
}
function headers() {
return {
@echoz
echoz / gist:4180982
Created December 1, 2012 07:29
Singtel fibre to adcdownload.apple.com
orange:lbciphone jeremy$ traceroute adcdownload.apple.com
traceroute: Warning: adcdownload.apple.com has multiple addresses; using 125.56.199.131
traceroute to a312.gi3.akamai.net (125.56.199.131), 64 hops max, 52 byte packets
1 10.0.1.1 (10.0.1.1) 0.444 ms 0.304 ms 0.250 ms
2 bb119-74-53-254.singnet.com.sg (119.74.53.254) 8.595 ms 2.428 ms 2.972 ms
3 202.166.123.50 (202.166.123.50) 8.694 ms 3.685 ms 2.800 ms
4 202.166.123.49 (202.166.123.49) 2.652 ms 3.722 ms 1.467 ms
5 xe-11-2-0.budweiser.singnet.com.sg (202.166.122.50) 1.478 ms 1.647 ms 2.704 ms
6 202.166.123.58 (202.166.123.58) 2.372 ms 2.510 ms 2.947 ms
7 203.208.191.42 (203.208.191.42) 2.021 ms 2.837 ms 2.921 ms
@echoz
echoz / gist:3838512
Created October 5, 2012 07:13
Weird crash
Incident Identifier: EBDC5F80-ABD9-4517-BDB4-90D27B5C872C
CrashReporter Key: 6efa2e1a852e8b513cc6054b3d045444baba5723
Hardware Model: iPhone4,1
OS Version: iPhone OS 6.0 (10A403)
Kernel Version: Darwin Kernel Version 13.0.0: Sun Aug 19 00:28:05 PDT 2012; root:xnu-2107.2.33~4/RELEASE_ARM_S5L8940X
Date: 2012-10-05 14:21:50 +0800
Time since snapshot: 3393 ms
Free pages: 835
Active pages: 7758
@echoz
echoz / gist:3089230
Created July 11, 2012 09:18
do animation only if its supposed to be animated
-(void)doAnimated:(BOOL)animated animation:(void (^)(void))animation {
if (animated) {
[UIView animateWithDuration:0.33
delay:0.0
options:(UIViewAnimationCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState)
animations:animation
completion:nil];
} else {
animation();
}
@echoz
echoz / gist:2932465
Created June 14, 2012 19:42
Nothing wrong with messaging nil
// Consider an accessor setter method
-(void)setUniqueIDString:(NSString *)uid {
if (uid != _uid) {
[_uid release];
_uid = [uid copy];
}
}
// You can do [object setUniqueIDString:nil] and not crash.