Skip to content

Instantly share code, notes, and snippets.

@philcali
philcali / function.sh
Last active June 12, 2022 17:21
Bash AWS Lambda runtime for converting raw h264 to mkv
#!/bin/bash
# Env to help ffmpeg to convert the raw stream to desirable framerate
FRAMERATE=${FRAMERATE:-15}
# Env to route converted video to new base prefix
CONVERSION_PATH=${CONVERSION_PATH:-motion_videos_converted}
# Env param to control which output you want.. ie 'mp4' for browser baseed video
CONVERSION_FORMAT=${CONVERSION_FORMAT:-mkv}
function handler () {
@philcali
philcali / parse_google_form.py
Created December 6, 2019 00:18
Simple script to output multiple files from Google form submissions.
import csv
import sys
with open(sys.argv[1]) as csvfile:
reader = csv.reader(csvfile)
rows = list(reader)
headers = rows[0][2:]
answers = rows[1:]
for answer in answers:
content = answer[2:]
@philcali
philcali / dod.lmxml
Created September 8, 2012 19:42
Puppet script to download latest DoD entries
browser
config
user-agent "Mozilla/5.0"
follow-redirects "true"
keep-alive "true"
instructions
[homepage]
---
val Dollar = """\$\s*(\d+\.\d+)\s*""".r
import Dollar.{ findFirstMatchIn => line }
import io.Source.{ fromFile => open}
val sum = (0.00 /: open("expenses.txt").getLines)(_ + line(_).map(_.group(1).toDouble).getOrElse(0.0))
println("Total is: $%.2f" format sum)
@philcali
philcali / do_it.scala
Created July 24, 2012 20:24
Massaging submodule
import scala.io.Source.{fromFile => open}
import scala.sys.process._
if (args.length < 1) {
println("Give me an existing .gitmodules file to copy")
exit(0)
}
val Submodule = """\[submodule "(.*)"\]""".r
val Url = """\s+url = (.*)""".r
@philcali
philcali / rm_gitmodules.sh
Created March 28, 2012 19:53
Safely removes submodules from a git repository.
#!/bin/sh
echo Removing .git directories in the submodules
cat .git/config | grep submodule | sed 's/\[submodule \"\(.*\)"\]/\1/' | xargs find | grep "./.git$" | xargs rm -r
echo Removing .git cached
cat .git/config | grep submodule | sed 's/\[submodule \"\(.*\)"\]/\1/' | xargs git rm --cached
echo Remove submodule entries from .gitmodules
git rm .gitmodules
@philcali
philcali / dod.scala
Created September 3, 2011 01:42
A simple stand-alone scala script to pull DoD entries.
if (args.length < 1) {
println("Please provide a date, in the form of year-month. ie: 11-08")
}
import java.net.URL
import java.io._
def read(in: InputStream, out: OutputStream) {
val buf = new Array[Byte](1024)
in read(buf) match {
@philcali
philcali / AndroidBuild.scala
Created July 23, 2011 20:36
sbt 10.x multiple android project example definition
import sbt._
import Keys._
import AndroidKeys._
// General object adds all modular android settings appropriately
object General {
val settings = Defaults.defaultSettings ++ Seq (
version := "0.1.0",
organization := "my.android.project"
@philcali
philcali / gist:1029230
Created June 16, 2011 13:31
Nicol project definition
// sbt 0.10 parent project definition
import sbt._
imoprt Keys._
object General {
val settings = Defaults.defaultSettings ++ Nicol.engineSettings ++ Seq (
organization := "com.github.scan",
version := "0.1.0.1",