Skip to content

Instantly share code, notes, and snippets.

View jeremyfromearth's full-sized avatar
🖖
Coding

Jeremy Brown jeremyfromearth

🖖
Coding
View GitHub Profile
@jeremyfromearth
jeremyfromearth / .vimrc
Created May 5, 2018 20:32
Enable Netrw in Vim
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
augroup ProjectDrawer
autocmd!
autocmd VimEnter * :Vexplore
augroup END
@jeremyfromearth
jeremyfromearth / count_lines.sh
Last active November 28, 2017 05:08
Count the lines of code in a file or files
#!/usr/bin/env bash
find . -name '*.js' | xargs wc -l
@jeremyfromearth
jeremyfromearth / example.cpp
Created April 30, 2016 01:05
strptime for C++
struct tm tm;
std::string dateString = "2016-04-29T00:30:29.016448Z"
strptime(dateString.c_str(), "%Y-%m-%dT%H:%M:%SZ", &tm);
int day = tm.tm_mday, month = tm.tm_mon + 1, year = tm.tm_year + 1900, hour = tm.tm_hour, min = tm.tm_min;
@jeremyfromearth
jeremyfromearth / AssetDataSource.cpp
Last active April 2, 2016 00:00
Make assets from your Cinder project accessible to html rendered in Awesomium
#include "cinder/app/App.h"
#include "AssetDataSource.h"
using namespace ci;
using namespace ci::app;
void AssetDataSource::OnRequest(int request_id, const WebString & path) {
// load the asset the Cinder way and convert it to a buffer
auto asset = loadAsset(toString(path));
from vec import Vec
from random import randrange
from operator import itemgetter
# The raw data points
raw_data = [
(41, 45),(39, 44),(42, 43),(44, 43),(10, 42),(38, 42),
(8, 41),(41, 41),(13, 40),(45, 40),(7, 39),(38, 39),
(42, 39),(9, 38),(12, 38),(19, 38),(25, 38),(6, 37),
(13, 35),(9, 34),(12, 34),(32, 27),(26, 25),(39, 24),
from math import sqrt
class Vec():
@staticmethod
def distance(v1, v2):
delta = v1 - v2
return sqrt(delta.x ** 2.0 + delta.y ** 2.0)
@staticmethod
import SceneKit
class Geometry : NSObject {
// Creates a geometry object from given vertex, index and type data
internal func createGeometry(vertices:[SCNVector3], indices:[Int32], primitiveType:SCNGeometryPrimitiveType) -> SCNGeometry {
// Computed property that indicates the number of primitives to create based on primitive type
var primitiveCount:Int {
get {
import Foundation
import SceneKit
class Icosahedron : Geometry {
// The golden ratio
static let t = (1.0 + sqrt(5.0)) / 2.0;
// These vertices represent three orthogonal rectangles
// The corners of which define the 12 vertices of an icosahedron
// We get the normalized vector so that our points are on the unit sphere
import SceneKit
public func + (left:SCNVector3, right:SCNVector3) -> SCNVector3 {
return SCNVector3(left.x + right.x, left.y + right.y, left.z + right.z)
}
public func += (inout left:SCNVector3, right:SCNVector3) {
left = left + right
}
import SceneKit
class IcoSphere : Geometry {
// Initialize the data to the Icosahedron
var faceIndices:[Int32] = Icosahedron.faceIndices
var vertices:[SCNVector3] = Icosahedron.vertices
var wireframeIndices:[Int32] = Icosahedron.wireframeIndices
required init(subdivisions:Int) {
// Map string representations to indices (used to avoid duplicate vertices)