Skip to content

Instantly share code, notes, and snippets.

View fernandojsg's full-sized avatar

Fernando Serrano fernandojsg

View GitHub Profile
@fernandojsg
fernandojsg / gltf_bookmarklet.js
Last active September 1, 2017 13:54
THREE.js and AFRAME glTF exporter bookmarklet
javascript:(function(){
var link = document.createElement( 'a' ); link.style.display = 'none'; document.body.appendChild( link );
function save( blob, filename ) { link.href = URL.createObjectURL( blob ); link.download = filename; link.click(); }
function saveString( text, filename ) { save( new Blob( [ text ], { type: 'application/json' } ), filename );}
var script=document.createElement('script');
script.src='https://threejs.org/examples/js/exporters/GLTFExporter.js';
script.onload = function () {
var exporter = new THREE.GLTFExporter();
@fernandojsg
fernandojsg / example.json
Last active August 15, 2017 08:59
GLTF three.js example
{
"asset": {
"version": "2.0",
"generator": "THREE.JS GLTFExporter"
},
"scenes": [
{
"nodes": [
0,
1,
@fernandojsg
fernandojsg / spheres.js
Created September 20, 2016 13:44
Spheres brush
/* globals AFRAME THREE */
AFRAME.registerBrush('spheres', {
init: function (color, width) {
// Initialize the material based on the stroke color
this.material = new THREE.MeshStandardMaterial({
color: this.data.color,
roughness: 0.5,
metalness: 0.5,
side: THREE.DoubleSide,
shading: THREE.FlatShading
@fernandojsg
fernandojsg / brush.js
Last active September 20, 2016 13:43
BrushInterface
BrushInterface.prototype = {
addPoint: function (position, orientation, pointerPosition, pressure, timestamp) {},
tick: function (timeoffset, delta) {}
}
1 - Oculus Rift CV1, Oculus VR
displayId: 1
displayName: Oculus Rift CV1, Oculus VR
isConnected: true
isPresenting: false
capabilities:
hasOrientation: true
hasPosition: true
hasExternalDisplay: true
@fernandojsg
fernandojsg / convertimages.sh
Created July 26, 2015 17:06
Convert all the raw/cr2 images in this folder to .jpg
for i in *.CR2; do sips -s format jpeg $i --out "${i%.*}.jpg"; done
### Aliases
# Open specified files in Sublime Text
# "s ." will open the current directory in Sublime
alias s='open -a "Sublime Text"'
alias d='cd /Volumes/SECUNDARIO'
alias gd='cd Volumes/SECUNDARIO/MIO/Google\ Drive/'
#alias ogc='open -a Google\ Chrome --args --disable-web-security'
alias ogc='open -a Google\ Chrome'
@fernandojsg
fernandojsg / gist:9c5858c0c1d399970cc4
Last active August 29, 2015 14:23
XML Utils for php
class XmlUtils
{
function removeChildren(&$node)
{
while ($node->firstChild)
{
while ($node->firstChild->firstChild)
{
XmlUtils::removeChildren($node->firstChild);
}
@fernandojsg
fernandojsg / gist:f4d2d3fa10749a7ee527
Created June 2, 2015 10:15
Encrypt & Decrypt from command line
# Add it to your ~/.zshrc
encrypt () { openssl des3 -in $1 -out $1.encrypted }
decrypt () { FILENAME=$(echo $1|sed -e 's/\.encrypted$//g'); openssl des3 -d -in $1 -out $FILENAME }
@fernandojsg
fernandojsg / gist:6e09e68f6d2205237316
Created May 21, 2015 06:50
Convert DOS Newlines CR-LF file to Unix/Linux format

#Using dos2unix Replacing the original file:

dos2unix filename

Creating a .bak copy of the original:

dos2unix -b filename

#Using tr command