Skip to content

Instantly share code, notes, and snippets.

View alairock's full-sized avatar

Skyler Lewis alairock

View GitHub Profile
@alairock
alairock / xml2phparray.php
Last active February 3, 2017 19:28
convert XML data into a PHP Array
<?php
/*
Working with XML. Usage:
$xml=xml2ary(file_get_contents('1.xml'));
$link=&$xml['ddd']['_c'];
$link['twomore']=$link['onemore'];
// ins2ary(); // dot not insert a link, and arrays with links inside!
echo ary2xml($xml);
*/
@alairock
alairock / recursechmod.php
Last active September 8, 2022 15:18
Recursive Chmod in php
<?php
function recursiveChmod ($path, $filePerm=0644, $dirPerm=0755) {
// Check if the path exists
if (!file_exists($path)) {
return(false);
}
// See whether this is a file
if (is_file($path)) {
// Chmod the file with our given filepermissions
@alairock
alairock / GeoCaching API
Last active December 19, 2015 11:09
GeoCaching via CakePHP. Shows how to use connect via Oauth, get the token, and use the token to process a post request.
<?php
//Place the following line above the class:
//App::import('Vendor', 'OAuth/OAuthClient');
//OAuth component found here: http://code.42dh.com/oauth/
public function index() {
$data = array(
'AccessToken' => $this->Session->read('access_token'),
'Usernames' => array('alairock'),
@alairock
alairock / funky-fresh.js
Last active February 3, 2017 19:24
Custom parallax effect
/**
* Main JS file for Casper behaviours
*/
$(document).ready(function(){
var lastScrollTop = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
var scrolli = st/1.5;
scrollicious = $(".cover-image > img").css({"top": scrolli + "px"});
if (st > lastScrollTop){

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this-&gt;anything()
@alairock
alairock / styles.less
Last active October 3, 2019 15:49
Atom.io custom styling.
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
@alairock
alairock / background.js
Created October 30, 2015 16:10 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@alairock
alairock / Stripe.php
Last active August 29, 2020 19:37
Get a Stripe token in PHP/Laravel. Helpful when testing.
<?php
Route::get('/stripetoken', function()
{
$client = new \GuzzleHttp\Client();
$pubKey = 'pk_test_xxxxxxxxxxxxx';
$cardNumber = "4242424242424242";
$cvc = "123";
$expMonth = "11";
$expYear = "2018";
@alairock
alairock / generator.php
Last active February 3, 2017 19:31
Using a Generator in PHP. Helpful when you need to work on hundreds....thousands....millions of records. Don't load them all into memory all at once. Work on them one at a time!
<?php
$usersQuery = \App\User::query();
$usersQuery->where('type', '=', 'client');
foreach(generate($usersQuery) as $user) {
// Do something with that user
}

Keybase proof

I hereby claim:

  • I am alairock on github.
  • I am alairock (https://keybase.io/alairock) on keybase.
  • I have a public key ASBhALIeRnQkHI9MccUghiVQ9kCz14yoViFb1wNaXWrA-go

To claim this, I am signing this object: