Skip to content

Instantly share code, notes, and snippets.

View victorbstan's full-sized avatar

Victor Stan victorbstan

  • Toronto & Remote
View GitHub Profile
@victorbstan
victorbstan / ConvexHull.cs
Created February 4, 2023 21:58 — forked from YclepticStudios/ConvexHull.cs
Convex hulling algorithm for Unity; converts a point cloud into triangle indices for meshing.
/**
* ============================================================================
* MIT License
*
* Copyright (c) 2016 Eric Phillips
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@victorbstan
victorbstan / DoPlanesIntersectAtSinglePoint.cs
Created February 4, 2023 16:04 — forked from StagPoint/DoPlanesIntersectAtSinglePoint.cs
Find intersection point of three planes in C# for Unity
private bool planesIntersectAtSinglePoint( Plane p0, Plane p1, Plane p2, out Vector3 intersectionPoint )
{
const float EPSILON = 1e-4f;
var det = Vector3.Dot( Vector3.Cross( p0.normal, p1.normal ), p2.normal );
if( det < EPSILON )
{
intersectionPoint = Vector3.zero;
return false;
}
(function($) {
// SIMPLE BOX
// make your own lightbox cuz they all suck
var imgSrc
, $simpleBox;
window.fitImg = function() {
var $img = $("#simple-box img");
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="author" content="Victor Stan">
<meta name="description" content="Get multiple video streams on one page. Adapted from code by Muaz Khan">
<title>Video Camera</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" ></script>
@victorbstan
victorbstan / video_pyopencv.py
Created March 20, 2012 02:07 — forked from kriben/video_pyopencv.py
Python opencv feed from webcam
import opencv
#this is important for capturing/displaying images
from opencv import highgui
import pygame
import sys
camera = highgui.cvCreateCameraCapture(0)
def get_image():
im = highgui.cvQueryFrame(camera)
# Add the line below if you need it (Ubuntu 8.04+)
@victorbstan
victorbstan / your_application.rb
Created October 28, 2011 12:31 — forked from nicholasjhenry/your_application.rb
PayRoll application, embedded in Rails, borrowing from Use Case Driven Architecture and DCI
## PayRoll Application Gem
# lib/pay_roll/pay_day_service.rb
# Consider this Use Case as the Context in DCI
#
class PayRoll::PayDayService
def initialize(date=Date.today)
@date = date
# Employee could be any data source from the host,
@victorbstan
victorbstan / gist:1256414
Created October 1, 2011 17:57 — forked from Amitesh/gist:1160428
Paperclip file name cleanup or rename
#http://blog.wyeworks.com/2009/7/13/paperclip-file-rename
Paperclip.interpolates :default_image_type do |attachment, style|
attachment.instance.get_user_default_profile_image
end
Paperclip.interpolates :normalized_avatar_file_name do |attachment, style|
attachment.instance.normalized_avatar_file_name
end
!default_rounded_amount ||= 5px
// Round corner at position by amount.
// values for position: "top-left", "top-right", "bottom-left", "bottom-right"
=round-corner(!position, !amount = !default_rounded_amount)
border-#{!position}-radius= !amount
-moz-border-#{!position}-radius= !amount
-webkit-border-#{!position}-radius= !amount
// Round left corners by amount
//get first part of current url, without hash
var base_path = window.location.href.split("#")[0];
var real_id = 0;
var current_page;
;(function($) {
//create new sammy app
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes like #/slide/1
get('#/slide/:page_id', function() { with(this) {
$(function() {
//run the accordion plugin, set height of sections to height of content
$("#accordion").accordion({ autoHeight: false });
});
;(function($) {
//write new sammy application
var app = new Sammy.Application(function() {
with(this) {
//corresponds to routes such as #/section/1
get('#/section/:section_id', function() { with(this) {