Skip to content

Instantly share code, notes, and snippets.

View manfromanotherland's full-sized avatar
🤏

Edmundo Santos manfromanotherland

🤏
View GitHub Profile
@manfromanotherland
manfromanotherland / sticky-header-ie8.js
Last active August 29, 2015 13:55
JS, jQuery: Sticky element on top. #snippet
// Sticky Element on scroll
var sticky = $('.selector');
var top = sticky.offset().top - parseFloat(sticky.css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
var y = $(this).scrollTop();
y >= top ? sticky.addClass('fixed') : sticky.removeClass('fixed');
});
@manfromanotherland
manfromanotherland / chmod-directories.sh
Created March 31, 2014 14:28
SHELL: CHMOD recursively on directories using find
find -name '*' -type d -exec chmod 0755 {} \;
@manfromanotherland
manfromanotherland / chmod-files.sh
Created March 31, 2014 14:29
SHELL: CHMOD recursively on files using find
find . -type f -exec chmod 0644 {} \;
@manfromanotherland
manfromanotherland / .gitignore_global
Last active August 29, 2015 14:00
GIT: .gitignore_global #snippet
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@manfromanotherland
manfromanotherland / viewport-size.js
Last active August 29, 2015 14:02
JS: Show viewport size for easy responsive development (no need to have the dev tools open).
// Show viewport size
document.addEventListener('DOMContentLoaded', function() {
document.body.insertAdjacentHTML('afterend', '<div id="viewport-size" style="position:fixed; top:0; right:0; z-index: 9999; padding:0 .5em; color:#333; background:rgba(255,255,255,.75); font: 14px/1.8em Monaco, Inconsolata, Ubuntu Mono, Courier New, monospaced;"></div>');
showViewportSize();
});
window.onresize = function() { showViewportSize(); }
function showViewportSize() {
var body = document.body,
@manfromanotherland
manfromanotherland / idiomatic.css
Last active August 29, 2015 14:03
CSS: Guidelines for good CSS, heavily based on idiomatic.css.
/* ==========================================================================
Section comment block
========================================================================== */
/* Sub-section comment block
========================================================================== */
/**
* Short description using Doxygen-style comment format
*
@manfromanotherland
manfromanotherland / looping.html
Created June 28, 2014 02:52
HTML; JavaScript: Loop infinito para sacanear os amiguinhos; Apenas uma linha de HTML.
<!doctype html><title>Looping…</title><script>window.history.go(0);</script>
@manfromanotherland
manfromanotherland / test-connection.php
Created July 3, 2014 18:35
PHP: How to test connection to database #snippet
<?php
$mysqli = @new mysqli('host', 'user', 'password', 'dabatase');
if ($mysqli->connect_errno) {
die('Connect Error: ' . $mysqli->connect_errno);
}
echo "Connected successfully"
?>
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Ensure user-installed binaries take precedence
export PATH=/usr/local/bin:$PATH
export PATH="/usr/local/mysql/bin:$PATH"
export PATH="/usr/local/git/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:$PATH"
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc