Skip to content

Instantly share code, notes, and snippets.

View Narayon's full-sized avatar
🛠️

Rui Barbosa Narayon

🛠️
View GitHub Profile
@Narayon
Narayon / osx_bootstrap.sh
Last active September 4, 2022 21:39 — forked from codeinthehole/osx_bootstrap.sh
Script to install stuff I want on a new OSX machine
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Newton (app store)
@Narayon
Narayon / config_mac.md
Created March 6, 2017 02:58
Config MacOs machine

macOS

Custom recipe to get macOS running from scratch, setup applications and (WordPress) developer environment. I use this gist to keep the steps required to have a functioning system after a semi-annual fresh install.

Software

Browsers

System

@Narayon
Narayon / check-default-lang.php
Last active April 9, 2018 22:09
PHP: check browser default language
<?php
function prefered_language( $available_languages, $http_accept_language = 'auto' ) {
if ( 'auto' == $http_accept_language ) {
// $http_accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$http_accept_language = isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
}
preg_match_all( '/([[:alpha:]]{1,8})(-([[:alpha:]|-]{1,8}))?' . '(\s*;\s*q\s*=\s*(1\.0{0,3}|0\.\d{0,3}))?\s*(,|$)/i', $http_accept_language, $hits, PREG_SET_ORDER );
$bestlang = $available_languages[0];
@Narayon
Narayon / wp-query-ref.php
Created February 13, 2017 15:54
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference.
*
* All credits go to luetkemj. Thanks!
*
* @author luetkemj <luetkemj@gmail.com>
* @author s3rgiosan <me@s3rgiosan.com>
*
* @see http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
@Narayon
Narayon / font_face_helper.css.scss
Created July 30, 2015 12:15 — forked from simaovergalho/font_face_helper.css.scss
SCSS: helper for font-face
@each $font-face in
"MyFont-Regular",
"MyFont-Bold",
"MyFont-Medium" {
@font-face {
font-family: $font-face;
font-style: normal; font-weight: normal;
src: font-url('#{$font-face}.eot');
src: font-url('#{$font-face}.eot?#iefix') format('embedded-opentype'),
@Narayon
Narayon / gist:556f42e012b2645b7ae9
Created October 8, 2015 09:09
CSS: Text Display Optimization
html {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}
@Narayon
Narayon / Javascript-jQuery_replacer
Last active April 8, 2018 02:52 — forked from simaovergalho/Javascript-jQuery_replacer
Javascript: Stop Using jQuery
<div class="container">
<ul>
<li id="pink">Pink</li>
<li id="salmon">Salmon</li>
<li id="blue">Blue</li>
<li id="green">Green</li>
<li id="red">Red</li>
</ul>
</div>
@Narayon
Narayon / analyse_watchers.js
Last active April 8, 2018 02:52 — forked from DTFagus/analyse_watchers.js
Bookmarklet to analyse angular watchers
javascript: (function() {
var root = angular.element(document.getElementsByTagName('html'));
var watchers = [];
var attributes = [];
var attributes_with_values = [];
var elements = [];
var elements_per_attr = [];
var scopes = [];
@Narayon
Narayon / jQuery-preloadFunction
Last active April 8, 2018 02:52 — forked from simaovergalho/jQuery-preloadFunction
jQuery: Preload Images, CSS and JS
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
@Narayon
Narayon / random.js
Last active April 8, 2018 02:52 — forked from kerimdzhanov/random.js
Javascript: random number in a specific range
// MIT License
// @return {float} a random number between min and max
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
// @return {integer} a random int between min and max
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);