Skip to content

Instantly share code, notes, and snippets.

View TakesTheBiscuit's full-sized avatar

Paul TakesTheBiscuit

  • United Kingdom
  • 07:45 (UTC +01:00)
View GitHub Profile
<?php
// just because this isn't wordpress..
$dummy_post = array('title'=>'the post name', 'body'=>'some post content');
$posts = array($dummy_post ,$dummy_post ,$dummy_post,$dummy_post,$dummy_post,$dummy_post );
$track_count = 0;
$posts_output = [];
foreach ($posts as $index => $post) {
@TakesTheBiscuit
TakesTheBiscuit / composer.json
Created August 30, 2017 11:13
Autoload metapack php shipping library wrapper client using composer
{
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": ["app/Libraries/metapack_client_v5.php"]
@TakesTheBiscuit
TakesTheBiscuit / lookup.php
Created September 15, 2017 12:16
Police UK postcode lookup
<?php
$addresses = explode('||',file_get_contents('https://ukpoliceimageappeal.co.uk/postcode/lookup?code=m146pb'));
if (count($addresses)) {
foreach ($addresses as $address) {
echo str_replace('//',', ',str_replace(' ','',$address));
echo "<hr>";
}
}
?>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
String inputString = ""; // a String to hold incoming data
@TakesTheBiscuit
TakesTheBiscuit / payload_templated_inputs.php
Created February 9, 2018 21:31
Payload templated inputs for semi dynamic API responses and input cycle
<?php
// P.D / TakesTheBiscuit proof of concept 9-2-2018 21:00
// This small demo shows how you can send an input template
// .. back to an api client (for example) which can then be auto populated
Class micro_api {
public function getResponse($input_id) {
@TakesTheBiscuit
TakesTheBiscuit / property_exists.php
Created February 12, 2018 15:10
PHP property exists check
<?php
$str = json_encode(['test'=>true]);
$obj = json_decode($str);
var_dump($obj);
echo PHP_EOL.'<br>';
$keys = [
'tests',
@TakesTheBiscuit
TakesTheBiscuit / send.php
Created February 16, 2018 13:53
Sendgrid Example
<?php
// If you are using Composer (recommended)
require 'vendor/autoload.php';
// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");
$from = new \SendGrid\Email("Example User", "test@example.com");
$subject = "Sending with SendGrid is Fun";
$to = new \SendGrid\Email("Example User", "takesthebiscuit@somewherenevereverever.co.uk");
@TakesTheBiscuit
TakesTheBiscuit / reverse_word_search.php
Created February 21, 2018 17:26
Reverse word search when reading direction is LTR
<?php
$wildcard_array = explode(' ', 'Delivered to neighbouring city signed for by github.com/TAKESTHEBISCUIT');
echo '<pre>';
print_r(reverseWildcard($wildcard_array));
echo '</pre>';
function reverseWildcard($wildcard_arr_of_words) {
$working_arr = $wildcard_arr_of_words;
$sentences = [];
if ($wildcard_arr_of_words != false) {
<?php
$arr = ["7",
"13",
"4",
"5",
"13",
"18",
"28",
"7",
<?php
$stringage = [
'order_id'=>'5678',
'name'=>'NO ONE cares'
];
echo replace_with_personal_data('There was a problem on order #[order_id] please phone [name]', $stringage);