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
git diff --name-only --diff-filter=AM origin/master | \ | |
xargs bundle exec rubocop --display-cop-names --extra-details --parallel --force-exclusion |
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
use std::thread; | |
use std::thread::JoinHandle; | |
use std::sync::{Arc, Mutex, MutexGuard}; | |
type Node = Arc<Mutex<TreeNode>>; | |
#[derive(Debug)] | |
struct TreeNode { | |
value: u16, | |
children: Vec<Node>, |
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
--lock monitor | |
CREATE VIEW lock_monitor AS( | |
SELECT | |
COALESCE(blockingl.relation::regclass::text,blockingl.locktype) as locked_item, | |
now() - blockeda.query_start AS waiting_duration, blockeda.pid AS blocked_pid, | |
blockeda.query as blocked_query, blockedl.mode as blocked_mode, | |
blockinga.pid AS blocking_pid, blockinga.query as blocking_query, | |
blockingl.mode as blocking_mode | |
FROM pg_catalog.pg_locks blockedl | |
JOIN pg_stat_activity blockeda ON blockedl.pid = blockeda.pid |
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
SELECT | |
pg_cancel_backend(pid), | |
now()-pg_stat_activity.query_start AS duration, | |
query, | |
state | |
FROM pg_stat_activity | |
WHERE (now()-pg_stat_activity.query_start) > interval '1 day'; | |
SELECT pg_sleep(30); | |
SELECT | |
pg_terminate_backend(pid), |
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 bash | |
CMD="${1?valid commands are psql, seed, create, drop, reset}" | |
set -eux pipefail | |
export $(sed '/^#/ d' .env) | |
HOST="${DB_HOST-localhost}" | |
USERNAME="${DB_USERNAME-postgres}" | |
PASSWORD="${DB_PASSWORD-postgres}" |
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
{ | |
"fromUserName": "Axel Lidenbrock", | |
"message": "Welcome to the center of the earth", | |
"chatroom": "foyer" | |
} |
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
ws.onopen = function () { | |
if (ws.protocol == 'appProtocol-v2') { | |
... | |
} else { | |
... | |
} | |
} |
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
const WebSocket = require('ws'); | |
const server = new WebSocket.Server({ port: 8080 }); | |
server.on('connection', function connection(ws) { | |
ws.send('connected') | |
ws.on('message', function incoming(message) { | |
ws.send('something'); | |
}); |
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
var websocket = new WebSocket('ws://echo.websocket.org/'); | |
websocket.onopen = function(e) { | |
console.log('socket open'); | |
} | |
websocket.onmessage = function (e){ | |
console.log(e.data) | |
}; |
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
class AddColumnUsersIsAdmin < ActiveRecord::Migration | |
phase :pre_restart | |
def change | |
add_column :users, :is_admin, :boolean | |
end | |
end | |
class BackfillUsersIsAdminNoLock < ActiveRecord::Migration | |
phase :post_restart |
NewerOlder