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 / validateEmail.js
Last active September 19, 2019 04:48
Email validation
/*
* Email validator
* By Wallace Sidhrée - @dreamyguy
*/
const validateEmail = value => {
if (value) {
// Emails longer than 256 chars aren't valid
if (value.length > 256) {
return false;
}
@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": ">=5.0.0 <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 / .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 / data_year-value.json
Created March 19, 2018 14:25
JSON Data - Year vs Value
[
[
915148800000,
0.0010
],
[
946684800000,
0.1133
],
[
@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) {
@dreamyguy
dreamyguy / downloadFile.js
Last active October 26, 2023 14:48
Download response.data as a file, through Blob()
// 'downloadFile.js', written by blending two solutions:
// 'js-download' https://github.com/kennethjiang/js-file-download
// 'Anders Paulsen' https://blog.jayway.com/2017/07/13/open-pdf-downloaded-api-javascript/
export function downloadFile(data, filename, mime) {
// It is necessary to create a new blob object with mime-type explicitly set
// otherwise only Chrome works like it should
const blob = new Blob([data], {type: mime || 'application/octet-stream'});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE doesn't allow using a blob object directly as link href.
@dreamyguy
dreamyguy / docker-problems.md
Last active August 4, 2017 10:48
Ultimate "Docker on macOS" problems solver

For when Docker acts up on you (macOS):

  1. Restart docker
  2. docker system prune (the secret sauce)
  3. docker login -u _token -p "$(gcloud auth print-access-token)" https://eu.gcr.io (authenticate if needed)
  4. docker-compose build --no-cache

If experiencing problems with npm modules or bower components:

  1. rm -rf /node_modules && rm -rf /bower_components/ && docker-compose build --no-cache
@dreamyguy
dreamyguy / position-absolute-center.css
Created March 24, 2017 15:01
Center absolutely positioned elements
.el-parent {
position: relative;
}
.el {
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
text-align: center;
}