Skip to content

Instantly share code, notes, and snippets.

View ivanbogomoloff's full-sized avatar

ivan ivanbogomoloff

View GitHub Profile
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
@ivanbogomoloff
ivanbogomoloff / gist:ec3010454873f3fbe04b
Created September 26, 2015 10:02 — forked from Joncom/gist:e8e8d18ebe7fe55c3894
Check if two line segments intersect
// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345
function line_intersects(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y) {
var s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x;
s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x;
s2_y = p3_y - p2_y;
var s, t;
@ivanbogomoloff
ivanbogomoloff / gist:c6fd28af0623f9e22fbf
Last active February 1, 2016 14:42
ttet builded blocks
/**
* Инвертирования бинарного массива
* @returns {Array}
*/
Array.prototype.binInverse = function() {
var ar = this;
var newar = new Array(ar.length - 1);
for(var i = 0; i < ar.length; i++)
{
if (typeof (ar[i]) == 'object') {
@ivanbogomoloff
ivanbogomoloff / PS1 in terminal
Created October 17, 2017 08:18
PS1 in terminal
PS1="\033[01;32m[\w]\[\033[00m\] \D{%T}\$(__git_ps1)$ "
//will produce [/your/directory] 11:15:34 (branchname)$
while true; do date; ps aux|grep php|wc -l; sleep 1;done
@ivanbogomoloff
ivanbogomoloff / functions.php
Last active November 1, 2017 09:06
Wordpress override login, logout urls and remove wp login php
//Cop wp-login.php into any_login_admin_page.php
//then delete wp-login.php
//then write this...
add_filter('login_url', function($login_url, $redirect = '', $force_reauth = false) {
$login_url = site_url( '/any_login_admin_page.php', 'login' );
if ( ! empty( $redirect ) ) {
$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
}
if ( $force_reauth ) {
$login_url = add_query_arg( 'reauth', '1', $login_url );
@ivanbogomoloff
ivanbogomoloff / gist:5cf8b5ef42ab42a1ca164e3bc6fd0def
Last active January 16, 2018 13:49
Php sum from two string that over 65535 int
<?php
$str = '11000000000000000000000 33';
//echo 11000000000000000000000+33 will produce 1.1E+22983411000000000000000000030
//but with this code you will get 11000000000000000000033
$e = explode(" ", $str);
$num1 = $e[0];
$num2 = $e[1];
//100
// 10
@ivanbogomoloff
ivanbogomoloff / Free mem
Created February 13, 2018 10:21
i3wm free memory and status modify script
###File name is free_m
mem_free()
{
TYPE=free
awk -v type=$TYPE '
/^MemTotal:/ {
mem_total=$2
}
/^MemFree:/ {
xrandr --output VGA1 --right-of HDMI1
@ivanbogomoloff
ivanbogomoloff / gist:50a0798e4a46f6d585b616c58879962a
Created February 14, 2018 04:21
i3lock 2 monitor tiled screen
bindsym $mod+Shift+h exec i3lock -i gitp.pb.pngng -t -p default -n