Skip to content

Instantly share code, notes, and snippets.

Avatar

Piotr Staszewski drbig

View GitHub Profile
@drbig
drbig / psql_useful_stat_queries.sql
Created Jul 12, 2019 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
View psql_useful_stat_queries.sql
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@drbig
drbig / Description.md
Created Jul 11, 2016 — forked from juanje/Description.md
Limit Chrome from eating all the memory and CPU
View Description.md

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
    }
@drbig
drbig / multiple_ssh_setting.md
Created Oct 29, 2015 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
View Fix rxvt-unicode via ssh.md

If tmux fails with the message "open terminal failed: missing or unsuitable terminal: rxvt-unicode-256color".

$ ssh remotemachine mkdir -p .terminfo/r
$ scp /usr/share/terminfo/r/rxvt-unicode* remotemachine:.terminfo/r/
@drbig
drbig / pr.md
Last active Aug 29, 2015 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

View gist:cdccc07e39ae14c59544
[0-9a-zA-Z]{2}
30-39,41-5a,61-7a
a:61 z:7a A:41 Z:5a 0:30 9:39
MSP430 alphanumeric shellcode is hard. There's no way to write to memory,
no word-sized reg-reg operations, and all we have is add/sub/mov and a few conditional jumps.
@drbig
drbig / vl.rb
Created Dec 8, 2014
Pipe compiler errors to it.
View vl.rb
#!/usr/bin/env ruby
# coding: utf-8
require 'smart_colored'
STDIN.each_line do |l|
if m = l.match(%r{((/.*?)+)\:(\d+)})
fn, _, ln = m.captures
next unless File.exist? fn
ln = ln.to_i
puts m.to_s.colored.bold
@drbig
drbig / hello_world.rb
Last active Aug 29, 2015
Hello world with c64asm
View hello_world.rb
hello_world = AsmMacro.new do
jsr 0xe544 # clear
ldx.d 0
label :read
lda.ax :msg
cmp.d 35
beq :finish
jsr 0xffd2 # chrout
inx
jmp :read
@drbig
drbig / gist:4446871
Last active Apr 24, 2017
Pry session over telnet. Minimal and forking (plus a thread for the TCPServer).
View gist:4446871
drbig@swordfish:pts/16 ~/P/pry-tcprepl> cat pry-tcprepl.rb
require 'pry'
require 'pty'
class PryTcpRepl
attr_reader :thread
def initialize(where, host = '127.0.0.1', port = '9123')
@where = where
@host = host