Skip to content

Instantly share code, notes, and snippets.

View jancimajek's full-sized avatar

Jan Majek (Yanchix Ltd) jancimajek

View GitHub Profile
@jancimajek
jancimajek / .gitconfig
Last active August 29, 2015 14:05
Git config
[user]
name = Jan Majek
email = jan.majek@ft.com
[push]
# Pushes only curent branch upstream (as opposed to "matching" (default) which would push all branches)
# default = upstream
[credential]
# helper = osxkeychain
[help]
# If there is only one matching command, it will execute it after X dediseconds (1/10s)
@jancimajek
jancimajek / preg_match_replace_test.php
Last active August 29, 2015 14:16
Test of preg_match replacement
<?php
t(
array(
'www.notft.com',
'ft.com',
'.ft.com',
'x.ft.com.au',
'x.ft.com',
),
@jancimajek
jancimajek / .bashrc
Last active October 12, 2015 01:47
My bashrc file
# System-wide .bashrc file for interactive bash(1) shells.
if [ -z "$PS1" ]; then
return
fi
# Support for GIT branch and status info
# @see http://www.bramschoenmakers.nl/en/node/624
# @see http://denis.tumblr.com/post/71390665/adding-bash-completion-for-git-on-mac-os-x-snow-leopard
if [ -f /etc/git-completion.bash ]; then
. /etc/git-completion.bash
@jancimajek
jancimajek / test.php
Last active November 10, 2015 16:58
PHP Storm 10 quote escaping when copy&paste
<?php
$test = "Copy from here -->" . $foo . "<-- to here and pasting will escape the quotes -->\" . $foo . \"<--";
$test = 'Copy from here -->' . $foo . '<-- to here and pasting will escape the quotes -->\' . $foo . \'<--';
$test = "
lorem ipsum
" . $foo . " // copy this line
\" . $foo . \" // the quotes get escaped on pasting
";
javascript:void(function(){%20var%20divId%20=%20'tmLprDiv'%20+%20Math.floor(Math.random()*1000000);%20var%20inputId%20=%20'tmLprUrl'%20+%20Math.floor(Math.random()*1000000);%20var%20divTag%20=%20document.createElement("div");%20divTag.setAttribute("align","center");%20divTag.id%20=%20divId;%20divTag.style.font%20="9pt%20Verdana";%20divTag.style.margin%20=%20"0px%20auto";%20divTag.style.position%20=%20"absolute";%20divTag.style.top%20=%20"10px";%20var%20left%20=%20(screen.width%20-%20350)%20/%202;%20divTag.style.left%20=%20left%20+%20"px";%20divTag.style.padding%20=%20"10px";%20divTag.style.border%20=%20"3px%20solid%20red";%20divTag.style.background%20=%20"white";%20divTag.style.width%20=%20"350px";%20divTag.style.zIndex%20=%20"999";%20divTag.innerHTML%20=%20"<div%20style='float:right;color:red;font-weight:bold;margin:-5px;%200px%2010px%200px;cursor:pointer;'%20onclick='document.body.removeChild(document.getElementById(\""%20+%20divId%20+%20"\"));'>X</div><br%20style='clear:right;'/><div>Landing%20page%20URL:%
@jancimajek
jancimajek / .eslintrc.js
Last active September 30, 2018 16:11
leveluptuts/React-Testing-For-Beginners
module.exports = {
"parser": "babel-eslint",
"env": {
"jest/globals": true,
"browser": true,
"es6": true
},
"settings": {
"ecmascript": 6,
"jsx": true
@jancimajek
jancimajek / perftest.php
Created February 29, 2012 12:15
Performance test
<?php
set_time_limit(0);
interface PerformanceTest
{
public function test($numberOfIteraftion);
}
class PerformanceTester
@jancimajek
jancimajek / async-error.ts
Last active July 9, 2019 20:45
Async error handling
import debug from 'debug';
import express, { NextFunction, Request, Response } from 'express';
const testRouter = express.Router();
const delay = async (wait: number, label: string) =>
new Promise(resolve => {
debug('yncx:delay:start')({ wait, label });
setTimeout(() => {
debug('yncx:delay:end')({ wait, label });
@jancimajek
jancimajek / rebase-master.sh
Last active October 11, 2019 14:38
Smart rebase master
#!/bin/bash
# GITS: https://gist.github.com/jancimajek/c744675a13da3357a7e9d3959b6b1d3b
echo "[git fetch]"
git fetch
NEEDS_UPDATE=$(git log HEAD..origin/master --oneline | wc -l)
if [ $NEEDS_UPDATE -eq 0 ]
then
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
[ -n "$ZSH_VERSION" ] || {
# ANSI formatting function (\033[<code>m)
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
omz_f() {
[ $# -gt 0 ] || return
IFS=";" printf "\033[%sm" $*
}
# If stdout is not a terminal ignore all formatting
[ -t 1 ] || omz_f() { :; }