Skip to content

Instantly share code, notes, and snippets.

@morsdyce
morsdyce / what-forces-layout.md
Created September 28, 2015 10:42 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@morsdyce
morsdyce / if_env.js
Created September 23, 2015 16:21
If-env angular directive
export function ifEnv(ENV) {
return {
restrict: 'A',
priority: 600,
transclude: 'element',
terminal: true,
link: function(scope, element, attrs, ctrl, $transclude) {
if (ENV === attrs.ifEnv) {
$transclude(function (clone) {
element.after(clone);
@morsdyce
morsdyce / gist-reveal.it-slides.html
Last active August 29, 2015 14:25 — forked from ryanj/gist-reveal.it-slides.html
Use Docker, gist.github.com, and Reveal.js to produce themed slideshow presentations for conferences and / or hackathons
<section data-background-transition='zoom' data-transition='concave' data-background='http://ryanjarvinen.com/presentations/shared/img/broadcast_reveal_dark.png' data-state='blackout'>
<h2>Gist-Powered</h2>
<h1>Reveal.js</h1>
<h2>Slideshow Presentations</h2>
<p class='fragment'><small><a class='fragment' href='http://github.com/ryanj/gist-reveal.it'>github.com/ryanj/gist-reveal.it</a>
<br/> <a class='fragment' href='https://registry.hub.docker.com/u/ryanj/gist-reveal.it/'>registry.hub.docker.com/u/ryanj/gist-reveal.it</a></small></p>
</section>
<section data-background-transition='zoom' data-transition='linear'>
<h2>Embed</h2>
<iframe webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" sandbox="allow-forms allow-scripts allow-popups allow-same-origin allow-pointer-lock" data-src="https://regex101.com/r/sB4uZ3/1"></iframe>
@morsdyce
morsdyce / .aliases
Created July 6, 2015 11:08
OSX Bluetooth Fix alias #osx #bluetooth #alias
#restart the bluetooth controller
restartBluetooth() {
sudo -v
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
}
alias bluetooth-reset=restartBluetooth
@morsdyce
morsdyce / analyticsController.js
Last active August 29, 2015 14:23
Google social sign in directive #angular #directive #google #social
$scope.$on('event:google-plus-signin-success', function (event, authResult) {
// Send login to server or save into cookie
$scope.showLoader = true;
if (authResult && authResult['code']) {
$http.post('/setup/authorize', { code: authResult['code'] }).then(function () {
$http.get('/setup/getaccounts').then(function (response) {
$scope.signedIn = true;
$scope.data.accounts = response.data;
$scope.showLoader = false;
});
@morsdyce
morsdyce / forward.sh
Created May 7, 2015 11:10
forward port on OSX yosemite #osx #firewall #forwarding
echo "
rdr pass inet proto tcp from any to any port 25 -> 127.0.0.1 port 1025
" | sudo pfctl -ef -
@morsdyce
morsdyce / preserving-history.md
Last active August 29, 2015 14:19 — forked from dannyroberts/preserving-history.md
move and rename directories in git while preserving history #git

Did you know...

...that git lets you move and rename whole directories while preserving the git history of those files?

If you run

git read-tree --prefix=$NEW_PATH -u master:$OLD_PATH
rm -rf $OLD_PATH
# ...you probably want to change some imports...
git commit -m $MESSAGE
@morsdyce
morsdyce / snippets.md
Last active August 29, 2015 14:17 — forked from sanusart/snippets.md
shell snippets and functions #shell #bash #sh

Inform with message

Use: message "Informing you about something"

message () {
    printf "\n";
    printf "\e[30;48;5;82m ${1} \e[0m "
    printf "\n";
}

Při prvním pokusu na mě ufw při pokusu o povolení vyplivl hlášku:

root@vps:~# ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
ERROR: problem running ufw-init
modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/2.6.32-042stab093.4/modules.dep.bin'
modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/2.6.32-042stab093.4/modules.dep.bin'
modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/2.6.32-042stab093.4/modules.dep.bin'
iptables-restore: line 4 failed
iptables-restore: line 77 failed
@morsdyce
morsdyce / index.js
Created August 6, 2014 17:41
why people hate javascript #js
function profiles(callback) {
var profileList = [];
gapi.client.analytics.management.webproperties.list({
accountId: '~all'
}).execute(function (webProperties) {
for (var i = 0, limit = webProperties.items.length; i < limit; i++) {
var webProperty = webProperties.items[i];