Skip to content

Instantly share code, notes, and snippets.

View ramonfincken's full-sized avatar

Ramon Fincken ramonfincken

View GitHub Profile
/**
* @brief Splits an address string containing a street, number and number addition
*
* @param $streetStr string An address string containing a street, number (optional) and number addition (optional)
*
* @return array Data array with the following keys: street, number and numberAddition.
*/
private function split_street($streetStr) {
$aMatch = array();
@johnwesonga
johnwesonga / unique elements in a slice
Created August 22, 2013 00:29
Go code that ensures elements in a slice are unique
package main
import "fmt"
func uniqueNonEmptyElementsOf(s []string) []string {
unique := make(map[string]bool, len(s))
us := make([]string, len(unique))
for _, elem := range s {
if len(elem) != 0 {
if !unique[elem] {
@aderaaij
aderaaij / yoast
Last active April 3, 2024 20:11
Wordpress - Move yoast seo boxes to bottom of post/page
// Move Yoast to bottom
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');
@benallard
benallard / xml_split.py
Last active March 5, 2024 05:28
Small python script to split huge XML files into parts. It takes one or two parameters. The first is always the huge XML file, and the second the size of the wished chunks in Kb (default to 1Mb) (0 spilt wherever possible) The generated files are called like the original one with an index between the filename and the extension like that: bigxml.…
#!/usr/bin/env python
import os
import xml.parsers.expat
from xml.sax.saxutils import escape
from optparse import OptionParser
from math import log10
# How much data we process at a time
@jeremyfelt
jeremyfelt / open-source-search-compare.md
Last active July 19, 2023 01:28
Comparing open source search solutions
@stefanzweifel
stefanzweifel / slack.php
Created May 8, 2014 13:26
Slack.com Webhook Integration (PHP) - Simple snippet which tells you, how to build your payload array.
<?php
//Options
$token = 'YOUR_TOKEN_HERE';
$domain = 'YOUR_SLACK_DOMAIN_GOES_HERE';
$channel = '#general';
$bot_name = 'Webhook';
$icon = ':alien:';
$message = 'Your message';
@bekarice
bekarice / wc-custom-order-status-icon.php
Last active May 13, 2019 17:01
Add WooCommerce custom order status icon
/**
* Adds icons for any custom order statuses
* Tutorial: http://www.skyverge.com/blog/changing-woocommerce-custom-order-status-icons/
**/
add_action( 'wp_print_scripts', 'skyverge_add_custom_order_status_icon' );
function skyverge_add_custom_order_status_icon() {
if( ! is_admin() ) {
return;
}
@pgilad
pgilad / Instructions.md
Last active March 31, 2024 22:30
Git commit-msg hook to validate for jira issue or the word merge

Instructions

  • copy the file commit-msg to .git/hooks/commit-msg
  • make sure your delete the sample file .git/hooks/commit-msg.sample
  • Make commit msg executable. chmod +x .git/hooks/commit-msg
  • Edit commit-msg to better fit your development branch, commit regex and error message
  • Profit $$

Shell example

@trepmal
trepmal / gist:1c66dbe97e8f322bc107
Created December 19, 2014 22:42
wp-cli: reset all user passwords
#!/bin/bash
for uid in $(wp user list --field=ID)
do
pass=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}`
wp user update $uid --user_pass="$pass"
done
@gwillem
gwillem / robots.txt
Created January 5, 2016 12:48
Sample robots.txt for Magento on Hypernode
User-agent: *
Allow: /
Crawl-delay: 25
sitemap: http://magentotestpakket.nl/sitemap.xml
Disallow: /*?p=
Disallow: /*&p=
Disallow: /*?price=
Disallow: /*&price=
Disallow: /*?color=