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"],
openssl req -in ust.csr -inform PEM -out ust.der -outform DER
function createDateRangeArray($strDateFrom,$strDateTo)
{
// takes two dates formatted as YYYY-MM-DD and creates an
// inclusive array of the dates between the from and to dates.
// could test validity of dates here but I'm already doing
// that in the main script
$aryRange=array();
@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;
@phpmypython
phpmypython / blog-header.php
Created April 24, 2016 21:14
Accessing posts page data wordpress
<?php
if ( is_home() && get_option('page_for_posts') )
{
$blog_page_id = get_option('page_for_posts');
$header_image_id = get_field('header_image', $blog_page_id);
$image_id = wp_get_attachment_image_src($header_image_id, 'full');
}