Skip to content

Instantly share code, notes, and snippets.

<snippet>
<content><![CDATA[
<!-- begin $1 -->
<div class="$1">
$2
</div>
<!-- end $1 -->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>di</tabTrigger>
@33r01b
33r01b / get-image-size.js
Created December 18, 2016 16:40 — forked from dimsemenov/get-image-size.js
I was looking for a way to get an image size with JavaScript before it's completely loaded. It's useful, for example, when you want to display it progressively. I've figured out that we can just fire an interval that will run until an image has defined width. Here is how it works:
// detect if naturalWidth property is supported
// getting it is much faster than getComputedStyle()
var supportsNatural = ( "naturalWidth" in (new Image()) ),
imagePath = 'image.jpg',
interval,
hasSize,
onHasSize = function() {
if(hasSize) return;
var naturalWidth = supportsNatural ? img[0].naturalWidth : img.width();
:;while [ $? -eq 0 ];do nc -vlp 8080 -c'(r=read;e=echo;$r a b c;z=$r;while [ ${#z} -gt 2 ];do $r z;done;f=`$e $b|sed 's/[^a-z0-9_.-]//gi'`;h="HTTP/1.0";o="$h 200 OK\r\n";c="Content";if [ -z "$f" ];then ($e $o;(for n in *;do if [ -f "$n" ]; then $e "<a href=\"/$n\">`ls -gh \"$n\"`</a><br>";fi;done););elif [ -f "$f" ];then $e "$o$c-Type: `file -ib \"$f\"`\n$c-Length: `stat -c%s \"$f\"`";$e;$e $f>&2;cat "$f";else $e -e "$h 404 Not Found\n\n404\n";fi)';done
:;while [ $? -eq 0 ];do
nc -vlp 8080 -c'(
r=read;
e=echo;
$r a b c;
z=$r;
while [ ${#z} -gt 2 ]; do
$r z;
done;
f=`$e $b|sed 's/[^a-z0-9_.-]//gi'`;
@33r01b
33r01b / dependecies.json
Created June 12, 2017 18:09 — forked from freearhey/dependecies.json
Полный список зависимостей vue-loader
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"css-loader": "^0.25.0",
"vue-html-loader": "^1.2.3",
"vue-style-loader": "^1.0.0"

Zip excluding specific directories

Exclude .git file and node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/\*

Exclude .git file and files in node_modules directory, but keep node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/**\*
@33r01b
33r01b / gist:268f04cf329137c81362af281c8d2980
Created December 27, 2017 16:44 — forked from realmyst/gist:1262561
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);
@33r01b
33r01b / mysql
Created January 20, 2018 02:10 — forked from edubarbieri/mysql
Mariadb login without sudo
shell$ sudo mysql -u root
[mysql] use mysql;
[mysql] update user set plugin='' where User='root';
[mysql] flush privileges;
[mysql] \q
@33r01b
33r01b / importCSV.sql
Created January 29, 2018 13:59 — forked from shalaby/importCSV.sql
Import csv to mariadb
mysql -uroot -p --local-infile
LOAD DATA LOCAL INFILE "file.csv"
INTO TABLE db.table
FIELDS TERMINATED BY ','
ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
@33r01b
33r01b / redid-cannot-allocate-memory.txt
Created April 28, 2018 09:59 — forked from fernandoaleman/redis-cannot-allocate-memory.txt
redis bgsave failed because fork Cannot allocate memory
Modify /etc/sysctl.conf and add
vm.overcommit_memory=1
Then restart sysctl by:
$ sudo sysctl -p /etc/sysctl.conf