Skip to content

Instantly share code, notes, and snippets.

View dtothefp's full-sized avatar

David Fox-Powell dtothefp

  • Flexport
  • United States
View GitHub Profile
let mockNuclearDec = mockNuclearComponent({formState, formValidation});
HigherOrderInput.__Rewire__('nuclearComponent', mockNuclearDec);
let HigherOrderComponent = HigherOrderInput(Input);
let hoc = TestUtils.renderIntoDocument(
<HigherOrderComponent {...mockProps} />
);
let hocElm = React.findDOMNode(hoc);
let inputObj = TestUtils.findRenderedDOMComponentWithClass(hoc, 'one');
var checkComplexPassword = function(password) {
var CHAR_LOWERS = /[a-z]/,
CHAR_UPPERS = /[A-Z]/,
CHAR_NUMBERS = /[0-9]/,
CHAR_SPECIAL = /[?=.*!@#$%^&*]/,
CHAR_TYPES = [CHAR_LOWERS,CHAR_UPPERS,CHAR_NUMBERS,CHAR_SPECIAL],
counter = 4;
for (var i=0; i<CHAR_TYPES.length; i++){
if(!CHAR_TYPES[i].test(password)){
@dtothefp
dtothefp / directive-draggable
Created February 20, 2014 22:51
Vanilla JS Draggable Directive
module = angular.module 'draggable', []
module.controller "dragDropCtrl", ($scope) ->
$scope.dropPosition = null
module.directive 'pixbiDraggable', ($timeout) ->
restrict: 'A'
controller: 'dragDropCtrl'
scope: {
dropPosition: "="
@dtothefp
dtothefp / gist:9202480
Last active August 29, 2015 13:56
Mario Pyramid
puts "Enter the pyramid height"
input = gets.chomp.to_i
while input < 1 || input > 69
puts "Please enter a number between 1 and 69"
input = gets.chomp.to_i
end
puts "Your input is #{input}"
@dtothefp
dtothefp / class_cons.rb
Created April 3, 2014 12:39
Classes & Prototypes
class Car
def initialize(name)
@name = name
end
def name
@name
end
@dtothefp
dtothefp / angular_grunt.js
Created April 3, 2014 18:26
angular production grunt
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
files: {
desktopSrc: ['public/js/config/*.js', 'public/js/factories/*.js', 'public/js/controllers/*.js', 'public/js/directives/*.js'],
mobileSrc: ['public_mobile/js/config/*.js', 'public_mobile/js/factories/*.js', 'public_mobile/js/controllers/*.js', 'public_mobile/js/directives/*.js'],
desktopImg: ['public/images/{,**/}*.{jpg,png,gif}', 'public/video/**/{,**/}*.{jpg,png,gif}'],
@dtothefp
dtothefp / lex_v_dyanamic
Last active August 29, 2015 14:00
Lexical vs. Dynamic Scope
// Lexical
(function(){
function addIt(){
var x = 100;
function addInside(){
return x += 5;
}
@dtothefp
dtothefp / JS Singleton
Last active August 29, 2015 14:01
private methods and vars
//http://www.crockford.com/javascript/little.html
var singleton = (function(){
var privateHello = "hello";
function privateFunction(something){
privateHello = privateHello + " " + something;
}
return {
changeSomething: function(a){
privateFunction(a);
@dtothefp
dtothefp / angular_anim
Created May 25, 2014 17:30
Angular Animation
.sharer-message-container {
// finished state when visible
position: absolute;
top: 0%;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.9);
z-index: 100;
padding: 20px 10px;
@dtothefp
dtothefp / SassMeister-input.scss
Created May 27, 2014 03:58
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
@mixin testing($properties) {
@if(type-of(nth($properties, 1)) == list) {
@each $property, $value in $properties {
#{$property}: $value;