Skip to content

Instantly share code, notes, and snippets.

View simonpioli's full-sized avatar

Simon Pioli simonpioli

  • LawPlus Solicitors
  • Manchester, UK
View GitHub Profile
@simonpioli
simonpioli / ExampleComponent.vue
Last active February 18, 2022 13:03
Vue mixin to Use Laravel Mix manifest in templates
<template>
<figure><img :src="mix('example-asset.jpg')" alt=""></figure>
</template>
<script>
import {mix} from "./mix";
export default {
name: "ExampleComponent",
mixins: [mix]
@simonpioli
simonpioli / GooglePlusOneCount.php
Last active August 29, 2015 14:22
Get the Google Plus One count for a given URL
<?php
function getCount($url)
{
//Assumes Guzzle. As long as you make a request to the URL below and grab the body, it doesn't matter how you cURL.
$request = $this->getHttpClient()->get('https://plusone.google.com/_/+1/fastbutton?url='.urlencode($url));
$html = $request->send()->getBody();
// Disable libxml errors
libxml_use_internal_errors(true);
$document = new \DOMDocument();
@simonpioli
simonpioli / countcssrules.js
Created May 5, 2015 09:01
Counts CSS Rules and Selectors in every CSS file and dumps to the console
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
2014-09-23 18:28:32 +0100
./configure
--prefix=/usr/local/Cellar/php55/5.5.17
--localstatedir=/usr/local/var
--sysconfdir=/usr/local/etc/php/5.5
--with-config-file-path=/usr/local/etc/php/5.5
--with-config-file-scan-dir=/usr/local/etc/php/5.5/conf.d
--with-iconv-dir=/usr
--enable-dba
@simonpioli
simonpioli / fixPermissions.php
Created June 12, 2014 14:01
Recursive PHP CHMOD Script
<?php
function fixPermissions($path, $filemode = 0644, $dirmode = 0775)
{
$dir = new DirectoryIterator($path);
foreach ($dir as $item) {
if (!$item->isDot() && !$item->isLink()) {
if ($item->isFile()) {
if (chmod($item->getPathname(), $filemode)) {
echo "CHMOD file ".$item->getPathname()." to ".decoct($filemode)." successful\r\n<br>";
@simonpioli
simonpioli / ioshideaddress.js
Created October 9, 2013 14:10
Hide iOS Safari address bar on window load. Source: http://davidwalsh.name/hide-address-bar
// When ready...
window.addEventListener("load",function() {
// Set a timeout...
setTimeout(function(){
// Hide the address bar!
window.scrollTo(0, 1);
}, 0);
});
@simonpioli
simonpioli / stringtobool.js
Created June 26, 2013 11:12
Converts a string to boolean in Javascript. Useful if passing settings through data- attributes.
function stringToBoolean(string){
switch(string.toLowerCase()){
case "true": case "yes": case "1": return true;
case "false": case "no": case "0": case "": return false;
default: return Boolean(string);
}
}
@simonpioli
simonpioli / wp-excerpts.php
Last active December 18, 2015 19:29
Allows you to specify the excerpt length per page rather than through a global setting in your functions.php.
<?php
/** In functions.php **/
/**
* Customise Excerpt Length
* @param int $new_length Length of excerpt
* @param mixed $new_more String to output at the end of the excerpt, if false reverts to default
* @return type
*/
@simonpioli
simonpioli / database-backup.php
Created June 21, 2013 09:45
Retrieves Content from mySQL database and saves as a .sql file. c/o @darkwing
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
backup_tables('localhost','username','password','database');
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
@simonpioli
simonpioli / thedate.php
Last active December 16, 2015 16:49
mySQL Date Format in PHP. Because I'm fed up of Googling it all the time!
<?php
//To mySQL Format
date("Y-m-d H:i:s", $datetime);
//Back to legible
date("d/m/Y", strtotime($datetime));