Skip to content

Instantly share code, notes, and snippets.

View lcdsantos's full-sized avatar
🏠
Working from home

Leonardo Santos lcdsantos

🏠
Working from home
View GitHub Profile
@lcdsantos
lcdsantos / simple-pagination.js
Created February 9, 2017 09:48 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@lcdsantos
lcdsantos / LICENSE.txt
Created March 6, 2017 21:24 — forked from jed/LICENSE.txt
calculate # of ms/seconds/minutes/hours/days in the past
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1
@lcdsantos
lcdsantos / httpd-vhosts.conf
Last active August 7, 2017 23:48
Apache Wildcard VHOST
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
@lcdsantos
lcdsantos / alignments.scss
Created August 13, 2018 00:18
Flexbox alignments
.flex {
display: flex;
.align-center {
margin: auto;
align-self: center;
}
.align-left {
margin-right: auto;
@lcdsantos
lcdsantos / map.js
Created March 14, 2018 14:48
Advanced Custom Fields Google Maps integration (ACF)
/**
* Advanced Custom Fields Google Maps integration
*
* @link https://www.advancedcustomfields.com/resources/google-map/
* @example
* <?php $location = get_field( 'location' ); ?>
* <div class="acf-map">
* <div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
* </div>
*/
@lcdsantos
lcdsantos / wp-get_id_by_slug
Created February 1, 2017 13:57 — forked from davidpaulsson/wp-get_id_by_slug
WordPress: Get page ID from slug
// Usage:
// get_id_by_slug('any-page-slug');
function get_id_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}