Skip to content

Instantly share code, notes, and snippets.

@andreipak
andreipak / gist:2731597
Created May 19, 2012 17:28 — forked from mhawksey/gist:1106744
Bunch of Google Apps Script snippets for getting social bookmark/share counts. Used in http://mashe.hawksey.info/2011/07/shared-counts/
/*
All code apart from getPlusones()
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@andreipak
andreipak / tmux.cheat
Created February 15, 2013 10:39 — forked from afair/tmux.cheat
========================================== WINDOW (TAB)
TMUX COMMAND ==========================================
==========================================
List ^b w
List tmux ls Create ^b c
New -s <session> Rename ^b , <name>
Attach att -t <session> Last ^b l (lower-L)
Rename rename-session -t <old> <new> Close ^b &
Kill kill-session -t <session>
Goto # ^b <0-9>
RVM home page: http://rvm.beginrescueend.com
Install RVM
------------
See http://rvm.beginrescueend.com/rvm/install/
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Install rvm for all users
#!./bin/knife exec
# A knife exec script to change chef node's name, preserving all the attributes.
#
# Usage: knife exec rename-node.rb old-name new-name
#
# Script retrieves the Node object, changes its 'name' attribute,
# creates new Node object with updated name and rest of attributes
# untouched. Then it deletes old Node and Client objects from
# database, and logs into the server to update it:
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
# We need to specify GNU sed for OS X, BSDs, etc.
if [[ "$(uname -s)" == "Darwin" ]]; then
SED=gsed
else
SED=sed
fi
@andreipak
andreipak / knife.sh
Created May 20, 2013 08:14 — forked from nukemberg/knife.sh
bash completion for Chef's knife command (updated for 0.10)
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
# We need to specify GNU sed for OS X, BSDs, etc.
if [[ "$(uname -s)" == "Darwin" ]]; then
SED=gsed
else
SED=sed
fi
@andreipak
andreipak / tcpstats.sh
Created August 2, 2013 22:31
TCP Connections Stats for Zabbix
#!/bin/bash
/sbin/ss -ant | awk "{if (NR>1) {state[\$1]++}} END {host = \"-\"; \
for (i in state) {s=i; \
sub (/ESTAB/, \"establ\", s); sub (/LISTEN/, \"listen\", s); sub (/SYN-SENT/, \"synsent\", s); \
sub (/SYN-RECV/, \"synrecv\", s); sub (/FIN-WAIT-1/, \"finw1\", s); sub (/FIN-WAIT-2/, \"finw2\", s); \
sub (/CLOSE-WAIT/, \"closew\", s); sub (/TIME-WAIT/, \"timew\", s); print host, \"tcp.\"s, state[i]}}" \
| /usr/bin/zabbix_sender -vv -c /etc/zabbix/zabbix_agentd.conf -i - 2>&1
echo "1"
exit 0
@andreipak
andreipak / midnight-commander.rb
Last active December 26, 2015 18:19
Modified MidnightCommander Formula to support PROMPT_COMMAND shell variable
require 'formula'
class MidnightCommander < Formula
homepage 'http://www.midnight-commander.org/'
url 'http://www.midnight-commander.org/downloads/mc-4.8.10.tar.bz2',
:using => CurlUnsafeDownloadStrategy
mirror 'http://fossies.org/linux/misc/mc-4.8.10.tar.bz2'
sha256 '5f4166fe78fbf4b42f51ed526ca7f79fea8c77d04355c2b97d4df2a6bd2a1b1a'
depends_on 'pkg-config' => :build
@andreipak
andreipak / subshell_prompt.patch
Last active December 26, 2015 18:19
MC clobbers the PROMPT_COMMAND shell variable [http://www.midnight-commander.org/ticket/2027]
diff -udpr src/subshell.c.orig src/subshell.c
--- src/subshell.c.orig 2013-08-02 18:02:39.000000000 +0300
+++ src/subshell.c 2013-10-28 10:47:34.000000000 +0200
@@ -769,7 +769,7 @@ init_subshell (void)
{
/* This must be remembered across calls to init_subshell() */
static char pty_name[BUF_SMALL];
- char precmd[BUF_SMALL];
+ char precmd[BUF_MEDIUM];
@andreipak
andreipak / parallel-scp
Last active November 8, 2019 04:52
Attempt to roll two useful pssh tools (parallel-ssh and parallel-scp) into reusable scripts with our old friend xargs. Link: http://90kts.com/2010/10/31/parallel-ssh-for-osx/
#!/bin/bash
usage()
{
cat << EOF
Usage: $0 [OPTIONS] -h hosts.txt local remote
-h hosts file (each line "host")
-r recusively copy directories (OPTIONAL)
-l username
-p max number of parallel threads (OPTIONAL)