Skip to content

Instantly share code, notes, and snippets.

Avatar

Doug Niccum dniccum

View GitHub Profile
@dniccum
dniccum / add-typeform.js
Created Jul 27, 2021
Dynamically appends a Typeform element to a page within a method/function
View add-typeform.js
const body = document.getElementsByTagName('body')[0];
const tag = document.createElement('a');
const formId = '#####'; // Change this to your specific form ID
tag.setAttribute('class', 'typeform-share button');
tag.setAttribute('href', `https://form.typeform.com/to/${formId}?typeform-medium=embed-snippet`);
tag.setAttribute('data-mode', 'popover');
tag.setAttribute('data-open', 'time');
tag.setAttribute('data-open-value', '1000');
tag.setAttribute('target', '_blank');
@dniccum
dniccum / SecureInput.js
Created Oct 4, 2018
A Vue.JS directive that toggles the input type from text to password on blur; creating a secure input.
View SecureInput.js
import Vue from 'vue';
Vue.directive('secure-input', {
inserted(el) {
el.type = 'password';
},
bind(el) {
el.addEventListener('focus', () => {
el.type = 'text'
});
@dniccum
dniccum / FizzBuzz.py
Created Feb 24, 2018
A basic Python application called FizzBuzz
View FizzBuzz.py
for x in range(1, 101):
if x % 3 == 0 and x % 5 != 0:
print "Fizz"
elif x % 5 == 0 and x % 3 != 0:
print "Buzz"
elif x % 5 == 0 and x % 3 == 0:
print "FizzBuzz"
else:
print x
@dniccum
dniccum / ErrorService.js
Last active Feb 29, 2016
A custom error reporting workflow for SailsJS that uses AngularJS and the NodeJS package sails-hook-validation
View ErrorService.js
module.exports = {
ParseUserErrors: function(errors) {
var validationErrors = [];
for (var key in errors) {
if (errors.hasOwnProperty(key)) {
for (var item in errors[key]) {
if (errors[key][item].rule !== "string") {
validationErrors.push(errors[key][item].message);
}
@dniccum
dniccum / jQuery Counter
Last active Aug 29, 2015
A basic jQuery/Javascript counter to counts up to a certain number within a certain time period.
View jQuery Counter
// target: The jQuery/Javascript element that you want the function to affect
// targetNumber: The max number you want the counter to get to
// type: Type of units the function outputs; can be modifed
// currentNumber: The number you would like to start from; leave undefined to start from zero
function countUp(target, targetNumber, type, currentNumber) {
var integer,
interval = (3 / targetNumber) * 1000; // 3 is the amount of time to give the counter to reach its desired amount
if (currentNumber === undefined) {
@dniccum
dniccum / _variables.scss
Last active Aug 29, 2015
This is my basic boilerplate of SCSS mixins that I have been compiling
View _variables.scss
// MIXINS
@mixin shadow($color: #B8B8B8) {
-webkit-box-shadow: 0 0 10px 2px $color;
box-shadow: 0 0 10px 2px $color;
}
@mixin gradient($color1, $color2) {
background: $color1;
background: -moz-linear-gradient(top, $color1 0%, $color2 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,$color1), color-stop(100%,$color2));