Skip to content

Instantly share code, notes, and snippets.

View aderowbotham's full-sized avatar
👽

Adrian Rowbotham aderowbotham

👽
View GitHub Profile
@prehensile
prehensile / dj-rnn.txt
Last active September 4, 2018 23:44
9012 DJ names generated by torch-rnn, trained on listings at residentadvisor.net
Aromino Lu
Farlos Gabate
Kukog Gracux
Cassunex De 90C
Alex Nede
Jeerra Bylentron
Eddeysive
Fair Figo
Andries Gamper
Ladewenteah
@mlynch
mlynch / info.plist
Last active August 6, 2023 07:31
Disable App Transport Security in iOS 9
<!--
This disables app transport security and allows non-HTTPS requests.
Note: it is not recommended to use non-HTTPS requests for sensitive data. A better
approach is to fix the non-secure resources. However, this patch will work in a pinch.
To apply the fix in your Ionic/Cordova app, edit the file located here:
platforms/ios/MyApp/MyApp-Info.plist
And add this XML right before the end of the file inside of the last </dict> entry:
@iainmullan
iainmullan / version_cmp.php
Created September 17, 2014 15:36
Compare version numbers of the format X.Y.Z (major.minor.patch)
<?php
/**
* Compare version numbers of the format X.Y.Z where X,Y,Z are non-negative integers
* Values with less than three parts will be padded out with zeros, eg. "1.1" becomes "1.1.0", "1" becomes "1.0.0"
*
* @return 1 if $a is greater (a later version) than $b, 0 if $a is equal to $b, -1 if $a is less (an earlier version) than $b
*
*/
function version_cmp($a, $b) {
@idleberg
idleberg / Install-Mcrypt.md
Last active May 31, 2023 17:13
Install Mcrypt on macOS

Setup php-mcrypt on macOS (and versions of Mac OS X)

These steps should have been mentioned in the prerequisites of the Laravel Installation Guide, since I'm surely not the only person trying to get Laravel running on macOS.

Install

Install Mcrypt using Homebrew and PECL (comes with PHP)

# PHP 7.3
@axemonkey
axemonkey / fp
Created July 25, 2013 16:31
Everyone should have this in their .bash_profile
alias fp="echo -e ' _______...\n .-‘”..........``~.\n ,.-”..................“-.\n ,/........................”:\n ,?............................\ \n /..............................,}\n /...........................,:\`^\`.}\n /..........................,:”..../\n ?...__......................:\`...../\n /__.(...“~-,_.............,:\`...../\n /(_..”~,_....“~,_..........:\`...._/\n {._$;_...”=,_....“-,_...-~/~},.~”/.}\n ((...*~_....”=-._...“;,./\`./”...../\n \\\`~,...“~.,..........\`...}....../\n (..\`=-,,....\`............(...\_,-”\n /.\`~,...\`-................\\../^\\ \n \\\`~.*-,...................|/...\,__\n,,_ }.>-._\..................|........\`=~-,.. \n...\`=~-,_\\_...\`\\,.................\\.............. \n..........\`=~-,,.\\,................\\............. \n................\`:,,..............\`\\.......__.... \n...................\`=-,..........,%\`>--
@irazasyed
irazasyed / Install Composer using MAMP's PHP.md
Last active April 2, 2024 18:45
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@simonwhitaker
simonwhitaker / postcode-regex.js
Last active December 15, 2023 11:29
An example of using a simplified UK postcode regex in Javascript
var tweet = "Currently chilling out at W1B 2EL, then on to WC2E 8HA or maybe even L1 8JF! :-)";
// Here's a simple regex that tries to recognise postcode-like strings.
// See http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
// for the rules on how UK postcodes are formatted.
var postcode_regex = /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/g;
var postcodes = tweet.match(postcode_regex);
console.log(postcodes);
@philsturgeon
philsturgeon / gist:5465246
Last active May 23, 2022 12:29
API Golden Rules

Never Expose DB Results Directly

  1. If you rename a field, then your users are fucked. Convert with a hardcoded array structure.
  2. Most DB drivers [for PHP] will show integers as numeric strings and false as "0", so you want to typecast them.
  3. Unless you're using an ORM with "hidden" functionality, people will see passwords, salts and all sorts of fancy codes. If you add one and forget to put it in your $hidden array then OOPS!

Use the URI sparingly, and correctly

  1. Use the query string for paired params instead of /users/id/5/active/true. Your API does not need to be SEO optimised.
  2. ?format=xml is stupid, use an Accept: application/xml header. I added this to the CodeIgniter Rest Server once for lazy people, and now people think it's a thing. It's not.
@adnan-i
adnan-i / angular-timeout.html
Last active March 16, 2017 11:55 — forked from orjan/angular-timeout.html
Workaround for $httpProvider.defaults As discussed here http://stackoverflow.com/a/15020611/1095616, it is not possible to set default timeout in $httpProvider. This gist offers a workaround.
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
</head>
<body>
<div ng-controller="TodoCtrl">
<button ng-click="beQuickOrBeDead()">Fetch with 100ms timeout</button>
<button ng-click="neverEndingStory()">Fetch with default timeout</button>
@ecowden
ecowden / angular-partial-cache-busting
Created January 25, 2013 21:01
Cache busting for AngularJS partials is easy
/*
* Decide on your cache-busting strategy. In this example, we use the current timestamp, which will
* force a change every time the app is visited, but not every time the partial is loaded within a
* visit. Even better would be to use a hash of the file's contents to ensure that the file is always
* reloaded when the file changes and never reloaded when it isn't.
*/
var cacheBustSuffix = Date.now();
// Optionally, expose the cache busting value as a constant so other parts of your app can use it.
ngModule.constant("cacheBustSuffix", cacheBustSuffix);