Skip to content

Instantly share code, notes, and snippets.

View cademarkegard's full-sized avatar

Cade Markegard cademarkegard

View GitHub Profile
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 19, 2024 10:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@tjdett
tjdett / MyScalatraServlet.scala
Last active May 24, 2018 05:29
Scala + Apache POI to read uploaded Excel doc
package com.example.app
import org.scalatra._
import servlet.{SizeConstraintExceededException, FileUploadSupport}
import scalate.ScalateSupport
import java.io.ByteArrayInputStream
import org.apache.poi.ss.usermodel.WorkbookFactory
import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.DataFormatter
import org.apache.poi.ss.usermodel.DateUtil
require 'excon'
require 'securerandom'
def multipart_form_data(buildpack_file_path)
body = ''
boundary = SecureRandom.hex(4)
data = File.open(buildpack_file_path)
data.binmode if data.respond_to?(:binmode)
data.pos = 0 if data.respond_to?(:pos=)
@britalmeida
britalmeida / model.py
Last active November 26, 2015 00:05
flask-sqlalchemy: polymorphic and python mixin
class Asset(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(120), nullable=False)
asset_type_id = db.Column(db.Integer(), db.ForeignKey('asset_type.id'), nullable=False)
asset_type = db.relationship('AssetType', backref='assets')
# I would like a nicer way to do this
@property
def versions(self):