Skip to content

Instantly share code, notes, and snippets.

View adriancbo's full-sized avatar
🎯
Focusing

Adrian Carballo adriancbo

🎯
Focusing
View GitHub Profile
@adriancbo
adriancbo / nginxsite.com
Created August 22, 2014 03:59
In your sites-available -> sites-enabled folder respective website config file
server {
listen portnumber;
server_name ip_address;
location / {
root /var/www/mywebsite.com;
index index.html index.htm;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd; #For Basic Auth
}
}
@adriancbo
adriancbo / Nginx Basic Auth Instructions - Ubuntu
Last active August 29, 2015 14:05
Steps for simple nginx .htpasswd auth - Ubuntu
1. Get apache utils:
sudo apt-get install apache2-utils
2. Create .htpasswd file and make up a username (one-liner)
sudo htpasswd -c /etc/nginx/.htpasswd exampleuser
3. You will be prompted to enter a new password
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
}
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
}
@adriancbo
adriancbo / functions.php
Created September 1, 2014 21:33 — forked from rileypaulsen/functions.php
Add Advanced Custom Fields Fields to the WP REST API - Awesome!
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
}
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
}
@adriancbo
adriancbo / gist:4c9f1b21ffc7bb2e43f6
Created September 15, 2014 03:51
Hardware Accelerate SCSS Mixin
@mixin hw-accelerate {
-webkit-transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
transform: translate3d(0, 0, 0);
backface-visibility: hidden;
}
@adriancbo
adriancbo / gist:f87b2547d0f78aa8038a
Created September 25, 2014 12:42
NodeJS Process File then Output to File
var fs = require('fs');
fs.readFile('cats.txt', function(err, data) {
if(err) throw err;
var array = data.toString().split("\n");
var lookup = array.map(function(line) {
var significant = line.split('. ')[1].split(' (');
return { category: significant[0], id: significant[1].split(')')[0] };
var addNth = (function () {
var len, i = 0, className, prevIndexes = [];
function isNew (el) {
return el.hasClass(className); // removed unnecessary parenthesis
}
return function (selector, html, nth, className ) {
var els = $( selector );
className = className || 'test';
@adriancbo
adriancbo / gist:cbd96b1ec6eec715aba3
Created February 7, 2015 15:38
Detect Vendor Prefix
var styles = window.getComputedStyle(document.documentElement, '');
function getWatchers(root) {
root = angular.element(root || document.documentElement);
var watcherCount = 0;
function getElemWatchers(element) {
var isolateWatchers = getWatchersFromScope(element.data().$isolateScope);
var scopeWatchers = getWatchersFromScope(element.data().$scope);
var watchers = scopeWatchers.concat(isolateWatchers);
angular.forEach(element.children(), function (childElement) {
watchers = watchers.concat(getElemWatchers(angular.element(childElement)));