Skip to content

Instantly share code, notes, and snippets.

View dnorton's full-sized avatar
🏠
Working from home

Daniel Norton dnorton

🏠
Working from home
View GitHub Profile
@dnorton
dnorton / sum_times.py
Last active September 14, 2016 20:25
python script to calculate average pace
"""Script to add up minutes:seconds and give average pace"""
def sum_times(*times):
'''arg list of MM:SS'''
return sum(map(lambda x: int(x.split(':')[0]) * 60 + int(x.split(':')[1]), times)), len(times)
def secs_to_mins(seconds, count):
from __future__ import with_statement
import csv
import re
"""
Parse a CSV file with multiple column counts
e.g., foo_1, foo_2
The result will be a single column, foo
@dnorton
dnorton / debug.gradle
Created June 13, 2016 19:56
A couple small tasks for debugging gradle
//debugging task to check the configuration
task list(dependsOn: configurations.compile) << {
println "classpath = ${configurations.compile.collect {File file -> file.name}}"
}
//debug -- show all dependency files
task showDependencyFiles(dependsOn:configurations.compile) {
configurations.compile.collect {
println it
}
fun main(args : Array<String>) {
println(System.getProperty("os.name"))
println(System.getProperty("os.arch"))
println(System.getProperty("os.version"))
}
import shutil
import os
import stat
def remove_readonly(func, path, excinfo):
os.chmod(path, stat.S_IWRITE)
func(path)
shutil.rmtree("../../export", onerror=remove_readonly)
C:\src\github>express aws-express-dynamodb-sample
destination is not empty, continue? [y/N] y

   create : aws-express-dynamodb-sample
   create : aws-express-dynamodb-sample/package.json
   create : aws-express-dynamodb-sample/app.js
   create : aws-express-dynamodb-sample/public
   create : aws-express-dynamodb-sample/public/javascripts
   create : aws-express-dynamodb-sample/routes

C:\src\github>express aws-express-dynamodb-sample destination is not empty, continue? [y/N] y

create : aws-express-dynamodb-sample create : aws-express-dynamodb-sample/package.json create : aws-express-dynamodb-sample/app.js create : aws-express-dynamodb-sample/public create : aws-express-dynamodb-sample/public/javascripts create : aws-express-dynamodb-sample/routes create : aws-express-dynamodb-sample/routes/index.js

@dnorton
dnorton / dates.kt
Last active March 18, 2016 15:07
when will then be now?
import java.time.Duration
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
/**
* Dates
*/
fun futureDate(days : Int) : String {
val currentDateTime : LocalDateTime = LocalDateTime.now()
val futureDateTime : LocalDateTime = currentDateTime.plus(Duration.ofDays(days.toLong()))
@dnorton
dnorton / passphrase.kt
Created March 9, 2016 19:10
A small Kotlin file to generate a passphrase
package com.velogica.passwords
import org.apache.http.client.fluent.Request
import java.util.*
/**
* Take a list of words, extract three at random, do some switcheraoos to the last word
*/
class PasswordGenerator {
@dnorton
dnorton / contains-example.groovy
Created February 2, 2016 14:44
Simple test of the contains() method in Groovy
def list = ["server1", "server2", "server3"]
println list.contains("server1")
println list.contains("server4")