Skip to content

Instantly share code, notes, and snippets.

View fogonthedowns's full-sized avatar
👋

JZ fogonthedowns

👋
View GitHub Profile
@fogonthedowns
fogonthedowns / gist:05f466ca784c99e46b0a
Last active August 29, 2015 14:14
Create an Image file from a Video/Movie file with the Swift Language
// By Justin Zollars
// jz.io
let asset1 = AVURLAsset(URL:tempImage, options:nil)
let generator = AVAssetImageGenerator(asset: asset1)
let time = CMTimeMakeWithSeconds(0, 30)
let size = CGSizeMake(425,355)
generator.maximumSize = size
let imgRef = generator.copyCGImageAtTime(time, actualTime: nil, error: nil)
let thumb = UIImage(CGImage:imgRef)
@fogonthedowns
fogonthedowns / merge_sort.rb
Created March 16, 2015 05:01
Ruby Merge Sort
def merge_sort(array)
return array if array.size <= 1
left = merge_sort array[0, array.size / 2]
right = merge_sort array[array.size / 2, array.size]
merge(left, right)
end
def merge(left, right)
@fogonthedowns
fogonthedowns / jz.rb
Last active August 29, 2015 14:17
jz.rb
# 1. Pick a chapter, save it on your desktop as text.text http://flyingmoose.org/tolksarc/book/
# 2. save this on your desktop:
# 3. open up terminal on OSX
# 4. cd Desktop
# 5. run with ruby:
# ruby jz.rb
class MarkovChain
def initialize(text)
@words = Hash.new
warnValidations: function(value) {
this.setState({warnErrorTypes:[]})
if (value["fact_interviews"] == "0") {
this.setWarnTypes(2)
} else if (Number(value["fact_interviews"]) >= 20) {
this.setWarnTypes(3)
}
console.log(this.state.warnErrorTypes)
},
@fogonthedowns
fogonthedowns / gist:2247f0cef68aea29ff0d
Created May 31, 2015 20:40
NLP Flask extract PERSON, PLACE AND ORG
#!/usr/bin/env python
from flask import Flask, url_for, jsonify
app = Flask(__name__)
import nltk, re, timex, json, sys
@app.route('/')
def api_root():
return 'Welcome'
@app.route('/articles')
@fogonthedowns
fogonthedowns / quicksort.rb
Created June 3, 2015 14:14
Ruby quicksort
# The steps are:
# 1. Pick an element, called a pivot, from the array.
# 2. Reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with # # values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in # its final position. This is called the partition operation.
# 3. Recursively apply the above steps to the sub-array of elements with smaller values and separately to the sub-array of # elements with greater values.
class Array
def quicksort
return [] if empty?
# 1
from app import db
from marshmallow import Schema, fields
class PlantMaterial(db.Model):
id = db.Column(db.Integer, primary_key=True)
cultivar = db.Column(db.String(64), index=True, unique=False)
variety = db.Column(db.String(120), index=True, unique=False)
tissue = db.Column(db.String(64), index=True, unique=False)
form = db.Column(db.String(64), index=True, unique=False)
items = db.relationship('Inventory', backref='plant_material', lazy='dynamic')
@fogonthedowns
fogonthedowns / env.py
Created October 7, 2015 17:04
env.py
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
import logging
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
@fogonthedowns
fogonthedowns / DOCKER.txt
Last active May 13, 2016 21:19
JZ'S DOCKER CHEATS
STARTING DOCKER
https://docs.docker.com/machine/get-started/
docker-machine ls
docker-machine create --driver virtualbox default
docker-machine env default
eval "$(docker-machine env default)”
docker-machine start default
docker-machine ip default
@fogonthedowns
fogonthedowns / docker-py
Last active March 14, 2016 23:34
docker-py with python3, docker 1.8.3, and 4.1.10-boot2docker
import docker
from docker import Client
from docker.utils import kwargs_from_env
client = Client(version='1.20',**kwargs_from_env(assert_hostname=False))
client.containers()
client.info()
client.version()
Starting a Container from an image