Skip to content

Instantly share code, notes, and snippets.

View assertchris's full-sized avatar

Christopher Pitt assertchris

View GitHub Profile
@JustSteveKing
JustSteveKing / State.php
Created August 11, 2023 18:31
US States as a PHP Enum
<?php
declare(strict_types=1);
namespace App\Enums;
enum State: string
{
case ALABAMA = 'AL';
case ALASKA = 'AK';
@eridal
eridal / Compiler.java
Last active August 9, 2023 13:26
Java to PHP Compilation
package j2p;
import japa.parser.JavaParser;
import japa.parser.ParseException;
import japa.parser.ast.CompilationUnit;
import japa.parser.ast.ImportDeclaration;
import japa.parser.ast.PackageDeclaration;
import japa.parser.ast.body.BodyDeclaration;
import japa.parser.ast.body.ClassOrInterfaceDeclaration;
import japa.parser.ast.body.FieldDeclaration;
Function.prototype.compile = function() {
var template = this.toString().split('\n').slice(1,-1).join('\n') + '\n';
return Ember.Handlebars.compile(template);
}
/*******************************************************/
test('sets first tab found to active', function() {
expect(2);
var component = this.subject({
@padraic
padraic / survey.php
Last active August 29, 2015 13:56
Enumerating Composer packages for PHPCS analysis and data collection
<?php
define('PACKAGE_LIST', 'list.txt');
define('CODING_STANDARD', 'PSR2');
define('SEVERITY', 1);
define('ENCODING', 'utf-8');
define('REPORT', 'source');
define('EXTENSIONS', 'php');
$excluded = [
'*/test/*',
@codeguy
codeguy / geocode-address.js
Created September 24, 2013 18:37
Geocode address with Google Maps API
/**
* Geocode address
*
* REQUIREMENTS
* - Google Maps API
* - HTML5 Geolocation API
*/
var geocode = function (address, onSuccess, onError) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ address: address }, function (results, status) {
/**
* Utility class for dealing with SVG elements
* Copyright Virtuosi Media, Inc. 2012
* MIT License
*/
var SVG = new Class({
/**
* @param string - el - The type of SVG element
* @param object - options - The attributes and values for the SVG element, stored in a hash
@wayneashleyberry
wayneashleyberry / latlng.php
Created November 26, 2012 11:20
maps api latlng
<?php
function get_latlng ($address)
{
// api key
$key = '';
// maps geocode api request
$url = "https://maps.googleapis.com/maps/api/geocode/json";
$query = "?address=" . urlencode($address) . "&sensor=false";
@wayneashleyberry
wayneashleyberry / gist:3893207
Created October 15, 2012 15:49
fuzzy string matching in javascript
var people = ['Daniel', 'Dustin', 'David', 'Damarcus', 'Russ'];
function matchPeople(input) {
var regex = new RegExp('[' + input.split('').join(']+.*[') + ']+', 'ig');
return people.filter(function(person) {
if (person.match(regex)) return person;
});
}
console.log(matchPeople('dvd')); // returns ['David']
@cheeaun
cheeaun / putonglasses.txt
Created September 14, 2012 08:57
put on glasses unicode
•_•)
( •_•)>⌐■-■
(⌐■_■)
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body
{
margin: 0;
padding: 0;
background: #fff;