Skip to content

Instantly share code, notes, and snippets.

@aizatto
aizatto / merge-querystrings.js
Last active April 8, 2024 20:27
Merge Query Strings (Node.js)
const url = require('url')
const appendQueryString = (url_string, query_string_object) => {
const parsed_url = url.parse(url_string, true);
parsed_url.query = Object.assign(
parsed_url.query,
query_string_object,
);
return url.format(parsed_url);
};
@aizatto
aizatto / mysql-to-postgres.ts
Created May 18, 2019 05:35
knex: Migrate from MySQL to PostgreSQL
const pg = require('pg');
pg.defaults.ssl = true;
const configs = require("config/knexfile.js");
const mysql = require("knex")(configs["mysql"]);
const postgres = require("knex")(configs["postgres"]);
async function migrate(table) {
const results = await mysql.from(table);
await postgres(table).insert(results);
@aizatto
aizatto / .bash_profile
Created July 2, 2017 06:20
Display node version in bash prompt
_node_version()
{
local br
br=$(node -v)
test -n "$br" && printf %s "$br" || :
}
green=$'\e[1;32m'
magenta=$'\e[1;35m'
normal_colours=$'\e[m'
@aizatto
aizatto / deploy.rb
Created June 2, 2017 23:47
Capistrano configuration for yarn
namespace :deploy do
before :updated, 'yarn:install'
before :updated, 'yarn:build'
end
namespace :yarn do
desc 'Install yarn dependencies'
task :install do
@aizatto
aizatto / gist:5684758
Created May 31, 2013 12:50
http://tour.golang.org/#40 A Tour of Go Exercise: Maps Implement WordCount. It should return a map of the counts of each “word” in the string s. The wc.Test function runs a test suite against the provided function and prints success or failure. You might find strings.Fields helpful.
package main
import (
"strings"
"code.google.com/p/go-tour/wc"
)
func WordCount(s string) map[string]int {
m := make(map[string]int)
for _, v := range strings.Fields(s) {
@aizatto
aizatto / controls.md
Last active June 27, 2020 04:42
Worms W.M.D. Controls
@aizatto
aizatto / gist:8af0f1565ab171e2df9087882b37f27b
Created May 8, 2020 09:05
Wake transition timed out after 180 seconds while entering fullwake from darkwake. Suspected bundle: com.apple.iokit.IOGraphicsFamily
panic(cpu 0 caller 0xffffff8016691b2c): Wake transition timed out after 180 seconds while entering fullwake from darkwake. Suspected bundle: com.apple.iokit.IOGraphicsFamily. Thread 0x74.
Backtracing specified thread
Backtrace (CPU 0), Frame : Return Address
0xffffff923b103900 : 0xffffff80160471e8
0xffffff923b90b9b0 : 0xffffff8015f433f1
0xffffff923b90ba20 : 0xffffff8015f41c2f
0xffffff923b90ba70 : 0xffffff80160442e9
0xffffff923b90bab0 : 0xffffff8016043b4b
0xffffff923b90bae0 : 0xffffff7f99afcced
0xffffff923b90bb10 : 0xffffff7f99b15f75
@aizatto
aizatto / build.md
Created April 12, 2020 06:36
Docker build errors with ubuntu:19.10 and s6-overlay
@aizatto
aizatto / gocd-agent.yaml
Last active April 7, 2020 03:37
gocd agent
apiVersion: v1
kind: Pod
metadata:
name: gocd-agent-{{ POD_POSTFIX }}
labels:
app: web
spec:
serviceAccountName: default
containers:
- name: gocd-agent-container-{{ CONTAINER_POSTFIX }}
https://openweathermap.org/weather-conditions
{ id: 201,
main: 'Thunderstorm',
description: 'thunderstorm with rain',
icon: '11d' },
[ { id: 500, main: 'Rain', description: 'light rain', icon: '10d' } ]
[ { id: 501,
main: 'Rain',
description: 'moderate rain',