Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Joseph Fusco josephfusco

🏠
Working from home
View GitHub Profile
@mdecorte
mdecorte / createUsefulAssetManifest.js
Last active Jul 17, 2019
Script to create a useful asset-manifest file for CRA-2 that only contains paths to assets needed on page load
View createUsefulAssetManifest.js
const fs = require('fs')
const path = require('path')
// for CRA-2 un-comment line 5 and comment line 6
// const assetManifest = require('./build/asset-manifest.json')
const assetManifest = require('./build/asset-manifest.json')[files]
const indexFilePath = path.join(__dirname, 'build/index.html')
const BUILD_PATH = path.join(__dirname, 'build/useful-asset-manifest.json')
View plugin.php
<?php
/**
* Plugin Name: YOUR PLUGIN NAME
*/
include( dirname( __FILE__ ) . '/lib/requirements-check.php' );
$your_plugin_requirements_check = new YOUR_PREFIX_Requirements_Check( array(
'title' => 'YOUR PLUGIN NAME',
'php' => '5.4',
@ibreakthecloud
ibreakthecloud / github-OAuth.php
Last active Dec 16, 2019
Complete PHP 7 code for Implementing OAuth via Github
View github-OAuth.php
<?php
session_start();
$code = $_GET['code'];
$url = 'https://github.com/login/oauth/access_token';
$client_id = 'xxxxxxxxxxxxxxxxxxxxxxx';
$client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// echo $code;
$postdata = http_build_query(
View User.php
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
@lukecav
lukecav / functions.php
Last active Jul 12, 2020
Logout of WordPress without confirmation message
View functions.php
function getLogoutUrl($redirectUrl = ''){
if(!$redirectUrl) $redirectUrl = site_url();
$return = str_replace("&amp;", '&', wp_logout_url($redirectUrl));
return $return;
}
/**
* Bypass logout confirmation on nonce verification failure
*/
function logout_without_confirmation($action, $result){
@robbens
robbens / main.js
Created Apr 5, 2017
Example on how to use Masonry.js with FacetWP
View main.js
// Init Masonry
var $grid = jQuery('.facetwp-template').masonry({
percentPosition: true,
columnWidth: '.grid-sizer',
itemSelector: '.grid-item'
});
// Reload and update on FacetWP load
jQuery(document).on('facetwp-loaded', function() {
$grid.masonry('reloadItems')
View gist:b2d8e5b8f5fec5b0ed946b24fa288a91
# Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install composer
brew install homebrew/php/composer
### PHPCS
composer global require "squizlabs/php_codesniffer=*"
# Add to your .bash_profile
@pistell
pistell / XMLRPC_Hack_Attempts
Created Apr 7, 2016
Finds IPs accessing xmlrpc.php from Apache logs and sorts them by connection attempts
View XMLRPC_Hack_Attempts
grep -i "xmlrpc\.php" other_vhosts_access.log.1 | awk '{print $2 " " $8}' | sort | uniq -c | sort -n | tail > hack_attempts.txt
1. cd into your apache logs directory (ex- /var/log/apache2)
2. Run the grep command
This will search the file "other_vhosts_access_log.1" for the string "xmlrpc.php
Awk will then print out column 2 (the incoming connection) and column 8 (the file accessed)
Sorts by unique IPs then numbers them by attempts
Data is output to hack_attempts.txt for analysis
Example output::
@jcallery
jcallery / acf-field-names.php
Created Mar 1, 2016
Display ACF field names
View acf-field-names.php
/**
* Display ACF field names for development
*/
function action_function_name( $field ) {
echo $field['_name'];
}
add_action( 'acf/render_field', 'action_function_name', 10, 1 );
@kevinwhoffman
kevinwhoffman / plugin.php
Last active Oct 12, 2018 — forked from mathetos/plugin.php
Dependent Plugin Activation/Deactivation and Alert
View plugin.php
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
You can’t perform that action at this time.