Skip to content

Instantly share code, notes, and snippets.

@piotrd
piotrd / hide_slack_top_nav.js
Created August 18, 2020 16:19
When using Slack in a browser, you can hide the top nav bar by creating a bookmark with this code snippet and clicking it once Slack is loaded in a tab:
javascript:var _A=function(){var i,x;x=document.getElementsByClassName('p-top_nav');for(i=0;i<x.length;i++)x[i].style.display='none';x=document.getElementsByClassName('p-client--ia-top-nav');for(i=0;i<x.length;i++){x[i].style.gridTemplateRows='auto min-content';x[i].style.gridTemplateAreas='"p-client__workspace" "p-client__banners"';}};_A();
@piotrd
piotrd / word_count.js
Created November 2, 2015 13:42
Word counter
function wc(value) {
return value.trim().replace(/\s+/gi, ' ').split(' ').length;
}
@piotrd
piotrd / svg-png.css
Last active October 11, 2015 15:42
Serving SVG to browsers that support it and PNG to the others
/* Technique of serving SVG to browsers that support it and PNG to the others */
background: url(icon.png) no-repeat 50% 50%, #ccc);
background: url(icon.svg) no-repeat 50% 50%, -webkit-linear-gradient(to bottom, #ccc, #ccc);
background: url(icon.svg) no-repeat 50% 50%, linear-gradient(to bottom, #ccc, #ccc);
/* background-size for WebKit (otherwise it may distort the SVG) */
background-size: 1.2em auto;
-webkit-background-size: 1.2em;
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click
* https://gist.github.com/justinmc/d72f38339e0c654437a2
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
angular.module('yourapp').directive('anchorSmoothScroll', function($location) {
'use strict';
return {
restrict: 'A',
sudo python -m smtpd -n -c DebuggingServer localhost:25
@piotrd
piotrd / gist:8a89993a475a88c0d298
Last active August 29, 2015 14:03
MySQL cheatsheet
-- Updating MySQL user host
UPDATE mysql.user SET host = '%' WHERE host = 'localhost' AND user = 'username';
UPDATE mysql.db SET host = '%' WHERE host = 'localhost' AND user = 'username';
FLUSH PRIVILEGES;
@piotrd
piotrd / Vim cheatsheet
Last active December 25, 2015 19:09
Vim cheatsheet
# Vim cheatsheet
### Duplicating a line
yy p #paste after
yy P #paste before
### Getting and setting file higlight
:set filetype #get