Skip to content

Instantly share code, notes, and snippets.

View ryanscherler's full-sized avatar

Ryan Scherler ryanscherler

View GitHub Profile
@insin
insin / app.js
Last active May 30, 2023 19:51
React Router Test / nwb/React/surge setup - live version: http://tasty-flavor.surge.sh/ - nwb: https://github.com/insin/nwb
import React from 'react'
import {render} from 'react-dom'
import {browserHistory, IndexRoute, IndexLink, Link, Route, Router} from 'react-router'
let activeStyle = {fontWeight: 'bold'}
let App = ({children}) => <div>
<h1>App</h1>
<ul>
<li><IndexLink activeStyle={activeStyle} to="/">Home</IndexLink></li>
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@ryanscherler
ryanscherler / Instagram WP Transient
Created April 27, 2016 00:24
Gets Recent Instagrams and sets as WP transient.
<?php
namespace Starter\Extras;
function instagramUserMedia($token, $count = 6, $minutes = 5) {
$results = [];
$transient_key = __NAMESPACE__ . 'instagram';
if (!$results = get_transient($transient_key)) {
$ch = curl_init();
curl_setopt_array($ch, array(
@ckressibucher
ckressibucher / cliserver.php
Last active August 27, 2024 12:44
Router script for PHP built in server
<?php
// public/cliserver.php (router script)
if (php_sapi_name() !== 'cli-server') {
die('this is only for the php development server');
}
if (is_file($_SERVER['DOCUMENT_ROOT'].'/'.$_SERVER['SCRIPT_NAME'])) {
// probably a static file...
return false;
@JacobBennett
JacobBennett / blog.md
Last active March 15, 2025 10:04
API Token Authentication in Laravel 5.2 & 5.3

I recently had the need to write a small url shortening application. I am aware that this problem has been solved quite a few times before, but what is being a developer if not reinventing the wheel just for the heck of it? Custom CMS anyone?

Knowing that this was going to be a tiny RESTful API and also knowing that Laravel 5.2 had API rate limiting built in, I was eager to give it a try. Taylor Otwell being Taylor Otwell shipped 5.2 with the rate limiting defaults set up out of the box and I had my application building out short url's in a matter of minutes. The problem for me came when I wanted to start associating those short urls with a user.

Typically my applications have a UI and authentication is done through a simple login page. Obviously for a RESTful API, having a login page isn't ideal. Instead, my hope was to have users append an api_token to the end of their query string and use that to auth

@mattclements
mattclements / function.php
Last active September 30, 2025 07:50
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@freekrai
freekrai / wordpress-using-multisite-domain-mapping-on-a-mediatemple-grid-server.md
Created August 27, 2015 00:44
WordPress: Using multisite domain mapping on a mediatemple grid server

This won’t get into setting up multisite in wordpress, but it will help you set up multisite domain mapping on a grid server from media temple. If you need to see a good intro article on setting up multisite mode in wordpress, check this article out or this article for a good multisite .htaccess intro.

First, install WordPress MU Domain Mapping plugin, and follow the instructions for setting that up.

Now, to add a new domain to media temple that will show up on your site, the big catch is to redirect this domain to the existing main domain.

For example, originalsite.com is the main root domain, and I am going to create newsite.com.

  1. Add the domains you’d like to use (newsite.com in this example) as alternate domains in the AccountCenter.
  2. Log into your (gs) via SSH, move into the domains direc
@amsgames
amsgames / laravel-5-audio-validator.php
Last active September 16, 2019 05:36
Laravel 5 Audio File Validation, Custom audio validation rules.
<?php
namespace App\Services;
/**
* Custom validator rules.
* Add this at app\Services
*
* @author Alejandro Mostajo <[email protected]>
*/
@mabasic
mabasic / helpers.php
Last active February 3, 2025 19:47
config_path function for Lumen framework
<?php
if ( ! function_exists('config_path'))
{
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
<?php
kirby::$handlers['template'] = function($kirby, $page, $data = array()) {
require_once(__DIR__ . DS . 'vendor' . DS . 'autoload.php');
$loader = new Twig_Loader_Filesystem($kirby->roots()->templates());
$twig = new Twig_Environment($loader, array(
'cache' => false
));