Skip to content

Instantly share code, notes, and snippets.

@weblancaster
weblancaster / cloudSettings
Last active August 17, 2018 15:28
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-08-17T15:28:31.220Z","extensionVersion":"v3.0.0"}
@weblancaster
weblancaster / check-if-string-is-palindrome.js
Created October 27, 2016 15:44
Check if string is palindrome in Javascript.
function isPalindrome(str) {
str = str.replace(/\W/g).toLowerCase();
return str === str.split('').reverse().join('');
}
@weblancaster
weblancaster / gist:6e7f43fc02725ce747e224b0c4290906
Last active May 25, 2020 12:53
Kill all container, remove all images and stop all containers
#stop all containers:
docker kill $(docker ps -q)
#remove all containers
docker rm $(docker ps -a -q)
#remove all docker images
docker rmi $(docker images -q)
@weblancaster
weblancaster / Javascript-find-second-string-occurrence
Created October 27, 2014 00:15
Javascript find second string occurrence
str.indexOf("is", str.indexOf("is") + 1);
@weblancaster
weblancaster / javascript-is-element-visible
Last active August 29, 2015 14:06
javascript snippet for "is element visible"
function isElementInViewport (el) {
//special bonus for those using jQuery
if (el instanceof jQuery) {
el = el[0];
}
var rect = el.getBoundingClientRect();
return (
@weblancaster
weblancaster / javascript-ie-and-ie11-detection
Created July 2, 2014 18:26
javascript IE and IE11 detection
function isIE() { return ((navigator.appName == 'Microsoft Internet Explorer') || ((navigator.appName == 'Netscape') && (new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null))); }
@weblancaster
weblancaster / javascript-mobile-device-detection
Created May 15, 2014 20:38
Javascript Mobile device detection
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// some code..
}
@weblancaster
weblancaster / javascript-image-preloader
Last active August 29, 2015 13:58
Snippet to how to preload images assets using javascript.
function preloadimages(arr) {
var newimages = []
, loadedimages = 0
, postaction = function() {}
, arr = ( typeof arr != "object" ) ? [arr] : arr
, i = 0;
function imageloadpost(){
loadedimages++;
if ( loadedimages == arr.length ) {
@weblancaster
weblancaster / instagram-real-time-steps
Created March 10, 2014 18:04
Instagram real time steps
As a heads up make sure you have these things listed below.
1. Make sure that you have everything set up on Instagram with your Key https://github.com/weblancaster/instagram-real-time/blob/master/server.js#L21
2. You have your url's set up https://github.com/weblancaster/instagram-real-time/blob/master/server.js#L29
3. Subscribing your code to Instagram Real Time https://github.com/weblancaster/instagram-real-time/blob/master/server.js#L123
4.To change the hashtag you will need to change "object_id" https://github.com/weblancaster/instagram-real-time/blob/master/server.js#L40
@weblancaster
weblancaster / px-to-em
Created September 22, 2013 18:18
px to em
// It strips the unit of measure and returns it
@function strip-unit($num) {
@return $num / ($num * 0 + 1);
}
// Converts "px" to "em" using the ($)em-base
@function convert-to-em($value, $base-value: $em-base) {
$value: strip-unit($value) / strip-unit($base-value) * 1em;
@if ($value == 0em) { $value: 0; } // Turn 0em into 0
@return $value;