Skip to content

Instantly share code, notes, and snippets.

@fomigo
fomigo / modx-snippets.php
Created October 9, 2012 12:03 — forked from christianhanvey/modx-snippets.php
Useful snippets for MODX Revo
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@fomigo
fomigo / taxonomy-slug-as-custom-post-type.php
Last active June 30, 2023 13:52
wp: CUSTOM TAXONOMY WITH SAME SLUG AS CUSTOM POST TYPE
<?php
/*
* Source: http://someweblog.com/wordpress-custom-taxonomy-with-same-slug-as-custom-post-type/
*/
// rewrite urls
function taxonomy_slug_rewrite($wp_rewrite) {
$rules = array();
@fomigo
fomigo / HamcrestTestCase.php
Created March 8, 2023 05:44
Hamcrest Test Case for PHPUnit
<?php // test/HamcrestTestCase.php
namespace App\Test;
use PHPUnit\Framework\TestCase;
use Hamcrest\MatcherAssert;
use Hamcrest\Util;
class HamcrestTestCase extends TestCase {
@fomigo
fomigo / how_to_use_hamcrest_matcher_with_phpunit.md
Created February 26, 2023 08:25 — forked from appkr/how_to_use_hamcrest_matcher_with_phpunit.md
How to use Hamcrest Matcher with PHPUnit

1 Set up

<?php // tests/HamcrestTestCase.php

namespace Tests;

use Hamcrest\MatcherAssert;
use Hamcrest\Util;
@fomigo
fomigo / installer.sh
Created June 23, 2012 13:16 — forked from pjkelly/installer.sh
Installing PHPUnit via Pear on Ubuntu Lucid
# Uninstall any pre-existing packaged
# versions of phpunit
sudo apt-get remove phpunit
# Install pear via apt-get
sudo apt-get install php-pear
# Update existing pear channels
sudo pear channel-update pear.php.net
@fomigo
fomigo / gist:2382775
Created April 14, 2012 07:59
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}
@fomigo
fomigo / .xbindkeysrc
Created August 12, 2021 05:11 — forked from MurzNN/.xbindkeysrc
Changing keyboard layout in Linux KDE + Electron apps via Alt+Shift workaround
# Add this to file in home folder
"~/bin/layout-switch.sh"
Alt + Shift_L
@fomigo
fomigo / wp_the_slug.php
Last active October 5, 2020 20:55
wp: get the slug in the loop
<?php
function the_slug($echo = true)
{
/*
$post_data = get_post(get_the_ID(), ARRAY_A);
$slug = $post_data['post_name'];
*/
$slug = basename(get_permalink());
@fomigo
fomigo / path.md
Created September 10, 2020 15:06 — forked from nex3/path.md

The PATH is an important concept when working on the command line. It's a list of directories that tell your operating system where to look for programs, so that you can just write script instead of /home/me/bin/script or C:\Users\Me\bin\script. But different operating systems have different ways to add a new directory to it:

Windows

  1. The first step depends which version of Windows you're using:
  • If you're using Windows 8 or 10, press the Windows key, then search for and
@fomigo
fomigo / hello.vue
Created May 19, 2020 14:40 — forked from ryenski/hello.vue
Stimulus.js + Vue.js
<template>
<div id="app">
<p>{{ message }}</p>
</div>
</template>
<script>
export default {
data: function () {
return {