Skip to content

Instantly share code, notes, and snippets.

@bbtdev
bbtdev / readline-cheatsheet.md
Last active October 15, 2018 16:45 — forked from P7h/Bash_command_line_shortcuts.md
Readline library aka command line shortcuts

Readline cheatsheet

Picked these from here

Command Editing Shortcuts

Command Note
Ctrl + a go to the start of the command line
Ctrl + e go to the end of the command line
Ctrl + k delete from cursor to the end of the command line
@bbtdev
bbtdev / bash-ruby-yaml-to-json
Created September 25, 2018 09:36 — forked from chrismytton/yaml2json.sh
Shell function to convert YAML to JSON
yaml2json () {
ruby -r yaml -r json -e 'puts YAML.load($stdin.read).to_json'
}
@bbtdev
bbtdev / ruby-read-file-from-bottom-to-top-until-match
Last active October 3, 2018 11:01
ruby read file from bottom to top until match
# thank you aperios from #ruby
#! /usr/bin/env ruby
class Rubash
def tail_match(filename, pattern)
fd = File.open(filename, 'rb')
file_byte_size = fd.size
pos = 0
result = ''
result.encode!(Encoding::BINARY)
06:42 <za1b1tsu> So I have a var: ['a','b']. How can I get the last element?
06:54 <flowerysong> za1b1tsu: {{ var | last }}
06:55 <flowerysong> Or {{ var[-1] }}
07:19 <za1b1tsu> but what is this syntax called {{ var | last }} etc. It is not yaml, right?
07:19 <@jborean93> it's jinja2
07:20 <@jborean93> http://jinja.pocoo.org/docs/2.10/
09:01 <za1b1tsu> Is it possible to have a shared database on a common partition between 2 OSes? Because I'm trying to achieve this and I can't start the postgres service after changing the data_directory to the shared one.
09:01 <za1b1tsu> It's version 9.6.10
09:02 <RhodiumToad> 2 OSes that you are dual-booting? i.e. only one is running at a time?
09:02 --> held (~heldchen@unaffiliated/held) has joined #postgresql
09:02 <RhodiumToad> the answer is that it depends on the OSes
09:03 <peerce> if their libc implementations different significantly, it may not work.
09:03 <za1b1tsu> yes dual booting, one is Mac on is Linux, but right now I'm testing this on the VM. Sice I don't want to setup everything and then realize it doesnt work and have to start other.
09:04 <peerce> what error do you get when you try and start the 'other' OS that didn't create this ?
09:04 <za1b1tsu> the problem is the postgresql log in /var/log/... does not say much or I don't know how to interpret
09:04 <RhodiumToad> mac vs linux likely wo
@bbtdev
bbtdev / gist:3bf21bc999edd60c408f22735d0bdf02
Created November 28, 2018 17:32
monitor-http-requests
sudo tcpdump -s 0 -A 'tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)'
BUT DOING IN A TEMP DIR IT CREATES FILES!!!
conky.config = {
alignment = 'bottom_left',
background = true,
color2 = '2ECC71',
cpu_avg_samples = 2,
default_color = 'FFFFFF',
double_buffer = true,
font = 'Bitstream Vera Sans:size=8',
gap_x = 25,
gap_y = 45,
-- vim: ts=4 sw=4 noet ai cindent syntax=lua
--[[
Conky, a system monitor, based on torsmo
Any original torsmo code is licensed under the BSD license
All code written since the fork of torsmo is licensed under the GPL
Please see COPYING for details
conky.config = {-- Create own window instead of using desktop (required in nautilus)
own_window = true,
own_window_type = 'desktop',
own_window_transparent = true,
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
-- Use double buffering (reduces flicker, may not work for everyone)
double_buffer = true,
conky.config = {
alignment = 'top_right',
background = true,
color2 = '2ECC71',
cpu_avg_samples = 2,
default_color = 'FFFFFF',
double_buffer = true,
font = 'Bitstream Vera Sans:size=8',
gap_x = 25,
gap_y = 13,