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
@toddmotto
toddmotto / gist:5477991
Created April 28, 2013 18:56
Center Google Maps Marker positioning on window.resize
google.maps.event.addDomListener(window, 'resize', function() {
var center = map.getCenter()
google.maps.event.trigger(map, "resize")
map.setCenter(center)
})
@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>
*/
@aradnom
aradnom / auto-paragraph.js
Created August 11, 2015 17:41
Simple auto-paragraph for JavaScript
/**
* Convert text containing newlines to paragraph'd markup.
*
* @param {String} text Text to add p tags to
*
* @return {String} Returns paragraphized text
*/
function autoParagraph ( text ) {
return '<p>' + text.split( /\n+/ ).join( '</p>\n<p>' ) + '</p>';
}
@davidhund
davidhund / pragmatic-touch-icons.md
Last active September 4, 2020 15:42
Pragmatic Touch Icons

NOTE I'm trying to find the most optimal fav/touch icon setup for my use-cases. Nothing new here. Read Mathias Bynens' articles on re-shortcut-icon and touch icons, a FAQ or a Cheat Sheet for all the details.

I'd like to hear how you approach this: @valuedstandards or comment on this gist.

The issue

You have to include a boatload of link elements pointing to many different images to provide (mobile) devices with a 'favicon' or 'touch icon':

![Touch Icon Links](https://o.twimg.com/2/proxy.jpg?t=HBj6AWh0dHBzOi8vcGhvdG9zLTYuZHJvcGJveC5jb20vdC8yL0FBRGFGY1VRN1dfSExnT3cwR1VhUmtaUWRFcWhxSDVGRjNMdXFfbHRJWG1GNFEvMTIvMjI3OTE2L3BuZy8xMDI0eDc2OC8yL18vMC80L1NjcmVlbnNob3QlMjAyMDE1LTA0LTE0JTIwMTYuNTYuMjYucG5nL0NNejBEU0FCSUFJZ0F5Z0JLQUkvNGR1eDZnMzZmYnlzYWI3

@fdaciuk
fdaciuk / 01 - Sublime Configurations.md
Last active March 11, 2021 00:56
Sublime Configurations
@toshimaru
toshimaru / jquery-scroll-bottom.js
Last active May 31, 2022 10:55
Detect the scrolling to bottom of the page using jQuery.
$(window).on("scroll", function() {
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
// when scroll to bottom of the page
}
});
@yanatan16
yanatan16 / .mongorc.js
Last active June 27, 2022 09:03
My .mongorc.js file
(function () {
rcversion = '1.0';
load('underscore.min.js')
// NOTES
// Basics, wrap the whole thing in a function
// Set a version for sanity's sake
// Load underscore, a must in any javascript environment
@timkinnane
timkinnane / database_table_example.php
Last active July 21, 2022 13:31
Take a WPDB query result and display it as a table, with headers from data keys. Creates demo menu page to show example table. #wordpress Basic example for previewing results, handy for debugging etc, but doesn't provide much validation, sorting, pagination etc.
<?php
/**
* Take a WPDB query result and display it as a table, with headers from data keys.
* This example only works with ARRAY_A type result from $wpdb query.
* @param array $db_data Result from $wpdb query
* @return bool Success, outputs table HTML
* @author Tim Kinnane <tim@nestedcode.com>
* @link http://nestedcode.com
*/
@yangshun
yangshun / using-eslint-with-prettier.md
Last active March 22, 2023 13:50
Comparison between tools that allow you to use ESLint and Prettier together.
prettier-eslint eslint-plugin-prettier eslint-config-prettier
What it is A JavaScript module exporting a single function. An ESLint plugin. An ESLint configuration.
What it does Runs the code (string) through prettier then eslint --fix. The output is also a string. Plugins usually contain implementations for additional rules that ESLint will check for. This plugin uses Prettier under the hood and will raise ESLint errors when your code differs from Prettier's expected output. This config turns off formatting-related rules that might conflict with Prettier, allowing you to use Prettier with other ESLint configs like eslint-config-airbnb.
How to use it Either calling the function in your code or via [prettier-eslint-cli](https://github.co