Skip to content

Instantly share code, notes, and snippets.

View dreamyguy's full-sized avatar
👨‍💻 Code-bending

Wallace Sidhrée dreamyguy

👨‍💻 Code-bending
View GitHub Profile
@dreamyguy
dreamyguy / possibility.js
Last active September 10, 2018 20:16
Chance + probability = possibility
// Calculate chance
const chance = (percentage) => {
const probability = (percentage / 100);
return (Math.random() < probability ? 1 : 0);
};
// Set percentage of possibility (10 = 10%, 75 = 75%)
const possibility = chance(70);
// Only execute it if 'possibility' is truthy
if (possibility) {
// It's possible!
@dreamyguy
dreamyguy / web-fonts.scss
Created August 31, 2018 12:59
SCSS Webfont pattern
$font-fallback: arial, sans-serif;
$path-fonts: '../fonts';
.font-defaults {
font-weight: normal;
font-style: normal;
-webkit-font-smoothing: antialiased;
}
@font-face {
@dreamyguy
dreamyguy / reinforce-node-version.md
Last active June 20, 2018 13:59
Reinforce Node version

Reinforcing node version

To specify which version of Node the app should be using, use the engines property on package.json, like so (in this case sticking to version 5):

{
  "name": "my-app",
  ...
  "engines": {
 "node": "&gt;=5.0.0 &lt;6.0.0"
@dreamyguy
dreamyguy / _helper-margin-padding.scss
Last active June 11, 2018 09:40
SCSS: Margin and Padding Helper loop. Generates helper classes like `.m-t-2`, `.p-b-3`, `.m-r-1`, etc.
// ~ Margin & padding helper ~
// by @dreamyguy - Wallace Sidhrée [http://sidhree.com]
// See https://gist.github.com/dreamyguy/2fc16be42a01f21527c5a12bbb662f08
// Based on https://gist.github.com/jacurtis/30da4bf9a6c9b9b5cc0aebac512ca7c9 by J. Alexander Curtis
//
// Generates the following classes:
// .m-t-[x]: margin-top [y]rem.
// .m-b-[x]: margin-bottom [y]rem.
// .p-t-[x]: margin-top [y]rem.
// .p-b-[x]: margin-bottom [y]rem.
@dreamyguy
dreamyguy / data_year-value.json
Created March 19, 2018 14:25
JSON Data - Year vs Value
[
[
915148800000,
0.0010
],
[
946684800000,
0.1133
],
[
@dreamyguy
dreamyguy / .bash_profile
Created April 17, 2018 14:01 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@dreamyguy
dreamyguy / bash_profile
Created April 17, 2018 13:59 — forked from existemi/bash_profile
My preferred bash setup
#!bin/bash
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
@dreamyguy
dreamyguy / modernizr.ios.js
Last active April 9, 2018 11:30
Modernizr tests to detect iOS devices.
// iOS Detection
// Clumsy but handy way to detect iOS devices and refer to them when needed.
Modernizr.addTest('ipad', function () {
return !!navigator.userAgent.match(/iPad/i);
});
Modernizr.addTest('iphone', function () {
return !!navigator.userAgent.match(/iPhone/i);
});
@dreamyguy
dreamyguy / logMessage1-import.js
Last active January 24, 2018 13:58
A way to see console.log() messages without breaking old browsers AND only on dev servers
import {ENV} from '../../env'; // (ENV = 'dev' || 'prod')
export default function logMessage(message, styles) {
// 'ENV' will establish if this should be rendered or not.
// Since it's set to 'dev' by default, 'console.log' messages
// will not output in production.
if (ENV === 'dev' && typeof parent.window.console === 'object') {
parent.window.console.log(message, styles);
}
}
@dreamyguy
dreamyguy / svg-with-color.scss
Last active December 19, 2017 08:33
SVGs as background images WITH COLOR!
$cl-black: #000;
$cl-green: #bada55;
$cl-red: #f00;
@function _buildIcon($icon) {
$icon: '%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20#{$icon}%3C%2Fsvg%3E';
@return $icon;
}
@function _buildPath($path, $viewbox, $parameters) {