Skip to content

Instantly share code, notes, and snippets.

View cademarkegard's full-sized avatar

Cade Markegard cademarkegard

View GitHub Profile
@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):
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=)
@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
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 23, 2024 18:01
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname