Skip to content

Instantly share code, notes, and snippets.

@borice
borice / uboot_interrupt.txt
Created July 27, 2020 01:10
iDRAC7 U-boot interrupt
U-Boot 2009.08-00088-g121cddc (Nov 17 2014 - 05:50:46) Avocent (0.0.3) EVB, Build: jenkins-idrac-yocto-release-505
CPU: SH-4A
BOARD: R0P7757LC00xxRL (C0 step) board
BOOT: Secure, HRK not generated
DRAM: 240MB
(240MB of 256MB total DRAM is available on U-Boot)
ENV: Using primary env area.
In: serial
Out: serial
@borice
borice / console_log.txt
Created July 26, 2020 23:17
bricked iDRAC7 boot console on PowerEdge T620
U-Boot 2009.08-00088-g121cddc (Nov 17 2014 - 05:50:46) Avocent (0.0.3) EVB, Build: jenkins-idrac-yocto-release-505
CPU: SH-4A
BOARD: R0P7757LC00xxRL (C0 step) board
BOOT: Secure, HRK not generated
DRAM: 240MB
(240MB of 256MB total DRAM is available on U-Boot)
ENV: Using primary env area.
In: serial
Out: serial
@borice
borice / extracted_features_path_converters.py
Created March 31, 2020 02:47
Example code for converting to- and from- pairtree and stubbytree directory structures for the HTRC Extracted Features dataset
#!/usr/bin/env python3
# Note: depends on `pairtree` package (`pip install pairtree`)
import os
import pairtree.pairtree_path as ppath
def stubby_to_pairtree(path: str, ef_ext: str = '.json.bz2') -> str:
assert path.endswith(ef_ext)
d, f = os.path.split(path)
assert len(d.split(os.sep)) >= 2
@borice
borice / JsonImplicits.scala
Created March 9, 2019 01:41
Converts LocalDate and Instant from java.time to/from Play JSON for MongoDB use
import java.time.{Instant, LocalDate, ZoneOffset}
import play.api.libs.json._
object JsonImplicits {
implicit object LocalDateMongoJsonReaderWriter extends Reads[LocalDate] with Writes[LocalDate] {
override def reads(json: JsValue): JsResult[LocalDate] =
(json \ "$date").validate[Long].map(Instant.ofEpochMilli(_).atZone(ZoneOffset.UTC).toLocalDate)
@borice
borice / BsonImplicits.scala
Created March 9, 2019 01:40
Converts LocalDate and Instant from java.time to/from BSONDateTime
import java.time.{Instant, LocalDate, ZoneOffset}
import reactivemongo.bson._
object BsonImplicits {
implicit object LocalDateBsonReaderWriter extends BSONReader[BSONValue, LocalDate] with BSONWriter[LocalDate, BSONDateTime] {
override def read(bson: BSONValue): LocalDate = bson match {
case BSONDateTime(millis) => Instant.ofEpochMilli(millis).atZone(ZoneOffset.UTC).toLocalDate
case BSONLong(millis) => Instant.ofEpochMilli(millis).atZone(ZoneOffset.UTC).toLocalDate
@borice
borice / JodaBsonImplicitConverters.scala
Created March 8, 2019 22:29
Convert to/from DateTime and LocalDate to BSONDateTime and ISODate
import org.joda.time.{DateTime, DateTimeZone, LocalDate, LocalDateTime}
import play.api.libs.json._
import reactivemongo.play.json._
object JodaBsonImplicitConverters {
// ### Automatic conversion of { DateTime, LocalDate } <-> BSONDateTime <-> ISODate ###
implicit val dateTimeRead: Reads[DateTime] =
(__ \ "$date").read[Long].map(new DateTime(_))
@borice
borice / Gzip.scala
Created March 1, 2019 16:40
Enable gzip-compressed JSON payload in op-rabbit
//
// To use the below, simply import Gzip._ instead of import com.spingo.op_rabbit.PlayJsonSupport._
//
import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
import java.util.zip.{GZIPInputStream, GZIPOutputStream}
import com.spingo.op_rabbit._
import play.api.libs.json._
import scala.io.{Codec, Source}