Skip to content

Instantly share code, notes, and snippets.

View Narayon's full-sized avatar
🛠️

Rui Barbosa Narayon

🛠️
View GitHub Profile
@Narayon
Narayon / gist:ecfe2abecf76debe9937
Last active April 8, 2018 02:52 — forked from jennimckinnon/functions.php
Wordpress: Add Google Font
function google_fonts() {
$query_args = array(
'family' => 'Open+Sans:400,700|Oswald:700'
'subset' => 'latin,latin-ext',
);
wp_register_style( 'google_fonts', add_query_arg( $query_args, "//fonts.googleapis.com/css" ), array(), null );
}
add_action('wp_enqueue_scripts', 'google_fonts');
@Narayon
Narayon / PHP-normalize_global_path
Last active April 8, 2018 02:52 — forked from simaovergalho/PHP-normalize_global_path
PHP: global vars for normalizing the ROOT and HTTP paths of the app.
<?php
// a.php: assuming this included everywhere at very first line
// and located in root directory
// preferable, define a constant instead of variable, cos it
// may used in functions directly without "global $ROOT";
// to use for "include"
define('ROOT', __DIR__); // for PHP >= 5.3
define('ROOT', realpath(dirname(__FILE__))); // for PHP < 5.3
// to use for "src,href"
@Narayon
Narayon / gist:6c56a8591c7cbb2454ab
Last active April 8, 2018 02:52 — forked from jameskoster/functions.php
WooCommerce: dequeue css (2.1+)
// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] ); // Remove the gloss
unset( $enqueue_styles['woocommerce-layout'] ); // Remove the layout
unset( $enqueue_styles['woocommerce-smallscreen'] ); // Remove the smallscreen optimisation
return $enqueue_styles;
}
// Or just remove them all in one line
@Narayon
Narayon / keybase.md
Created November 21, 2017 12:29
Keybase Auth

Keybase proof

I hereby claim:

  • I am narayon on github.
  • I am narayon (https://keybase.io/narayon) on keybase.
  • I have a public key ASAInUGjO1eaI4pdabI7CM6B2AZpIWk-kPC3n-v3uuRHTQo

To claim this, I am signing this object:

@Narayon
Narayon / get-template-page-url.php
Created July 5, 2017 09:50
WP - Get link of page with specific template
<?php
function get_template_page_url( $template_name ) {
$url = null;
$pages = new \WP_Query( array(
'post_type' => 'page',
'meta_key' => '_wp_page_template',
'meta_value' => $template_name,
) );
@Narayon
Narayon / vagrant-scp
Last active April 8, 2018 01:53 — forked from geedew/vagrant-scp
Copying files from and to a Vagrant VM
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | grep -v '^Host ' | awk -v ORS=' ' 'NF{print "-o " $1 "=" $2}'`
# copy from host to vagrant
# scp ${OPTIONS} $FILE v:$PATH
@Narayon
Narayon / gulpfile.js
Created August 25, 2016 10:05 — forked from jadsalhani/gulpfile.js
Ionic Tutorial
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var uglify = require('gulp-uglify');
var mainBowerFiles = require('main-bower-files');
@Narayon
Narayon / gist:5f2cbb34594665abf3c81cc56eb7eed4
Created April 22, 2016 19:06
AngularJS 1.x Performance Tips
In general, keep the digest cycle slim, avoiding the creation of watchers, when possible.
Some tips:
- ng-bind instead of {{expressions}}
- use bind once: ng-bind="::expression" or {{::expression}}
- avoid ng-repeat, but if necessary, use track by ...
- use small directives, with new or nested scope, instead of a monolithic scope
- use local events and $digest/$apply(when needed), to prevent running the digest cycle globally, for every event
- use $digest instead of $apply, when changes only affect children
- don't use filters in the DOM, use pre filtered data instead
- don't use true/false DOM logic in the controller
@Narayon
Narayon / block-scroll.css
Last active April 8, 2018 01:53 — forked from davidgilbertson/block-scroll.css
Don't resize the body when you open a modal
/* the page should not change width as content is loaded */
body {
overflow-y: scroll;
}
/* block scrolling without losing the scroll bar and shifting the page */
/* add this class when a modal is open */
body.block-scroll {
overflow: hidden;
overflow-y: scroll !important;
@Narayon
Narayon / pubsub.js
Created February 24, 2017 19:17
Angular v1 Pub-Sub
// an example channel service that lets consumers
// subscribe and publish for nuclear reactor meltdowns
var CoreReactorChannel = function($rootScope) {
// local constants for the message ids.
// these are private implementation detail
var ELEVATED_CORE_TEMPERATURE_MESSAGE = "elevatedCoreMessage";
// publish elevatedCoreTemperature