Skip to content

Instantly share code, notes, and snippets.

@radmen
radmen / gist:22139e20d0bdb2f9d95bb98f093a521d
Last active March 6, 2018 08:34
Promise/Future Result Maybe object!

The task

  1. get something from a remote site (loadPage())
  2. find specific element (findElement())
  3. grab and parse contents as JSON (extractJson())

stage 1

Easy way: grab page and return result

@radmen
radmen / .bash_aliases
Created February 8, 2016 10:34
Include `.env` file and connect to MySQL
# connect to mysql using .env file
env-mysql ()
{
yellow=$(tput -Txterm setaf 3)
lt_blue=$(tput -Txterm setaf 6)
reset=$(tput -Txterm sgr0)
if [ -f .env ]; then
. .env
fi
@radmen
radmen / README.md
Last active December 16, 2015 12:49
Bypass BZWBK masked password input scriptlet

Ten skrypt w prosty sposób obchodzi maskowanie hasła dla centrum24.pl (BZWBK).

  • Dodaj do zakładek zawartość scriptlet.js
  • Przejdź na stronę logowania - centrum24.pl
  • Wpisz numer NIK, wciśnij Dalej
  • Uruchom skryptozakładkę
  • Pod polem do wpisania PINu pojawi się nowy textbox - wpisz w nim swój pin i wciśnij ENTER
  • Twoje hasło powinno zostać wpisane w odpowiednie pola
  • Wciśnij button Dalej
@radmen
radmen / gist:5420036
Created April 19, 2013 12:32
L4 - Loading session from query param
<?php
$id = Input::get('SSID');
Session::save();
Session::setId($id);
unset($_SESSION);
Session::start();
@radmen
radmen / vimrc
Created February 27, 2013 13:59
Simple vim command to turn off Gdiff. Works only when Gdiff buffer is focused.
" Simple way to turn off Gdiff splitscreen
" works only when diff buffer is focused
if !exists(":Gdiffoff")
command Gdiffoff diffoff | q | Gedit
endif
@radmen
radmen / qitlab-quickfix.md
Last active December 13, 2015 19:09
Quickfix for Gitlab 500 error on creating user.

On some special situations (probably bad server config) Gitlab instead of queuing email throws 500 error.
To fix it You can force Gitlab to send emails immediately.

Just run this script inside gitlab installation folder (normally it's /home/gitlab/gitlab):

grep -r "Notify.delay" app/* | cut -d":" -f1 | xargs sed -i.bak -e"s/Notify\.delay\.\(.*\)/Notify.\1.deliver/"
@radmen
radmen / .htaccess
Created January 2, 2013 21:56
Wordpress lazy static site generator
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI} -f
RewriteRule ^(.*)$ /static/$1 [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}/index.html -f
RewriteRule ^(.*)$ /static/$1/index.html [L,QSA]
RewriteRule ^index\.php$ - [L]
@radmen
radmen / stylebot.json
Created October 4, 2012 20:16
Stylebot config
{"www.youtube.com":{"_enabled":true,"_rules":{"div.comments-section":{"display":"none"}}},"www.trojmiasto.pl":{"_enabled":true,"_rules":{"div.opinions-wrap.opinions-tree":{"display":"none"}}},"wyborcza.pl":{"_enabled":true,"_rules":{"#article_toolbar":{"display":"none"}}},"*":{"_enabled":true,"_rules":{}},"gazeta.pl":{"_enabled":true,"_rules":{"#article_toolbar":{"display":"none"}}}}
@radmen
radmen / gitlab.sh
Created August 8, 2012 09:52
Gitlab init.d script (without using nginx and unicorn)
#! /bin/bash
### BEGIN INIT INFO
# Provides: gitlab
# Required-Start: $local_fs $remote_fs $network $syslog redis-server
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitLab git repository management
# Description: GitLab git repository management
### END INIT INFO
@radmen
radmen / current_route.php
Created October 7, 2015 09:36
Lument getCurrentRoute()
<?php
$verbs = 'GET|POST|PUT|DELETE|PATCH';
$routeToRegex = function ($string) use ($verbs) {
$string = preg_replace("/^({$verbs})/", '', $string);
$string = preg_replace('/\{\w+\}/', '\w+', $string);
$string = preg_replace('/\{(\w+):(.+?)\}/', '\2', $string);
return '#^'.$string.'$#';
};