Skip to content

Instantly share code, notes, and snippets.

@CarsonF
CarsonF / ForcedSelectionAutoComplete.jsx
Last active December 20, 2016 05:50
Material UI AutoComplete Forced Selection
import React from 'react';
import ReactDOM from 'react-dom';
import { FormattedMessage } from 'react-intl';
import { AutoComplete as MuiAutoComplete } from 'material-ui';
class AutoComplete extends MuiAutoComplete {
/**
* Added callback param
*/
close(cb?: () => any) {
@CarsonF
CarsonF / .bash_profile
Created August 24, 2016 20:14
Symfony Console Bash Completion
#!/usr/bin/env bash
function _symfony_complete {
local CMDLINE_CONTENTS="$COMP_LINE"
local CMDLINE_CURSOR_INDEX="$COMP_POINT"
local CMDLINE_WORDBREAKS="$COMP_WORDBREAKS";
export CMDLINE_CONTENTS CMDLINE_CURSOR_INDEX CMDLINE_WORDBREAKS
local RESULT STATUS;
@CarsonF
CarsonF / example.tsx
Last active November 2, 2017 05:44
Redux Form V6 typescript definition
// This doesn't have everything but it gives an idea of how the interfaces and decorator should be used.
interface LoginFormData {
username?: string;
password?: string;
}
interface LoginFormProps extends FormProps<LoginFormData, AppState> {
dispatch?: Dispatch<AppState>,
}
@CarsonF
CarsonF / ssh-fingerprints
Created April 20, 2016 17:37
Lists SSH public key fingerprints
#!/usr/bin/env bash
# Lists SSH public key fingerprints
file=$1
hash=""
if [[ "$OSTYPE" == "darwin"* ]]; then
hash="-E MD5"
fi
@CarsonF
CarsonF / composer.sh
Last active January 19, 2024 11:10
Global Composer Setup
#!/usr/bin/env bash
# As root
# Make config and data dirs
mkdir /etc/composer -p || exit 1
mkdir /var/lib/composer -p
# Set composer home dir to global location
cat << EOF > /etc/profile.d/composer.sh
#!/usr/bin/env bash
@CarsonF
CarsonF / Filesystem Finding.php
Last active September 30, 2015 18:41
Using Symfony's Finder with our Filesystem abstraction...
<?php
use Bolt\Filesystem\Filesystem;
use Bolt\Filesystem\Local;
$fs = new Filesystem(new Local(__DIR__));
foreach ($fs->find()->files() as $file) {
/** @var \Bolt\Filesystem\File $file */
echo $file->getFilename() . '\n';
@CarsonF
CarsonF / CarbonType.php
Last active August 29, 2015 14:27
Doctrine DBAL Carbon Integration
<?php
use Carbon\Carbon;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\DateTimeType;
/**
* Updates DateTime objects to return Carbon instance
*/
class CarbonType extends DateTimeType
@CarsonF
CarsonF / dump.php
Created July 17, 2015 14:12
Dumps pimple container for silex plugin
<?php
use Sorien\Provider\PimpleDumpProvider;
use Symfony\Component\HttpFoundation\Request;
require_once __DIR__ . '/vendor/autoload.php';
$app = new \Bolt\Application();
$request = Request::create('/');
Request::setFactory(function () use ($request) {
<?php
namespace Log;
use Common\Config;
use GMO\Cache\CacheKeys;
use GMO\Common\String;
use Log\Handler\LogstashHandler;
use Log\Processor\EnvProcessor;
use Log\Processor\RequestProcessor;
use Monolog\Handler\ChromePHPHandler;
<?php
namespace GMO\Common;
class Http {
/**
* A list of HTTP headers to choose the original client IP address from. In
* addition to these the RemoteAddr (REMOTE_ADDR) is also used as a final
* fallback.
*/