Skip to content

Instantly share code, notes, and snippets.

View sfines's full-sized avatar

Steven Fines sfines

View GitHub Profile
@pheymann
pheymann / GenericCaseClassDiff.scala
Last active June 12, 2020 22:21
Generic `case class` instance diff's (aka. comparing instance fields and output differences)
import shapeless._
import shapeless.labelled.FieldType
import shapeless.record._
trait GenericDiff[H <: HList] {
// syntactic sugar
type HI = H
// compares field values and returns the field name with values if they differ
@mrlesmithjr
mrlesmithjr / ansible-macos-homebrew-packages.yml
Last active October 29, 2024 13:33
Install MacOS Homebrew Packages With Ansible
---
- name: Install MacOS Packages
hosts: localhost
become: false
vars:
brew_cask_packages:
- atom
- docker
- dropbox
- firefox
@ymauray
ymauray / extract_video.sh
Created July 15, 2016 19:34
How to cut a video file on black keyframes
# Re-encode source video with one keyframe every 5 frames
ffmpeg -i source.mkv -g 5 tmp.mkv
# Search black frames
ffmpeg -i tmp.mkv -vf blackframe -f null -
# Use output to locate black frames right on keyframes
# Then cut video at those keyframes
ffmpeg -i tmp.mkv -ss 6.089 -to 180.263 -c copy tmp2.mkv
@ConnorDoyle
ConnorDoyle / ReflectionHelpersSnippet.scala
Last active January 26, 2022 20:00
Generic reflective case class instantiation with Scala 2.10.x
package test
import scala.reflect.runtime.universe._
object ReflectionHelpers extends ReflectionHelpers
trait ReflectionHelpers {
protected val classLoaderMirror = runtimeMirror(getClass.getClassLoader)
@dfalster
dfalster / addNewData.R
Last active February 19, 2023 00:29
The function addNewData.R modifies a data frame with a lookup table. This is useful where you want to supplement data loaded from file with other data, e.g. to add details, change treatment names, or similar. The function readNewData is also included. This function runs some checks on the new table to ensure it has correct variable names and val…
##' Modifies 'data' by adding new values supplied in newDataFileName
##'
##' newDataFileName is expected to have columns
##' c(lookupVariable,lookupValue,newVariable,newValue,source)
##'
##' Within the column 'newVariable', replace values that
##' match 'lookupValue' within column 'lookupVariable' with the value
##' newValue'. If 'lookupVariable' is NA, then replace *all* elements
##' of 'newVariable' with the value 'newValue'.
##'
@landonf
landonf / pcap.go
Last active August 29, 2024 05:15
Go C ffi example
/*
* Copyright (c) 2013 Landon Fuller <[email protected]>
* All rights reserved.
*/
/* Interface to the native pcap(3) library */
package pcap
/*
#cgo LDFLAGS: -lpcap
@switzer
switzer / gist:4218526
Created December 5, 2012 19:03
Custom Mongodb Serializer/Deserializer
package com.example.core.application
import com.mongodb.casbah.Imports._
import java.util.UUID
import com.example.domain.{User, Address, Customer}
/**
* Contains type classes that deserialize records from Casbah into "our" types.
*/
trait CasbahDeserializers {
@kerrizor
kerrizor / gist:1359716
Created November 11, 2011 23:53
Actual code we found buried DEEP in a repo our offshore devs wrote a year ago
if (isTrue)
{
// return true value
return true;
}
else
{
// if not...
// return false value
return false;