Skip to content

Instantly share code, notes, and snippets.

@bryanjswift
bryanjswift / inClassLoader.scala
Created January 19, 2012 03:56
Work around CaseClassSigParser exceptions in sbt:console

When doing something in an SBT console which requires the loading of Case Class instances via fig or jerkson if the code is executed within inClassLoader it will produce a result rather than a ClassNotFoundException.

For example in Persnicketly:

val articles = inClassLoader(classOf[com.persnicketly.persistence.Connection$]) {
  ScoredArticleDao.select(from = 60, count = 100)
}

Will successfully load MongoDB configuration from config.json, access the db and retrieve articles.

@bryanjswift
bryanjswift / build.sbt
Created March 8, 2012 15:37
Project files for debugging
organization := "com.momentumww"
name := "sxsw-12"
version := "0.0.5"
scalaVersion := "2.9.1"
resolvers ++= Seq(
"Bryan's Repo" at "http://repos.bryanjswift.com/maven2/"
@bryanjswift
bryanjswift / twitter-entities.js
Created August 19, 2012 02:31 — forked from wadey/twitter-entities.js
JavaScript parser for Tweet Entities
/*
* twitter-entities.js
* This function converts a tweet with "entity" metadata
* from plain text to linkified HTML.
*
* See the documentation here: http://dev.twitter.com/pages/tweet_entities
* Basically, add ?include_entities=true to your timeline call
*
* Copyright 2010, Wade Simmons
* Licensed under the MIT license
@bryanjswift
bryanjswift / vimeo.class.php
Created September 23, 2012 06:52
Perch2 field type for vimeo embeds. Heavily based on youtube.class.php by Drew McLellan.
<?php
/**
* A field type for Vimeo videos
*
* @package default
* @author Bryan Swift
*/
class PerchFieldType_vimeo extends PerchAPI_FieldType
{
package com.android.workaround;
import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
/**
* When an {@link Activity} is launched with
@bryanjswift
bryanjswift / Vagrantfile
Last active February 25, 2016 02:26 — forked from helloIAmPau/Vagrantfile
A file to install redis server onto an Ubuntu virtual machine.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
type Query {
article(id: ID!): Article
page(id: ID!): Page
product(id: ID!): Product
profile(id: ID!): Profile
}
type Article {
# Unique identifier for this piece of content */
id: ID!
@bryanjswift
bryanjswift / machine.js
Last active October 25, 2019 18:24
Generated by XState Viz: https://xstate.js.org/viz
//----------------------------------------
const findingDevice = {
initial: 'findingDevice',
states: {
/* BASE STATES */
foundDevice: {
type: 'final',
},
@bryanjswift
bryanjswift / machine.js
Last active November 9, 2019 01:45
Generated by XState Viz: https://xstate.js.org/viz
/**
* For a given `state` from `CompositeMachine` should the video indicated by
* `state.context.videoSrc` be in a playback state or a paused state.
* @param state node from the `CompositeMachine`.
* @returns `false` (indicating a playing state) or `true` (indicating a paused
* state). `null` or `undefined` state nodes are `true`.
*/
function isVideoPaused(state) {
if (state === null || state === undefined) {
return true;
const ComponentStateMachine = Machine({
id: 'component:record-screen',
initial: 'ssr',
states: {
ssr: {
on: {
MOUNT: {
target: 'loading',
},
},