Skip to content

Instantly share code, notes, and snippets.

@deanhu2
deanhu2 / hello_triangle.cpp
Created March 11, 2018 17:32 — forked from vittorioromeo/hello_triangle.cpp
SDL2 + OpenGL ES 2.0 - "Hello triangle" example that works both on X11 and Emscripten
#include <exception>
#include <functional>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
@deanhu2
deanhu2 / perlin-noise.gd
Last active October 16, 2018 19:19
Godot heightmap generator using perlin-noise
#If you would like to contribute or modify the content's
#of this script, please consider contribution to the original
#repository - https://github.com/deanhu2/Perlin-Noise-Godot
tool
extends ImageTexture
export(int,1,100) var octave= 5 setget set_octave, get_octave
export(int,1,512) var width= 256 setget set_width, get_width
export(int,1,512) var height= 256 setget set_height, get_height
@deanhu2
deanhu2 / Blend Add Particle.shader
Created June 29, 2018 09:55 — forked from ThePhiMa/Blend Add Particle.shader
Blend Add Shader (as used in Diablo 3)
// Blend Add Shader (as used in Diablo 3)
// Uses the alpha channel to determine if the pixel needs to be blended additively or by transparency.
// Is a good way prevent the additive buildup that makes a scene with a lot of particle effects white and unreadable while still having some particle texture features.
// Idea by Julian Love - http://www.gdcvault.com/play/1017660/Technical-Artist-Bootcamp-The-VFX
Shader "Custom/Blend Add Particle Test"
{
Properties
{
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_BlendThreshold("Blend Treshold (0.0:Additive, 1.0:Trasparency)", Range(0.0, 1.0)) = 0.5
@deanhu2
deanhu2 / animation.gif
Created March 16, 2018 19:37 — forked from tforgione/animation.gif
SFML / OpenGL ES cube test
animation.gif
extern {
// Our C function definitions!
pub fn strcpy(dest: *mut u8, src: *const u8) -> *mut u8;
pub fn puts(s: *const u8) -> i32;
}
fn main() {
let x = b"Hello, world!\0"; // our string to copy
let mut y = [0u8; 32]; // declare some space on the stack to copy the string into
unsafe {
@deanhu2
deanhu2 / k_means_anchor_points.py
Created January 23, 2018 15:42 — forked from WillieMaddox/k_means_anchor_points.py
create darknet anchor points using k-means. Uses fast numpy array ops: pascal ~= 1.0 s coco ~= 16 s
# -*- coding: utf-8 -*-
import numpy as np
import xml.etree.ElementTree as ET
from pycocotools.coco import COCO
def convert_coco_bbox(size, box):
dw = 1. / size[0]
dh = 1. / size[1]
x = box[0] + box[2] / 2.0
@deanhu2
deanhu2 / sgdlinreg.java
Created January 4, 2018 10:47 — forked from ngopal/sgdlinreg.java
Stochastic Gradient Descent, but this time in Java.
package com.nikhilgopal.spark;
/**
* Created by nikhilgopal on 3/24/17.
*/
public class SGDLinReg {
public static void main(String[] args) {
double[] coefficients = {0.4, 0.8};
double[][] dataset = {
{1.0, 1.0},
@deanhu2
deanhu2 / 1_install_cuda.sh
Last active December 29, 2017 17:55 — forked from graphific/1_install_cuda.sh
Installation script for Cuda and drivers on Ubuntu 14.04
#!/usr/bin/env bash
# Installation script for Cuda and drivers on Ubuntu 14.04, by Roelof Pieters (@graphific)
# BSD License
if [ "$(whoami)" == "root" ]; then
echo "running as root, please run as user you want to have stuff installed as"
exit 1
fi
###################################
# Ubuntu 14.04 Install script for:
# - Nvidia graphic drivers for Titan X: 352
#include <iostream>
using namespace std;
void loadXML(std::string xml)
{
std::cout << xml;
}
int main()
@deanhu2
deanhu2 / UI.cpp
Last active November 8, 2017 22:08
A simple example on abstracting a UI interface, and creating a MVVM register component that controls communication via events.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <utility>
#include <map>