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 / breadcrumbs.rb
Created March 24, 2015 12:07
simple breadcrumbs
module Breadcrumbs
module InstanceMethods
# Append a breadcrumb to the end of the trail
def add_breadcrumb(name, url = nil)
@breadcrumbs ||= []
url = send(url) if url.is_a?(Symbol)
@breadcrumbs << [name, url]
end
end
@placek
placek / ensure.sh
Last active October 20, 2015 10:30
function ensure {
if [[ $? -eq 0 ]]; then
/usr/bin/osascript -e 'display notification "Zajebiście kurwa - działa!"'
say 'Zajebiście kurwa - działa!'
else
/usr/bin/osascript -e 'display notification "Nosz kurwa - coś jebło!"'
say 'Nosz kurwa - coś jebło!'
fi
}
@placek
placek / jsUnit.js
Last active April 25, 2016 17:42
simple unit testsiute for javascript
(function() {
// styles for console
var greenStyle = 'font-weight: bold; color: green;';
var redStyle = 'font-weight: bold; color: red;';
var normalStyle = 'font-weight: none;';
// customizable assertions
var _assertions = {
truth: function(obj) {
if(obj != true) {
@placek
placek / Dockerfile.local.ci
Last active August 14, 2018 08:32
CI/CD with bash/git/docker-compose
FROM ruby:2.5.1-alpine3.7
RUN apk add --no-cache --update build-base linux-headers git postgresql-dev nodejs tzdata
ENV APP_PATH /www
RUN mkdir -p $APP_PATH
WORKDIR $APP_PATH
COPY Gemfile $APP_PATH/Gemfile
@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;