Skip to content

Instantly share code, notes, and snippets.

View RickardAhlstedt's full-sized avatar

Rickard Ahlstedt RickardAhlstedt

View GitHub Profile
<?php
/**
* ContainerBridge.php
*
* Copyright © 2005-2006, FileMaker, Inc. All rights reserved.
* NOTE: Use of this source code is subject to the terms of the FileMaker
* Software License which accompanies the code. Your use of this source code
* signifies your agreement to such license terms and conditions. Except as
* expressly granted in the Software License, no other copyright, patent, or
* other intellectual property license or right is granted, either expressly or
@RickardAhlstedt
RickardAhlstedt / retry.php
Created May 5, 2020 12:10 — forked from HonzaMac/retry.php
Retry any function in php
<?php
if (!function_exists('retry')) {
/**
* Retries callable
*
* Could be specified how many times, default is 1 times.
*
* @param callable $what
* @param int $retry how many time should it be retried, default is 1
* @return mixed
@RickardAhlstedt
RickardAhlstedt / functions.php
Created April 7, 2020 09:39 — forked from maddisondesigns/functions.php
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
@RickardAhlstedt
RickardAhlstedt / php-webscraping.md
Created December 9, 2019 12:14 — forked from anchetaWern/php-webscraping.md
web scraping in php

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

{% blockquote %} Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox. {% endblockquote %}

@RickardAhlstedt
RickardAhlstedt / index.html
Created November 14, 2019 05:00 — forked from CodeMyUI/index.html
Sidebar Menu Hover Show/Hide CSS
<html>
<head>
</head>
<body><div class="area"></div><nav class="main-menu">
<ul>
<li>
<a href="http://justinfarrow.com">
<i class="fa fa-home fa-2x"></i>
<span class="nav-text">
@RickardAhlstedt
RickardAhlstedt / Exit.cs
Created July 24, 2019 07:17 — forked from IronMonk-UK/Exit.cs
The C# code for the Text Adventure
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TextAdventure
{
class Exit
{
@RickardAhlstedt
RickardAhlstedt / gist:ac4e98dd944124789487d89cf85a814b
Created November 12, 2018 20:37 — forked from dukeofharen/gist:e2c60b4478408b53d743
WordPress like shortcode parser for PHP
<?php
//The content which should be parsed
$content = '<p>Hello, my name is John an my age is [calc-age day="4" month="10" year="1991"].</p>';
$content .= '<p>Hello, my name is Carol an my age is [calc-age day="26" month="11" year="1996"].</p>';
//The array with all the shortcode handlers. This is just a regular associative array with anonymous functions as values. A very cool new feature in PHP, just like callbacks in JavaScript or delegates in C#.
$shortcodes = array(
"calc-age" => function($data){
$content = "";
//Calculate the age
<?php
class Registry {
/**
* @var array The store for all objects
*/
static private $store = array();
/**