Skip to content

Instantly share code, notes, and snippets.

View pajtai's full-sized avatar

Peter Ajtai pajtai

  • https://www.soliddigital.com/
  • Portland, Oregon
View GitHub Profile
<?php
$pagination = paginate_links( array(
'base' => get_pretty_url($currentMarket, $currentCategory) . '%_%',
'format' => '/page/%#%',
'current' => $paged,
'total' => $posts->pagination()->total,
'prev_next' => false
));
function get_pretty_url( $root, $marketSlug, $topicSlug ) {
@pajtai
pajtai / rewrite-rules.php
Last active March 29, 2018 06:33
Wordpress Rewrite Rules
<?php
add_action( 'init', function () {
add_rewrite_rule('blog/market/([^/]+)/category/([^/]+)/page/([0-9]{1,})/?$', 'index.php?pagename=blog&pg=$matches[3]&market=$matches[1]&category=$matches[2]', 'top');
add_rewrite_rule('blog/market/([^/]+)/category/([^/]+)/?$', 'index.php?pagename=blog&market=$matches[1]&category=$matches[2]', 'top');
add_rewrite_rule('blog/market/([^/]+)/page/([0-9]{1,})/?$', 'index.php?pagename=blog&pg=$matches[2]&market=$matches[1]', 'top');
add_rewrite_rule('blog/market/([^/]+)/?$', 'index.php?pagename=blog&market=$matches[1]', 'top');
add_rewrite_rule('blog/category/([^/]+)/page/([0-9]{1,})/?$', 'index.php?pagename=blog&paged=$matches[2]&category=$matches[1]', 'top');
add_rewrite_rule('blog/category/([^/]+)/?$', 'index.php?pagename=blog&category=$matches[1]', 'top');
@pajtai
pajtai / cleanup.md
Last active September 13, 2017 09:55
Cleaning up a Vagrant box before packaging

I tested the following script on a vagrant box.

The box was 850MB without the script, and 450 MB with the script.

The script was taken from chef/bento with just one modification.

screen shot 2015-02-08 at 3 27 20 pm

@pajtai
pajtai / test-ssl.sh
Last active September 27, 2016 14:25
Test open ssl cyphers for a domain. e.g.: ./test-ssl.sh example.com
#!/usr/bin/env bash
# source: http://superuser.com/a/224263/41059
# OpenSSL requires the port number.
SERVER=$1:443
DELAY=1
echo Obtaining cipher list from $(openssl version).
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
{
role: 'admin',
enabled: true,
firstname: 'Test',
lastname: 'User',
identities: {
basic: {
username: 'admin',
salt: '225384010328',
hash: '885f59a76ea44e1d264f9da45ca83574fbe55e3e7e6c51afe681730b45c7bb03'
@pajtai
pajtai / loadGruntConfigAndDependencies.js
Created December 2, 2013 04:29
Load all grunt tasks and load grunt config from a directory and set of files
loadGruntConfigAndDependencies('./initConfig/');
function loadGruntConfigAndDependencies (files) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig(loadConfig(files));
}
function loadConfig(files) {
var path = require('path'),
object = {};
@pajtai
pajtai / .gitconfig
Created February 6, 2013 18:27
Git aliases
[alias]
lg1 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
lg2 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
logo = log --oneline
stat = log --stat
//Wait for relevant code bits to load before starting any tests
define(['core.js'], function( core ) {
module("Core Tests");
test("Test core methods", function(){
expect(2);
equals( 1, 1, "A trivial test");
ok( true, "Another trivial test");
});
@pajtai
pajtai / embed.js
Created December 25, 2012 03:29 — forked from anonymous/embed.js
var DISQUS = function (e) {
var g = e.DISQUS || {};
g.AssertionError = function (b) {
this.message = b
};
g.AssertionError.prototype.toString = function () {
return "Assertion Error: " + (this.message || "[no message]")
};
g.assert = function (b, d, f) {
if (!b) if (f) e.console && e.console.log("DISQUS assertion failed: " + d);
DISQUS.addBlocks("theme")(function (d) {
d.blocks.letUsKnow = function (f, c) {
var a = new d.Builder,
h = DISQUS.extend({}, f, c);
with(h) return a.put('<a href="https://www.surveymonkey.com/s/GHK872T" target="_blank">'), a.put(gettext("Let us know.")), a.put("</a>"), a.compile()
};
d.blocks.relatedThread = function (f, c) {
var a = new d.Builder,
h = DISQUS.extend({}, f, c);
with(h) return a.put(' <li class="discovery-unit"> <div class="discovery-heading-wrapper"> <h3 title="'), a.put((a.esc || function (a) {