Skip to content

Instantly share code, notes, and snippets.

View jwill9999's full-sized avatar
💭
working

Jason Williams jwill9999

💭
working
View GitHub Profile
@jwill9999
jwill9999 / CustomPage.js
Last active September 20, 2018 02:27
Puppeteer setup using Proxys
const puppeteer = require('puppeteer');
/**************************************************
SETUP CLASS USING PROXYS FOR PUPPETEER
***************************************************/
class CustomPage {
@jwill9999
jwill9999 / test.js
Created September 19, 2018 16:29
Simple assertion test function
/*===========================================
assertion function
=============================================*/
function test(str, bool) {
console.log(
bool ? '\x1b[32m' : '\x1b[31m',
bool ? '[PASS]' : ' [FAIL]',
str
)
}
@jwill9999
jwill9999 / index.php
Last active July 29, 2018 00:12
PHP CLI commands
<?php
# Help
php -h;
# PHP ini file
php -i;
# Filter files
php -i | grep "memory";
@jwill9999
jwill9999 / app.js
Created June 7, 2018 19:10
Set a local storage session token JavaScript
// 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
};
@jwill9999
jwill9999 / app.js
Created June 7, 2018 18:42
XMLHttpRequest native JavaScript
// 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';
@jwill9999
jwill9999 / app.js
Created June 7, 2018 18:31
bind form data JavaScript
// 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();
@jwill9999
jwill9999 / npmcrashcourse.txt
Created December 8, 2017 01:34 — forked from bradtraversy/npmcrashcourse.txt
NPM Crash Course Commands
# GET VERSION
npm -v (or --version)
# GET HELP
npm help
npm
# CREATE PACKAGE.JSON
npm init
npm init -y (or --yes)
@jwill9999
jwill9999 / index.js
Created October 10, 2017 16:54
arguments Optional
/*
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);
@jwill9999
jwill9999 / index.js
Created October 10, 2017 16:51
Everything be true
/*
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];
});
@jwill9999
jwill9999 / index.js
Created October 10, 2017 16:49
Binary Agents
/*
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) {