Skip to content

Instantly share code, notes, and snippets.

View aarongarciah's full-sized avatar
💻
Solving problems so you don't have to

Aarón García Hervás aarongarciah

💻
Solving problems so you don't have to
View GitHub Profile
@aarongarciah
aarongarciah / system-date.sh
Created July 13, 2016 10:41
Update unix system date
sudo ntpdate -u ntp.ubuntu.com
@aarongarciah
aarongarciah / debounce.js
Created June 2, 2016 22:08
Debounce function
// https://davidwalsh.name/javascript-debounce-function
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
@aarongarciah
aarongarciah / sass-functions.md
Last active May 19, 2016 11:42
Some useful Sass functions

###Strip units

@function strip-unit($number) {
  @if type-of($number) == 'number' and not unitless($number) {
    @return $number / ($number * 0 + 1);
  }

  @return $number;
}
@aarongarciah
aarongarciah / stop-scrolling.js
Created April 28, 2016 10:38
Detect stop scrolling
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
// Do something
console.log('Haven\'t scrolled in 250ms!');
}, 250));
@aarongarciah
aarongarciah / what-forces-layout.md
Created March 7, 2016 11:07 — 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()
@aarongarciah
aarongarciah / sanfrancisco-font.css
Created March 7, 2016 10:37
San Francisco Web Font
/**
* http://applemusic.tumblr.com/
* https://jsfiddle.net/xq56dmrh/
*/
/** Ultra Light */
@font-face {
font-family: "San Francisco";
font-weight: 100;
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-ultralight-webfont.woff");
/***** Selector though hack ******/
/* Only for IE6 and below */
* html div { color: gray }
/* Only for IE7 */
*:first-child+html div { color: gray }
@aarongarciah
aarongarciah / .bash_profile
Last active January 23, 2016 18:38
Custom terminal commands in OSX. Restart the terminal and the changes will take effect.
alias w='cd ~/www'
alias gs='gulp serve'
@aarongarciah
aarongarciah / MY_Config.php
Created January 23, 2016 18:38
Fix base_url in Codeigniter 3.0 when working on local server.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Config extends CI_Config {
public function __construct()
{
$this->config =& get_config();
// Set the base_url automatically if none was provided