Skip to content

Instantly share code, notes, and snippets.

View lunaroja's full-sized avatar

Abraham Velazquez Tello lunaroja

View GitHub Profile
@lunaroja
lunaroja / new_machine.sh
Last active November 29, 2018 17:23
Quick Commands to setup a new computer
#!/bin/bash
defaults write com.apple.finder AppleShowAllFiles YES
## Xcode Tools
xcode-select --install
## [Setup oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@lunaroja
lunaroja / get_terms_chekboxes.php
Last active November 25, 2018 19:04
Wordpress: Get taxonomy terms as checkboxes with labels
<?php
function get_terms_chekboxes($taxonomies, $args) {
$terms = get_terms($taxonomies, $args);
foreach($terms as $term){
$output .= '<label for="'.$term->slug.'"><input type="checkbox" id="'.$term->slug.'" name="'.$term->taxonomy.'" value="'.$term->slug.'"> '.$term->name.'</label>';
}
return $output;
}
@lunaroja
lunaroja / wordpress-cors.php
Created March 3, 2015 06:51
Set CORS Header for WordPress JSON API
<?php
add_action( 'init', 'handle_preflight' );
function handle_preflight() {
header("Access-Control-Allow-Origin: " . get_http_origin());
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Headers: Authorization, Origin, X-Requested-With, Content-Type, Accept");
if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
status_header(200);
exit();
@lunaroja
lunaroja / allElementStyles.js
Last active August 3, 2017 19:22
Get all elements and fine out which has a specific style value
// simple way to debug which elements are loading a specific font weight so you can remove them
const allElements = document.querySelectorAll('body *');
for (var element of allElements) {
let styles = window.getComputedStyle(element)
let weight = styles.getPropertyValue('font-weight');
if (weight !== 'normal') {
console.log(element, weight);
}
}
@lunaroja
lunaroja / gulpfile.js
Created February 16, 2017 01:02 — forked from xzyfer/gulpfile.js
True incremental sass compilation
var production = process.env.APP_ENV === "test";
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var cssmin = require('gulp-minify-css');
var prefix = require('gulp-autoprefixer');
var newer = require('gulp-newer');
var print = require('gulp-print');
var notify = require('gulp-notify');
var batch = require('gulp-batch');
@lunaroja
lunaroja / wp_redirect_not_loggedin.php
Created December 1, 2016 05:38
wp_redirect_not_loggedin
<?php
$redirect_url = 'https://google.com/';
if ($redirect_url && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))
&& !is_admin() && !is_user_logged_in()) {
wp_redirect( $redirect_url , 302 ); exit;
}
@lunaroja
lunaroja / running_jekyll-cloud-9.md
Last active October 20, 2016 23:59 — forked from michaelhiiva/running_jekyll-cloud-9.md
Running Jekyll on Cloud9

Run Jekyll in the Cloud9

Running jekyll projects on Cloud 9 requires this jekyll serve -H $IP -P $PORT --baseurl "" command in the terminal.

Setting up a new run configuration

  1. Under the menu select Run > Run Configuration > New Run Configuration.
  2. Then enter jekyll serve -H $IP -P $PORT --baseurl "" for the Command.
  3. Then enter Jekyll for the Run Configuration. This will ensure that you can access it quickly in the Run > Run Configuration > Jekyll.
@lunaroja
lunaroja / wp_login_redirect.php
Last active September 15, 2016 09:26
require login to see wordpress site
<?php
function login_redirect() {
global $pagenow;
if(!is_user_logged_in() && $pagenow != 'wp-login.php') {
auth_redirect();
} else {
return site_url();
}
}
add_action( 'wp', 'login_redirect' );
@lunaroja
lunaroja / Clay.scss
Last active September 14, 2016 06:00
Clay, a simple collections of Sass patterns
// ----
// libsass (v3.3.6)
// ----
// Breakpoints, setter and mixins for mobile-first layouts
// =============================================================================
$-breakpoints: () !global;
@mixin breakpoint-set($breakpoint-name, $min-width) {
@lunaroja
lunaroja / imagesizes.sh
Created June 9, 2016 03:42
json with image dimensions from directory
function imagesizes() {
for filename in *; do
imgsize "$filename"
done
}
function imgsize() {
local width height
if [[ -f $1 ]]; then
height=$(sips -g pixelHeight "$1"|tail -n 1|awk '{print $2}')