Skip to content

Instantly share code, notes, and snippets.

View placek's full-sized avatar

Paweł Placzyński placek

  • BinarApps
  • Łódź Poland
View GitHub Profile
@placek
placek / example.sh
Created July 29, 2013 11:09
Shell useful hacks
# searching through files content in current directory, not in .git subdir
find . -type f -not -path ".git" -exec grep --color -Hn "hello" {} \;
# VoIP
# reciever
nc -l -p 12345 | aplay
# sender
aplay | nc 192.168.0.2 12345
# view the file while it is still updating
@placek
placek / ruby_ctags.rb
Last active September 17, 2015 08:50
ctags generator for ruby project using bundle
#!/usr/bin/env ruby
require 'bundler'
class CTagsService
def call
trap_int_signal
system(command)
system(['mv ', tmpfile, ' .git/tags'].join)
end
@placek
placek / captcha_image.rb
Last active July 20, 2017 07:42
simple captcha image generator in rmagick
require 'rmagick'
module Captcha
Image = Struct.new :text, :width, :height, :blur, :wave_length, :wave_amplitude do
def image
captcha_image = Magick::Image.new(width, height)
captcha_text = Magick::Draw.new
captcha_text.annotate(captcha_image, 0, 0, 0, height / 10, text) do
self.gravity = Magick::CenterGravity
self.pointsize = 60
@placek
placek / openssl.sh
Last active December 11, 2022 09:58
OpenSSL cheat sheet
# openssl version
openssl version
# openssl commands
openssl list-standard-commands
# ca - create certificate authorities
# dgst - compute hash functions
# enc - encrypt/decrypt using secret key algorithms (it is possible to generate using a password or directly a secret key stored in a file)
# genrsa - generate a pair of public/private key for the RSA algorithm
# password - generation of “hashed passwords”
@placek
placek / HowToOTGFast.md
Created October 15, 2019 13:28 — forked from gbaman/HowToOTGFast.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

###Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)
More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH is

@placek
placek / yubi.nix
Created December 7, 2020 08:12
nix ISOs
# yubikey-installer.nix
{ nixpkgs ? <nixpkgs>, system ? "x86_64-linux" } :
let
config = { pkgs, ... }:
with pkgs; {
imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-graphical-kde.nix> ];
boot.kernelPackages = linuxPackages_latest;
dd if=/dev/zero of=/swap_file bs=1G count=16 # create a zero-filled 16GB swap file
fallocate -l 16G /swap_file # alternative, faster way
chmod 600 /swap_file # chmod
mkswap /swap_file # make swap partition on file
swapon /swap_file # apply swap file as a swap partition
@placek
placek / ctags
Created October 26, 2022 14:00
git hooks ctags
#!/usr/bin/env bash
set -eux
root="$(git rev-parse --show-toplevel)"
dir="$root/$(git rev-parse --git-dir)"
trap 'rm -f "$dir/$$.tags"' EXIT
hasktags -cxRf "$dir/$$.tags" "$root"
@placek
placek / .vimrc
Last active July 25, 2023 13:40
Some simple vimrc that makes VIM into an IDE (kind of).
""""""""""""""""""""""""""""""""" ESSENTIALS """""""""""""""""""""""""""""""""""
filetype plugin indent on " for plugins to load correctly
syntax enable " turn on syntax highlighting
set nocompatible " don't try to be vi compatible
"""""""""""""""""""""""""""""""""" SETTINGS """"""""""""""""""""""""""""""""""""
" interface
set cmdheight=1 " set command line height
set cursorline " line at current cursor position
set foldcolumn=1 " always show at least one cahr in fold column
@placek
placek / README.md
Last active July 26, 2023 19:35
TODO file as a support while working on feature branch

Work with TODO file

This gist presents a methodology of working on a task on feature branch using a TODO file as a support.

How?

Here is a possible scenario:

  1. Turn on verbose commits option: git config --local commit.verbose true. It's really awesome!
  2. Take a task from your project management tool.
  3. cd to repo.
  4. Checkout to a main branch on the repo: git checkout master.
  5. Pull the most recent changes from origin: git pull origin master.