####PHP cheat sheet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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 = {};
OlderNewer