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
# example of getting file change details along with a batch marker | |
# used to perform single action for "batch" for file changes | |
# set to `true` to echo all file changes | |
DEBUG=false | |
FILE_CHANGE_BATCH_MARKER='--file-change-batch-end--' | |
fswatch --batch-marker="${FILE_CHANGE_BATCH_MARKER}" -0 . | xargs -0 -n 1 -I {} echo {} | while read file_path; | |
do |
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
// fetches all the books history from safaribooksonline.com for the logged in user | |
// and outputs as csv string | |
// see screenshot @ https://www.evernote.com/l/AAHItduomfRPHpw03KboGWL5cof7oK1CZjgB/image.png | |
// run in browser console (tested in chrome) | |
(async () => { | |
class Scraper { |
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
#!/usr/sbin/dtrace -C -s | |
#pragma D option quiet | |
proc::posix_spawn:exec-success,proc::__mac_execve:exec-success | |
{ | |
this->isx64=(curproc->p_flag & P_LP64)!=0; | |
#define SELECT_64_86(x64, x86) (this->isx64 ? (x64) : (x86)) | |
#define GET_POINTER(base, offset) (user_addr_t)SELECT_64_86(*(uint64_t*)((base)+sizeof(uint64_t)*(offset)), *(uint32_t*)((base)+sizeof(uint32_t)*(offset))) |
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
// C scratch area | |
#include <cstdio> | |
#include <memory> | |
#include <cstring> | |
#include <cstdlib> | |
#include <ctime> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> |
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
(async () => { | |
class Scraper { | |
sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} |
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
/* convert a safari book (safaribooksonline.com) to text in the browser */ | |
/* must be logged in and on one of the pages in the book */ | |
(async () => { | |
class Scraper { | |
sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} |
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
package main | |
import ( | |
"fmt" | |
"testing" | |
) | |
func TestSliceTypeAssertion(t *testing.T) { | |
fn := func(v interface{}) { |
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
// Text color codes: | |
// 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white | |
// see: http://webhome.csc.uvic.ca/~sae/seng265/fall04/tips/s265s047-tips/bash-using-colors.html | |
// '\u001b' is ESC (escape) | |
function color(s, c) { | |
return '\u001b[' + c + ';1m' + s + '\u001b[0m'; | |
} | |
const s = `Hello ${color('World', 32)}. How are you?` |