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
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)
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
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 / example_unit_test.kt
Created March 15, 2016 14:29
simple unit test example in Kotlin
import org.junit.Test
import org.assertj.core.api.Assertions
import org.junit.BeforeClass
class ThingTest {
companion object {
@JvmStatic
@BeforeClass fun init() {
@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")
@dnorton
dnorton / Remote.py
Created October 1, 2015 19:02
a paramiko class for use in a "with" block
__author__ = 'usunoda'
try:
import paramiko, getpass
except ImportError:
pass
class Remote(object):
"""
Container class for SSH functionality. Needs to be used in a with statement.