Skip to content

Instantly share code, notes, and snippets.

View Jdtanacredi's full-sized avatar

Justin Jdtanacredi

View GitHub Profile
@alfonsomunozpomer
alfonsomunozpomer / Fetch.test.js
Created September 28, 2017 12:51
How to test a React component that sets its state in componentDidMount with fetch, and how to mock it, in Jest
// https://github.com/alfonsomunozpomer/react-fetch-mock
import React from 'react'
import fetchMock from 'fetch-mock'
import Enzyme from 'enzyme'
import {shallow, mount, render} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
Enzyme.configure({ adapter: new Adapter() })
@mbhall88
mbhall88 / .gitignore
Last active October 25, 2022 19:46
A dynamic, reusable donut chart for D3.js v4
.DS_Store
.idea
@NickTitle
NickTitle / markovator.rb
Last active December 18, 2015 16:10
markov chain generator
def setup
@input = File.read('./input.txt')
@input.gsub("\n", " \n")
@split_input = @input.split(/ /)
@word_list = @split_input.uniq
@lookup_hash = Hash.new{ |k,v| k[v] = Hash.new{ |k,v| k[v] = 0 } }
@lookback_length = 2
@out = []
first_preceding_words = @split_input[0..@lookback_length-1]
@josephdburdick
josephdburdick / _helpers.scss
Created June 1, 2015 04:38
Awesome Sass helpers for positioning
/*****************************************************************************/
/* Stylesheet Helpers */
/*****************************************************************************/
$units: px, rem, vh, vw;
$sizes: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 65, 70, 75, 80, 85, 90, 95, 100;
$positions: relative, absolute, fixed, sticky;
$directions: top, left, bottom, right;
@each $position in $positions{
@chantastic
chantastic / on-jsx.markdown
Last active April 21, 2026 08:06
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@polimorfico
polimorfico / quaderno-charges-for-stripe.html
Last active June 19, 2017 10:11
Create a Stripe charge with Quaderno.js
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Quaderno.js for One-off Charges on Stripe</title>
<!-- The required libs -->
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript" src="https://js.quaderno.io/v2/"></script>
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWCOLORHINTS=true
export PS1='\u:\W$(__git_ps1 " (%s)")\$ '
@pablosalgadom
pablosalgadom / secret_key_base
Last active March 11, 2022 18:17
app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)
So i was using Rails 4.1 with Unicorn v4.8.2 and when i tried to deploy my app it doesn't start properly and into the unicorn.log file i found this error message:
"app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)"
After a little research i found that Rails 4.1 change the way to manage the secret_key, so if we read the secrets.yml file located at exampleRailsProject/config/secrets.yml (you need to replace "exampleRailsProject" for your project name) you will find something like this:
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@kanakiyajay
kanakiyajay / app.js
Created February 25, 2014 16:39
Ajax forms using express.js and jQuery utilizing mysql and node-js
var mysql = require("mysql"),
express = require("express"),
app = express();
var connection = mysql.createConnection({
host : "localhost",
user : "root",
password : "",
database : "node"
});