Skip to content

Instantly share code, notes, and snippets.

@CarsonF
CarsonF / ForcedSelectionAutoComplete.jsx
Last active Dec 20, 2016
Material UI AutoComplete Forced Selection
View ForcedSelectionAutoComplete.jsx
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 Aug 24, 2016
Symfony Console Bash Completion
View .bash_profile
#!/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 Nov 2, 2017
Redux Form V6 typescript definition
View example.tsx
// 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 Apr 20, 2016
Lists SSH public key fingerprints
View ssh-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 Nov 11, 2021
Global Composer Setup
View composer.sh
#!/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 Sep 30, 2015
Using Symfony's Finder with our Filesystem abstraction...
View Filesystem Finding.php
<?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 Aug 29, 2015
Doctrine DBAL Carbon Integration
View CarbonType.php
<?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 Jul 17, 2015
Dumps pimple container for silex plugin
View dump.php
<?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) {
View LogServiceProvider.php
<?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;
View Http.php
<?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.
*/