Skip to content

Instantly share code, notes, and snippets.

@bobstrange
bobstrange / influxdb.md
Last active July 25, 2017 09:39
influxdb memo

Use cli

Login

influx -username <username> -password <password>
SHOW DATABASES
use <dbname>
@bobstrange
bobstrange / script.sh
Created July 11, 2017 08:32
Load something from stdin, edit and output to stdout
#!/bin/bash
TMPFILE=`mktemp /tmp/vipe.bashXXXXXXXX`
command="ls"
$(command) > ${TMPFILE}
confirm_changes_and_update() {
while true; do
@bobstrange
bobstrange / mongo_monit
Created July 10, 2017 08:39
Mongod monit configuration on amazon linux
# Put this file to /etc/monit.d/mongo
check process mongod with pidfile /var/run/mongodb/mongod.pid
group mongod
start program = "/etc/init.d/mongod start"
stop program = "/etc/init.d/mongod stop"
if failed host localhost port 27017 type TCP with timeout 15 seconds then restart
if 5 restarts within 5 cycles then timeout
@bobstrange
bobstrange / mongo_logrotate
Last active July 11, 2017 06:10
mongo logrotate for amazonlinux
/var/log/mongodb/*.log {
daily
rotate 3
copytruncate
delaycompress
compress
dateext
notifempty
missingok
}
@bobstrange
bobstrange / debug_angular.md
Last active June 15, 2017 03:02
Access to angular object with chrome dev console

How to get directive's controller

Sample directive

class MyDirectiveController {
  constructor() {
    this.foo = "bar";
  }
  ...
}
@bobstrange
bobstrange / export_mongo_collection_size.js
Last active October 20, 2020 07:38
List mongo collections size
# List mongo collections with count, size and storageSize. Output format is csv
# Usage:
# mongo export_mongo_collection_size.js --eval "var dbName = 'something'"
const conn = new Mongo();
const database = conn.getDB(dbName);
const collectionNames = database.getCollectionNames();
const fields = [
"count",
  • Open keybindings
    • cmd+k cmd+s
  • Install extensions
  • shift+cmd+x
require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL
require 'aws-sdk'
region = 'us-west-2'
user = 'ec2-user'
ssh_options = {
keys: ['~/.ssh/id_rsa'],

Show Database size

SELECT 
  table_schema,
  sum(data_length+index_length) / 1024 / 1024 AS 'Total size(MB)'
FROM
  information_schema.tables
GROUP BY
 table_schema
@bobstrange
bobstrange / gist:37936887d206b0fc008e45bdbbb570d9
Created November 24, 2016 05:23
agent-stats-api ruby sample
require 'net/https'
require 'uri'
require 'json'
require 'csv'
token = "*******"
def retrieve_stats(token)
url = "*******"
uri = URI.parse("https://api.agent-stats.com/groups/#{url}/now")