Skip to content

Instantly share code, notes, and snippets.

[
{
"createdDate": "2023-04-04T17:06:12.261866",
"closingDate": "2023-07-03T17:06:10",
"listingTime": 1680627970,
"expirationTime": 1688403970,
"orderHash": "0xad8718bfd02fc4c3afcaad8dc9f13265ce46cd09dc15ec6385c152ad8482e8c3",
"maker": {
"address": "0x2d0024f74ed381167b37f18c9f09f72226523072",
"config": "",
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

// Hours [0, ...23]
function offsetHour (hour, offset) {
return (((hour + offset) % 24) + 24) % 24
}
@alandotcom
alandotcom / logstash-mysql-query-parse.md
Created November 15, 2016 00:46 — forked from jordansissel/logstash-mysql-query-parse.md
parsing mysql's bullshit query log format with logstash

parsing mysql query logs with logstash

The problem is that some lines in the file are missing timestamps when they aren't continuations of any previous line. It's dumb, really.

The mysql query log is seriously bullshit format, but nothing logstash can't unscrew.

The main goal here is to show how we can fix the 'missing timestamp' problem.

% ruby bin/logstash agent -e '

@alandotcom
alandotcom / multiple_ssh_setting.md
Created October 28, 2016 20:06 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
set normal (set_color normal)
set magenta (set_color magenta)
set yellow (set_color yellow)
set green (set_color green)
set red (set_color red)
set gray (set_color -o black)
# Fish git prompt
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
@alandotcom
alandotcom / client.md
Last active December 2, 2015 00:45
rippleAPI JSON RPC server over HTTP port 3000

Using a simple javascript client

const jayson = require('jayson');
const Promise = require('bluebird');

// create a client
const client = jayson.client.http({
  port: 3000,
  hostname: 'localhost'
@alandotcom
alandotcom / example.md
Created November 12, 2015 20:22
Node IPC
var cluster = require('cluster');
var http = require('http');

if (cluster.isMaster) {
  var worker = cluster.fork();

  cluster.on('exit', function(worker, code, signal) {
    console.log('worker ' + worker.process.pid + ' died');
 });