Skip to content

Instantly share code, notes, and snippets.

View ptcampbell's full-sized avatar
🌲
(◍•﹏•)

Patrick Campbell ptcampbell

🌲
(◍•﹏•)
View GitHub Profile
@rec
rec / airtime-ubuntu.md
Last active July 15, 2017 15:18
Installing SourceFabric's Airtime on a clean Ubuntu server running Virtualmin.

Installing SourceFabric's Airtime on a clean Ubuntu server running Virtualmin.

I'm documenting my experience installing SourceFabric's open source radio station manager Airtime on a clean server Ubuntu 12.04 LTS (Precise Pangolin) server running the popular Virtualmin open-source domain manager.

Virtualmin is sufficiently generic that I imagine the results will be useful to anyone trying to install Airtime on Ubuntu 12.04.

Before you start.

@alexvcasillas
alexvcasillas / store-union-test.js
Last active June 10, 2018 22:34
Types Union Thing
import { types } from 'mobx-state-tree';
const ItemUI = types.model(
'ItemUI',
{
id: types.identifier(),
position: types.optional(types.frozen, { x: 0, y: 0 }),
text: types.string,
width: types.string,
height: types.string,
{% layout none %}
{% paginate collections by 50 %}
{
"collections": [{% for collection in collections %}
{
{% if collection.image %}"image": "{{ collection.image }}",{% endif %}
"body_html": "{{ collection.description | url_escape }}",
"handle": "{{ collection.handle }}",
"id": {{ collection.id }},
/* global localStorage */
import {observable, autorunAsync} from 'mobx'
import _ from 'lodash'
function storedObservable (key, defaultValue, debounce) {
let fromStorage = localStorage.getItem(key)
const defaultClone = _.cloneDeep(defaultValue) // we don't want to modify the given object, because userscript might want to use the original object to reset the state back to default values some time later
if (fromStorage) {
_.merge(defaultClone, JSON.parse(fromStorage))
}
@Juhlinus
Juhlinus / OrganizationsController.php
Last active July 7, 2020 09:40
A more elegant way to handle validation in Inertia.js
<?php
namespace App\Http\Controllers;
use App\Http\Requests\StoreOrganization;
use App\Organization;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Request;
use Inertia\Inertia;
@jordanburke
jordanburke / Upload.tsx
Last active December 29, 2020 22:44
React Simple S3 Uploader
import React, {useState} from "react";
import axios from "axios";
import config from "../config"
const endpoint = config.apiGateway.URL;
export const Upload = () => {
const [file, setFile] = useState<File | undefined>()
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;
class DOSpacesStorageServiceProvider extends ServiceProvider
{
/**
@kjbrum
kjbrum / search_for_value.php
Last active March 20, 2021 06:24
Check if a value exists in an array/object.
<?php
/**
* Check if an array is a multidimensional array.
*
* @param array $arr The array to check
* @return boolean Whether the the array is a multidimensional array or not
*/
function is_multi_array( $x ) {
if( count( array_filter( $x,'is_array' ) ) > 0 ) return true;
return false;
@oncomouse
oncomouse / StyledTransition.js
Last active April 15, 2021 05:24
Using CSSTransitionGroup with Emotion.js
import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { CSSTransition } from 'react-transition-group';
const has = (key, obj) => Object.prototype.hasOwnProperty.call(obj, key);
const keyframes = [
'appear',
'enter',
@reecelucas
reecelucas / useScrollDirection.js
Last active September 8, 2021 20:07
React hook to detect scroll direction, based on the API of https://github.com/dollarshaveclub/scrolldir
const SCROLL_UP = "up";
const SCROLL_DOWN = "down";
const useScrollDirection = ({
initialDirection,
thresholdPixels,
off
} = {}) => {
const [scrollDir, setScrollDir] = useState(initialDirection);