Skip to content

Instantly share code, notes, and snippets.

View Daniel-Wiedemann's full-sized avatar

MEDIATRASH Daniel-Wiedemann

View GitHub Profile
@Daniel-Wiedemann
Daniel-Wiedemann / negative_loop.js
Last active August 29, 2015 14:07
Decrement for Loop (or. negative for loop)
for(var i = array.length; i--;) {
// do something
}
// =====================================
// example
var letters = ['a','b','c','d','e','f'];
for(var i = arr.length; i--;){
console.log(arr[i]);
}
@Daniel-Wiedemann
Daniel-Wiedemann / compute_boundingbox_group_objects.js
Created September 28, 2014 21:04
Compute Boundingbox from a group of Objects
/**
* Calculates the bounding box of grouped 3d Objects, with Objects that contains geometries
* @param {Object3d} objectgroup A Object3d that contains other Object3d objects like Mesh.
* @return {Object} Returns a Object with two parameter min{THREE.Vector3} and max{THREE.Vector3}
*/
function computeBoundingBoxGroupObjects(objectgroup){
var minX = 0, minY = 0, minZ = 0, maxX = 0, maxY = 0, maxZ = 0;
function getBox(item){
if(item.geometry){
@Daniel-Wiedemann
Daniel-Wiedemann / local_to_world.js
Last active August 29, 2015 14:07
Local to World
var parent = new THREE.Object3d();
var child = new THREE.Object3d();
parent.add(child);
parent.position.y = 100;
child.position.y = 200;
// we get 200, because child.position returns us the local position
console.log( child.position.y );
// we get 300, because child.localToWorld(new THREE.Vector3()) returns us the global position
Date
Basic date: Format: DD.MM.YYYY
(0[1-9]|1[0-9]|2[0-9]|3[01]).(0[1-9]|1[012]).[0-9]{4}
To add a prefix to filenames in an folder.
1. open the command line window
2. go into the folder where are the files to add the "_prefix"
3. FOR /r "." %a in (*.*) DO REN "%~a" "prefix%~nxa"
You can also define which files should get prefixed
eg. only .txt files
FOR /r "." %a in (*.txt) DO REN "%~a" "prefix%~nxa"
@Daniel-Wiedemann
Daniel-Wiedemann / Sublime Alignment
Created March 10, 2014 09:14
Sublime Text 2 Packages
http://wbond.net/sublime_packages/alignment#Package_Settings
Usage
Make a multi-line selection, or multiple selections
Press ctrl+alt+a on Windows and Linux, or cmd+ctrl+a on OS X
When using with a multi-line selection, the lines will be indented consistently first. If the selected lines are consistently indented, the first = on each line will be aligned. The character to align to for mid-line alignment can be configured via the settings.
Example:
befor:
@Daniel-Wiedemann
Daniel-Wiedemann / Evaluation MV* Frameforks
Created February 9, 2014 19:53
Evaluation of AngularJS, EmberJS, BackboneJS + MarionetteJS
http://blog.binarymist.net/2013/12/28/evaluation-of-angularjs-emberjs-backbonejs-marionettejs/
https://egghead.io/lessons
@Daniel-Wiedemann
Daniel-Wiedemann / skeleton-namespace.xml
Created February 7, 2014 18:17
Sublime Text 2 Snippet Skeleton namespaces
<snippet>
<content><![CDATA[
/**
* name: $TM_FULLNAME
* email: $TM_EMAIL
* filename: $TM_FILENAME
* @type {{}}
*/
(function( ${1:namespace}, \$, undefined ) {
@Daniel-Wiedemann
Daniel-Wiedemann / Environment Variables.xml
Created February 7, 2014 18:15
Sublime Text 2 Environment Variables
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Globals</string>
<key>scope</key>
<string></string>
<key>settings</key>
<dict>
@Daniel-Wiedemann
Daniel-Wiedemann / Large numbers erroneously rounded
Created February 7, 2014 16:33
Large numbers erroneously rounded in Javascript // AJAX, JSON response/request
Erklärung zu dem Problem:
http://stackoverflow.com/questions/1379934/large-numbers-erroneously-rounded-in-javascript
http://www.2ality.com/2012/04/number-encoding.html
What you're seeing here is actually the effect of two roundings. Numbers in ECMAScript are internally represented double-precision floating-point. When id is set to 714341252076979033 (0x9e9d9958274c359 in hex), it actually is assigned the nearest representable double-precision value, which is 714341252076979072 (0x9e9d9958274c380). When you print out the value, it is being rounded to 15 significant decimal digits, which gives 14341252076979100.
JavaScript uses double precision floating point values, ie a total precision of 53 bits, but you need