Skip to content

Instantly share code, notes, and snippets.

View nicklasos's full-sized avatar
💭
😅

Olkhovyk Mykyta nicklasos

💭
😅
View GitHub Profile
@nicklasos
nicklasos / gist:3702393
Created September 11, 2012 21:55
Moving lines up or down
nnoremap <C-k> mz:m-2<CR>`z==
inoremap <C-j> <Esc>:m+<CR>==gi
inoremap <C-k> <Esc>:m-2<CR>==gi
vnoremap <C-j> :m'>+<CR>gv=`<my`>mzgv`yo`z
nnoremap <C-j> mz:m+<CR>`z==
vnoremap <C-k> :m'<-2<CR>gv=`>my`<mzgv`yo`z
@nicklasos
nicklasos / history_count
Last active December 15, 2015 17:59
Show commands count in shell from history
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
@nicklasos
nicklasos / gist:6412672
Created September 2, 2013 13:06
Random hex color in JavaScript
'#'+Math.floor(Math.random()*16777215).toString(16);
@nicklasos
nicklasos / .gtkrc-2.0
Created September 24, 2013 07:23
Vim Gtk fix
style "no-resize-handle"
{
GtkWindow::resize-grip-height = 0
GtkWindow::resize-grip-width = 0
}
class "GtkWidget" style "no-resize-handle"
style "vimfix" {
@nicklasos
nicklasos / gist:7335688
Last active December 27, 2015 13:49
Create Squared Image (with alpha channel)
<?php
/**
* Create squared image
*
* @param $originalFile file path
* @param null $destinationFile if null - file will be displayed (output)
* @param int $squareSize px
* @return bool
*/
@nicklasos
nicklasos / gist:7336604
Created November 6, 2013 14:08
Reduce image by factor
<?php
/**
* Reduce image by factor
*
* @param string $originalFile file path
* @param string $destinationFile file path
* @param int $factor
* @return bool
*/
@nicklasos
nicklasos / gist:7337140
Last active December 27, 2015 13:59
FFMPG + Video functions
<?php
/**
* Compile video from images with FFMPG
*
* @param string $tmpDirWithImages
* @param string $ext jpg|png...
* @param string $videoFilePath
*/
@nicklasos
nicklasos / gist:7446725
Created November 13, 2013 10:15
Diff between two commands
diff <(identify -verbose 1.jpg) <(identify -verbose 2.jpg)
<?php
function isAjax()
{
return
isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
$_SERVER['HTTP_X_REQUESTED_WITH'] &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
@nicklasos
nicklasos / array_multi_intersect.js
Last active December 30, 2015 08:28
Array intersect.
// array_multi_intersect([[1, 2, 3], [2, 3, 4], [0, 2, 3, 8]]); => [2, 3]
function array_multi_intersect(arr)
{
var firstArr = [],
totalArr = [],
i,
j,
k;
if (arr.length < 2) {