This file contains 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
<?php | |
# Help | |
php -h; | |
# PHP ini file | |
php -i; | |
# Filter files | |
php -i | grep "memory"; |
This file contains 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
// Form response processor set session token | |
app.formResponseProcessor = function(formId,requestPayload,responsePayload){ | |
var functionToCall = false; | |
// If account creation was successful, try to immediately log the user in | |
if(formId == 'accountCreate'){ | |
// Take the phone and password, and use it to log the user in | |
var newPayload = { | |
'phone' : requestPayload.phone, | |
'password' : requestPayload.password | |
}; |
This file contains 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
// AJAX Client (for RESTful API) | |
app.client = {} | |
// Interface for making API calls | |
app.client.request = function(headers,path,method,queryStringObject,payload,callback){ | |
// Set defaults | |
headers = typeof(headers) == 'object' && headers !== null ? headers : {}; | |
path = typeof(path) == 'string' ? path : '/'; | |
method = typeof(method) == 'string' && ['POST','GET','PUT','DELETE'].indexOf(method.toUpperCase()) > -1 ? method.toUpperCase() : 'GET'; |
This file contains 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
// Bind the forms | |
app.bindForms = function(){ | |
if(document.querySelector("form")){ | |
var allForms = document.querySelectorAll("form"); | |
for(var i = 0; i < allForms.length; i++){ | |
allForms[i].addEventListener("submit", function(e){ | |
// Stop it from submitting | |
e.preventDefault(); |
This file contains 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
## console colour out colour codes | |
// syntax | |
console.log("\x1b[33m%s\x1b[0m" ,"I Am Using Yellow"); | |
console.log("\x1b[44m%s\x1b[0m" ,"Background Color Is Blue"); | |
// variable choices | |
Reset = "\x1b[0m" |
This file contains 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
# GET VERSION | |
npm -v (or --version) | |
# GET HELP | |
npm help | |
npm | |
# CREATE PACKAGE.JSON | |
npm init | |
npm init -y (or --yes) |
This file contains 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
/* | |
Create a function that sums two arguments together. If only one argument is provided, then return a function that expects | |
one argument and returns the sum. | |
For example, addTogether(2, 3) should return 5, and addTogether(2) should return a function. | |
Calling this returned function with a single argument will then return the sum: | |
var sumTwoAnd = addTogether(2); |
This file contains 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
/* | |
Check if the predicate (second argument) is truthy on all elements of a collection (first argument). | |
Remember, you can access object properties through either dot notation or [] notation. | |
*/ | |
function truthCheck(collection, pre) { | |
return collection.every(function(key) { | |
return key[pre]; | |
}); |
This file contains 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
/* | |
Return an English translated sentence of the passed binary string. | |
The binary string will be space separated. | |
*/ | |
function binaryAgent(str) { | |
str = str.split(' '); | |
var convertedBinary = ''; | |
for (var i in str) { |
This file contains 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
/* | |
Flatten a nested array. You must account for varying levels of nesting. | |
*/ | |
function steamrollArray(arr) { | |
var flatterned = []; | |
arr.forEach(item => { | |
if (item instanceof Array) { | |
flatterned = flatterned.concat(steamrollArray(item)); |