This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec3 BoxNormal(const Box box, const vec3 point) | |
{ | |
vec3 center = (box.max + box.min) * 0.5; | |
vec3 size = (box.max - box.min) * 0.5; | |
vec3 pc = point - center; | |
// step(edge,x) : x < edge ? 0 : 1 | |
vec3 normal = vec3(0.0); | |
normal += vec3(sign(pc.x), 0.0, 0.0) * step(abs(abs(pc.x) - size.x), kEpsilon); | |
normal += vec3(0.0, sign(pc.y), 0.0) * step(abs(abs(pc.y) - size.y), kEpsilon); | |
normal += vec3(0.0, 0.0, sign(pc.z)) * step(abs(abs(pc.z) - size.z), kEpsilon); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 330 core | |
out vec4 out_color; | |
in DATA | |
{ | |
vec2 uv; | |
} fs_in; | |
struct Material { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float MercatorNode::GetAltitude(float pos_x, float pos_z, bool accurate) | |
{ | |
const float * height_data = map_tile_.GetHeightData(); | |
if (height_data) | |
{ | |
const float kMSM = static_cast<float>(mgn::terrain::GetMapSizeMax()); | |
// Determine point relative position in tile | |
float tiles_per_side = static_cast<float>(1 << lod_); | |
float tiles_x = tiles_per_side * (pos_x / kMSM); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <limits> | |
#include <iostream> | |
#include <set> | |
#include <vector> | |
#include <stddef.h> | |
#include <assert.h> | |
class StackLinkedList { | |
public: | |
struct Node { | |
Node* next; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def average(x): | |
n = len(x) | |
s = 0 | |
for xi in x: | |
s += xi | |
s = s / n | |
return s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Module describes classes ActionPromise and ActionPromiseList. | |
* Exceptionally useful when your executed code has asynchronous dependencies. | |
* Keeps the same execution order as promises have been added despite the server response. | |
* | |
* Here's an example of code: | |
* @code{.js} | |
* needAddress = true; | |
* needGeometry = true; | |
* requestAddress(function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('beforeunload', function (e) { | |
sendAnalyticsData(); | |
}); | |
function sendAnalyticsData() { | |
if (navigator && navigator.sendBeacon) { | |
navigator.sendBeacon(url); | |
} else { | |
$.ajax({ | |
type: 'POST', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download(content, fileName, contentType) { | |
var a = document.createElement("a"); | |
var file = new Blob([content], {type: contentType}); | |
a.href = URL.createObjectURL(file); | |
a.download = fileName; | |
a.click(); | |
URL.revokeObjectURL(a.href); | |
} | |
// Usage | |
var jsonObject = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getObjectRows : function(array) { | |
if (!Array.isArray(array)) | |
return new Array(); | |
if (array.length == 0) | |
return new Array(); | |
var rows = new Array(); | |
var namesRow = new Array(); | |
var obj = array[0]; | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop) && typeof obj[prop] !== "function" && typeof obj[prop] !== "object") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
Future<String> someFutureResult(){ | |
final c = new Completer<String>(); | |
// complete will be called in 3 seconds by the timer. | |
new Timer(Duration(seconds: 3), () => c.complete("you should see me second")); | |
return c.future; | |
} | |
main(){ |