Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shanecp
shanecp / LocationService.swift
Created September 26, 2022 00:09
Swift Location Distance Demo
import CoreLocation
struct Venue {
var name: String
var location: CLLocation
init(name: String, lat: Double, lng: Double) {
self.name = name
self.location = CLLocation(latitude: lat, longitude: lng)
@shanecp
shanecp / HasAttributesTrait.php
Last active September 9, 2020 01:22
PHP Magic Methods / Attributes
On a class, add the methods Trait
```
// define the properties
/* @property $name string User's name */
class MyClass {
// add the trait
use HasAttributes;
}
@shanecp
shanecp / compile-ffmpeg-source.md
Last active September 9, 2020 03:27
How to Compile FFMpeg to a Specific Version

How to Compile FFMpeg to a Specific Version

You can find FFMpeg compilation instructions from https://trac.ffmpeg.org/wiki/CompilationGuide

If you can't find a pre-built version of FFMpeg, you'll have to compile it from the source. By using the above link, you'll be getting the latest snapshot and it may not be the version you want. If you need to compile a specific version, follow the instructions below.

Pick the correct version you need from https://git.ffmpeg.org/ffmpeg

On the guide, follow all instructions upto 'FFMpeg' section, then instead of the snapshot build, switch to the version needed. (Using v4.3 on the example below)

@shanecp
shanecp / gist:db18c9fe5889e123d729aa110d5e807a
Created April 24, 2019 01:12
Freeze Google chrome to inspect the contents
setTimeout(function(){debugger;}, 5000);
@shanecp
shanecp / Intersect
Created April 14, 2019 02:58
Recursive Intersect for array subsets in PHP. Pass an array and a subset of an array. Returns the matching subset if it intersects.
<?php
namespace App\Domain;
class Intersect
{
@shanecp
shanecp / domdetailer.php
Created April 9, 2018 00:46
DomDetailer PHP Code
<?php
$results = [];
if (!empty($_POST['domains'])) {
$apiKey = 'INSERT_API_KEY';
$domains = explode("\n", $_POST['domains']);
foreach ($domains as $domain) {
@shanecp
shanecp / nginx_wordpress_subfolder.md
Last active December 22, 2017 15:39
nginx Configuration for WordPress subfolders

Setup WordPress in nginx within a subfolder. This example does the redirect to a folder called /blog. So you can have one installation at / and another at /blog Change [sitename].dev to the domain.

server {
	listen 80;
	listen [::]:80;
	server_name     [sitename].com.au www.[sitename].com.au;
    	# redirect all http traffic to https
	return          301 https://www.$server_name$request_uri;
@shanecp
shanecp / 0_reuse_code.js
Created March 12, 2016 12:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@shanecp
shanecp / error_libsass.md
Created March 12, 2016 04:03
Error: `libsass` bindings not found. Try reinstalling `node-sass`?

Error: libsass bindings not found. Try reinstalling node-sass?

npm uninstall --save-dev gulp-sass
npm install --save-dev gulp-sass

or try deleting node_modules and running npm install again. The cause of this is a conflict between node + npm + node-sass + gulp-sass.

@shanecp
shanecp / .bash_profile
Created November 27, 2015 23:37
.bash_profile for Terminal on OSX
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
alias a='php artisan'
alias reseed='php artisan migrate:refresh --seed'
alias cept='vendor/bin/codecept'
alias ioios='ionic run ios -l -c'
default_username='shane'