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 / 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>
*/
// 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 / 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
@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 / 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;
}
@lcdsantos
lcdsantos / leaflet-big-image-full.html
Created December 13, 2016 16:33 — forked from longhotsummer/leaflet-big-image-full.html
Full example of using leaflet to pan and zoom a big image, as described at http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html
<html>
<!-- See also: http://kempe.net/blog/2014/06/14/leaflet-pan-zoom-image.html -->
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"></script>
<style>
#image-map {
width: 100%;
height: 300px;
border: 1px solid #ccc;
margin-bottom: 10px;
/*! Custom Input File v1.0 - Copyright (c) 2016 Leonardo Santos */
(function($) {
$.fn.inputFile = function() {
return this.each(function() {
var $this = $(this);
$this
.on('change', function() {
var value = /[^(\\|\/)]*$/.exec($this.val());
$this.siblings('span').text(value[0]);
})
@lcdsantos
lcdsantos / Copy text directly from Photoshop text layer.
Created December 2, 2016 02:04 — forked from praveenvijayan/Copy text directly from Photoshop text layer.
Copy text directly from text layer. Works above photoshop cs6. Copy following script file into /Applications/Adobe Photoshop CC 2014/Presets/Scripts (MAC) or C:\Program Files\Adobe\Adobe Photoshop CC 2014\Presets\Scripts (WIN). Assign shortcut for easy access (cmd+option+c / ctrl+alt+c)
/*****************************************************************
*
* Copy Layer text 1.0 - by Praveen Vijayan! - http://www.decodize.com/
*
* Compatibility above Photoshop CS6
*
* Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
*
*****************************************************************/
@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