Skip to content

Instantly share code, notes, and snippets.

View kurtisdunn's full-sized avatar

Kurtis Dunn kurtisdunn

View GitHub Profile
@kurtisdunn
kurtisdunn / desc.md
Last active August 26, 2018 04:12
React Form Component

React Form Component

Forms need to be able to pass state to deeply nested children, specifically validation state. You will need map React.Children in order to setState for each child. Unfortunately this doesn't solve the problem of of deeply nested inputs. In order to combat this we will need to use a recursive function to check against each nested level to see if it has an input for validation.

  function recursiveCloneChildren(children) {
    const that = this;
    return React.Children.map(children, child => {
 var childProps = {};
@macerier
macerier / MariaDB.repo
Last active December 6, 2019 07:06 — forked from sumardi/nginx.default.conf
Install PHP-FPM, Nginx & MariaDB on EC2 with Amazon Linux AMI
# MariaDB 10.2 CentOS repository list - created 2017-06-19 06:04 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
@idleberg
idleberg / atom-macos-context-menu.md
Last active April 27, 2022 00:37
“Open in Atom” in macOS context-menu

Open in Atom

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /usr/local/bin/atom -n "$@"
  • Set “Pass input” to as arguments
  • Save as Open in Atom
@dtomasi
dtomasi / default
Last active December 8, 2023 04:20
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
@luggage66
luggage66 / fixBookShelfES6Inheritance.js
Created September 16, 2015 19:03
Bookshelf.js 0.8.2 static method inheritance monkey-punching
export default function fixBookShelfES6Inheritance(target) {
// console.log('Fixing:', target.name);
let parentConstructor = Object.getPrototypeOf(target.prototype).constructor;
let parentStaticProperties = Object.keys(parentConstructor);
// console.log('Adding static properties:', parentStaticProperties);
// TODO: Deal with static methods that want to call super() (right now they are REPLACED!)
parentStaticProperties.forEach(propName => target[propName] = parentStaticProperties[propName]);
}
@kurtisdunn
kurtisdunn / README.md
Last active January 6, 2016 06:21
PHP cheat sheet.

####PHP cheat sheet.

@kurtisdunn
kurtisdunn / knexQuery.js
Created May 27, 2015 16:40
Knex.js paginated query string.
app.get('/api/:id', function(req, res) {
var query = req.params.id.toLowerCase();
knex.select('*').from('table').where('name', 'ilike', '%'+query+'%').limit(5).offset(30).orderBy('id', 'desc')
.then(function(rows){
res.send(rows);
});
});
@kurtisdunn
kurtisdunn / leafly.js
Last active August 29, 2015 14:20
Leafly API - NodeJS
var num = Math.floor(Math.random() * 16) + 1
var body = JSON.stringify({
"Page": num,
"Take": 15
});
var options = {
host: 'data.leafly.com',
port: '80',
path: '/strains/cookies-kush',
method: 'GET',
@kurtisdunn
kurtisdunn / random-css-background-image.jsp
Last active August 29, 2015 14:05
Random CSS background-image generated with JSP
<%
File imageDirectory = new File("./images");
String images[] = imageDirectory.list();
if(images != null){
int imageNumber = 0;
double randomNumber = Math.random();
int random2Digits = (int)(randomNumber * 100);
for(int i = 0; i < random2Digits; i++){
@manjeshpv
manjeshpv / passport.js
Last active February 29, 2024 15:11
Passport.js using MySQL for Authentication with Express
// config/passport.js
// load all the things we need
var LocalStrategy = require('passport-local').Strategy;
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',