Skip to content

Instantly share code, notes, and snippets.

View phpmypython's full-sized avatar

William Wilkerson phpmypython

View GitHub Profile
@phpmypython
phpmypython / menu.php
Created July 31, 2014 16:40
Menu Class file
<?php
namespace AbleCore;
class Menu{
public static function CreateLocation($location,$description){
$location_t = __($location);
$description_t = __($description);
register_nav_menu($location_t,$description_t);
}
<?php
// Code to register menu locations
AbleCore\Menu::CreateLocation("header_menu","Header Menu");
AbleCore\Menu::CreateLocation("footer_menu","Footer Menu");
// Code to call those menus
$header_menu = new AbleCore\Menu();
<?php
class TailRecursion
{
public $func;
public $acc;
public $recursing;
public function tail()
{
return call_user_func_array($this->func, func_get_args());
}
public int longestConsecutive(int[] num) {
int res = 0;
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int n : num) {
if (!map.containsKey(n)) {
int left = (map.containsKey(n - 1)) ? map.get(n - 1) : 0;
int right = (map.containsKey(n + 1)) ? map.get(n + 1) : 0;
// sum: length of the sequence n is in
int sum = left + right + 1;
map.put(n, sum);
var gulp = require('gulp'),
scss = require('gulp-sass'),
notify = require('gulp-notify');
autoprefixer = require('gulp-autoprefixer');
minifyCss = require('gulp-minify-css');
gulp.task('styles', function () {
return gulp.src('scss/main.scss') //This is the path to SCSS files that you want to compile.
.pipe(scss())
.pipe(autoprefixer({
<?php
$currentCookieParams = session_get_cookie_params();
$rootDomain = '.example.com';
session_set_cookie_params(
$currentCookieParams["lifetime"],
$currentCookieParams["path"],
$rootDomain,
$currentCookieParams["secure"],
@phpmypython
phpmypython / permissionset.sh
Last active December 24, 2016 06:27
WordPress Permissions
find . -type f -name "wp-config-sample.php" -o -name "readme.html" -o -name "README.txt" -o -wholename "wp-admin/install.php" -exec rm -f {} \; &&
find . -type d -exec chmod 0755 {} \; &&
find . -type f -exec chmod 0755 {} \; &&
find . -name "wp-config.php" -exec chmod 600 {} \;
@phpmypython
phpmypython / utf8_encode.js
Created October 15, 2015 16:39
Implementation of utf8_encode in javascript
//Javascript implementation of utf8_encode function from php.
function utf8_encode(argString) {
if (argString === null || typeof argString === 'undefined') {
return '';
}
var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
var utftext = '',
start, end, stringl = 0;
openssl req -in ust.csr -inform PEM -out ust.der -outform DER
(function (m) {
/*
* PHP => moment.js
* Will take a php date format and convert it into a JS format for moment
* http://www.php.net/manual/en/function.date.php
* http://momentjs.com/docs/#/displaying/format/
*/
var formatMap = {
d: 'DD',
D: 'ddd',