Skip to content

Instantly share code, notes, and snippets.

@xexu
xexu / index.html
Last active May 9, 2018 10:28
A-Frame custom component
<script>
var direction = 1;
AFRAME.registerComponent('auto-camera', {
tick: function () {
var currentPosition = this.el.object3D.position;
if (currentPosition.z < -2) {
direction = 1;
} else if (currentPosition.z > 0) {
direction = -1;
}
@xexu
xexu / index.html
Created May 9, 2018 10:25
A-Frame aframe-star-system-component example
<script src="https://cdn.rawgit.com/matthewbryancurtis/aframe-star-system-component/db4f1030/index.js"></script>
<a-scene>
<a-sky color="#222"></a-sky>
<a-entity star-system></a-entity>
</a-scene>
@xexu
xexu / index.
Created May 9, 2018 10:23
A-Frame assets
<a-assets>
<a-asset-item id="mtl" src="https://cdn.glitch.com/787f26e4-ded1-4eaf-ba99-e2a5c1ffda59%2Facesjustforroomshow.mtl?1525708212104"></a-asset-item>
<a-asset-item id="obj" src="https://cdn.glitch.com/787f26e4-ded1-4eaf-ba99-e2a5c1ffda59%2Facesjustforroomshow.obj?1525708229479"></a-asset-item>
</a-assets>
<a-entity obj-model="obj: #obj; mtl: #mtl;" position="-1 -1 -1" scale="1 1 1" rotation="0 180 0" shadow></a-entity>
@xexu
xexu / index.html
Created May 9, 2018 10:19
A-Frame camera customization
<a-entity position="0 1 0">
<a-camera></a-camera>
</a-entity>
@xexu
xexu / index.html
Created May 9, 2018 10:10
A-Frame hello world
<!DOCTYPE html>
<html>
<head>
<title>Hello, WebVR! - A-Frame</title>
<meta name="description" content="Hello, WebVR! - A-Frame">
<script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
</head>
<body>
<a-scene>
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
@xexu
xexu / replacer.py
Created April 28, 2013 21:02
replace utility for large files
# -*- coding: utf-8 -*-
import os, codecs, sys
dir = os.getcwd()
file = sys.argv[1]
Dict = [['a', 'b'], ['c', 'd']]
fname = os.path.join(dir, file)
@xexu
xexu / paypal-nvp.php
Created October 23, 2013 11:12
Script to query paypal nvp api
<?php
class Paypal {
/**
* Last error message(s)
* @var array
*/
protected $_errors = array();
/**
* API Credentials
@xexu
xexu / dom.html
Last active December 17, 2015 20:49
DOM selection jQuery-ish on IE8+
<html>
<head>
<title>DOM selection jQuery-ish on IE8+</title>
</head>
<body>
<script>
window.$ = function(selector) {
return document.querySelector(selector);
};
@xexu
xexu / recursive list
Last active December 16, 2015 18:29
Rescursive list of files
ls -R /path | awk '
/:$/&&f{s=$0;f=0}
/:$/&&!f{sub(/:$/,"");s=$0;f=1;next}
NF&&f{ print s"/"$0 }'
@xexu
xexu / PHP Debug
Last active October 13, 2015 22:38
Just add this code on top of the file if the page goes blank to show errors
error_reporting(E_ALL);
ini_set("display_errors", "on");