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
SSH_ENV="$HOME/.ssh/environment" | |
function start_agent { | |
echo "Initialising new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo succeeded | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null | |
/usr/bin/ssh-add; | |
} |
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
#!/usr/bin/env python | |
# both python 2 and 3 comatible | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
try: | |
input = raw_input | |
except NameError: | |
pass | |
import sys |
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
#!/bin/cat | |
# Intro to using UNIX Screen | |
## Basics | |
screen -list # LIST current screen sessions | |
screen -S myscreen1 # CREATE a new session named *myscreen1* |
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
REGEDIT4 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] | |
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00 |
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
REGEDIT4 | |
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] | |
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00 |
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
# sync_scrape.py (needs Python 3.7+) | |
import time, re, requests | |
def fetch_url(url): | |
t = time.perf_counter() | |
html = requests.get(url).text | |
print(f"time of fetch_url({url}): {time.perf_counter() - t:.2f}s") | |
return html | |
def scrape_data(html): |
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
// sync_scrape.js (tested with node 11.3) | |
const request = require("sync-request"); | |
const fetchUrl = url => { | |
console.time(`fetchUrl(${url})`); | |
const html = request("GET", url).getBody(); | |
console.timeEnd(`fetchUrl(${url})`); | |
return html; | |
}; |
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
// callbacks_async_scrape.js (tested with node 11.3) | |
const http = require('http'); | |
const https = require('https'); | |
const fetchUrl = (url, onSuccess, onError) => { | |
console.time(`fetchUrl(${url})`); | |
(url.indexOf('https') === 0 ? https : http).get(url, resp => { | |
let html = ''; | |
resp.on('data', chunk => html += chunk); | |
resp.on('end', () => { |
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
# async_scrape.py (requires Python 3.7+) | |
import asyncio, random, time | |
async def fetch_url(url): | |
print(f"~ executing fetch_url({url})") | |
t = time.perf_counter() | |
await asyncio.sleep(random.randint(1, 5)) | |
print(f"time of fetch_url({url}): {time.perf_counter() - t:.2f}s") | |
return f"<em>fake</em> page html for {url}" |
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
// async_scrape.js (tested with node 11.3) | |
const sleep = ts => new Promise(resolve => setTimeout(resolve, ts * 1000)); | |
async function fetchUrl(url) { | |
console.log(`~ executing fetchUrl(${url})`); | |
console.time(`fetchUrl(${url})`); | |
await sleep(1 + Math.random() * 4); | |
console.timeEnd(`fetchUrl(${url})`); | |
return `<em>fake</em> page html for ${url}`; | |
} |