Skip to content

Instantly share code, notes, and snippets.

View pmalek's full-sized avatar
👋
Go and Open Source enthusiast

Patryk Małek pmalek

👋
Go and Open Source enthusiast
View GitHub Profile
@pmalek
pmalek / android_hide_status_bar.java
Created April 23, 2014 19:20
Hide status bar in Android
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
@pmalek
pmalek / count_pages.sh
Created January 20, 2014 15:04
Bash script to count pages of pdfs in current directory
#!/bin/bash
sum_pages=0
for file in *.pdf ; do
cur_pages=$(pdfinfo $file | awk '/Pages/{print $2}')
echo "pdf: $file has $cur_pages pages."
sum_pages=$(( sum_pages + cur_pages))
done
echo "All pdf files in this directory have $sum_pages pages."
func httpClientForCert(t *testing.T, caData, certData, keyData []byte) *http.Client {
cert, err := tls.X509KeyPair(certData, keyData)
require.NoError(t, err)
caCertPool := x509.NewCertPool()
require.True(t, caCertPool.AppendCertsFromPEM(caData))
// Setup HTTPS client
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12,
@pmalek
pmalek / shared_tmux.sh
Created February 9, 2018 15:07
Tmux read only shared session setup
#/bin/bash
SHARED_SESSION_FILE=/tmp/shared_tmux_session
set -e
tmux -2 -S ${SHARED_SESSION_FILE} new -s guest -d
sudo chown $(whoami) ${SHARED_SESSION_FILE}
sudo chmod 777 ${SHARED_SESSION_FILE}
@pmalek
pmalek / RectangleConfig.json
Created April 22, 2022 09:53
RectangleConfig.json
{
"defaults" : {
"almostMaximizeWidth" : {
"float" : 0
},
"curtainChangeSize" : {
"int" : 0
},
"allowAnyShortcut" : {
"bool" : false
@pmalek
pmalek / install_gcc.sh
Last active January 15, 2019 12:00
gcc installation script for Centos6.6 (probably can be used for other distributions). It also installs dependencies like mpc, mpfr and gmp !NOTE: As of now this only works for installations with PREFIX=/usr/local
#!/bin/bash
LOGFILE=/tmp/gcc_install.log
# $1 - package name
errorIf(){
if [ $? -ne 0 ]; then
echo "Something was wrong with $1"
exit 1
fi
@pmalek
pmalek / new_gist_file
Created September 26, 2016 11:12
tcpdump from a remote machine to fifo on local machine and read via wireshark
mkfifo fifo
TCPHOST="10.0.0.1"; while true ; do \
ssh $TCPHOST 'tcpdump -s 0 -U -n -w - "!igmp && !arp && !rarp && !(host 224.0.0.1) && !(port 22) && !(port 67) && !(port 53) && !(port 123) && !(port 5353) && !(port 137)"' > fifo; \
done
# on another console
wireshark -k -i fifo
package main
import (
"crypto/rand"
"crypto/rsa"
"encoding/json"
"fmt"
"log"
jose "gopkg.in/square/go-jose.v2"
)
func main() {
@pmalek
pmalek / parse.go
Last active October 6, 2017 12:25
really quick and dirty stackoverflow jobs feed parsing with Go
package main
import (
"encoding/xml"
"fmt"
"io"
"os"
"regexp"
"strings"
"time"
@pmalek
pmalek / profile_vim
Last active August 17, 2017 11:43
vim profiling (e.g. for finding slow plugins)
http://stackoverflow.com/a/12216578/675100
:profile start profile.log
:profile func *
:profile file *
" At this point do slow actions
:profile pause
:noautocmd qall!
// --------------------