Skip to content

Instantly share code, notes, and snippets.

@humbletim
humbletim / gist:284037
Created January 22, 2010 19:00 — forked from ry/gist:155877
// Answer to http://github.com/ry/http-parser/issues/#issue/1
// UNTESTED
struct line {
char *field;
size_t field_len;
char *value;
size_t value_len;
};
<?php
echo "hello world!<br />"
@humbletim
humbletim / README.md
Last active December 16, 2015 22:29
transition scrollTop on a DIV
@humbletim
humbletim / example.cpp
Created February 23, 2015 04:30
GLM Example - C++11
#define GLM_FORCE_RADIANS 1
#include <glm/glm.hpp>
#include <glm/ext.hpp>
static auto mrot = glm::angleAxis(glm::radians(45.0f), glm::vec3(0,1,0));
auto m1 = glm::mat4(1.0f);
auto m2 = glm::mat4(2.0f);
@humbletim
humbletim / example.frag
Created February 23, 2015 04:40
GLM Example - GLSL
mat4 rotationMatrix(vec3 axis, float angle);
void main(void)
{
mat4 mrot = rotationMatrix(vec3(0.0,1.0,0.0), radians(45.0));
mat4 m1 = mat4(1.0);
mat4 m2 = mat4(2.0);
mat4 m3 = m1 * m2;
@humbletim
humbletim / example.js
Created February 23, 2015 04:47
GLM Example - JavaScript
var glm = require('./build/glm-three.min.js');
this.mrot = this.mrot ||
glm.angleAxis(glm.radians(45.0), glm.vec3(0,1,0));
var m1 = glm.mat4(1.0);
var m2 = glm.mat4(2.0);
var m3 = m1['*'](m2);
@humbletim
humbletim / canResTmpTests.js
Last active July 2, 2016 23:02
canRezTmp tests
print('hostname: ', location.hostname);
print('logged in: ', Account.isLoggedIn());
print('username: ', Account.getUsername());
print('canAdjustLocks: ', Entities.canAdjustLocks());
print('canRez: ', Entities.canRez());
print('canRezTmp: ', Entities.canRezTmp());
var lifetimes = [ undefined, -1, 0, 1, 3, 5, 3600, 3601 ];
function rez(lifetime) {
observeModeChanges(); // defined below
// --------------------------------------------------------------
// hear from your Avatar's perspective
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeHead;
// --------------------------------------------------------------
// hear from the Camera's perspective
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeCamera;
@humbletim
humbletim / createTestEntity.js
Created July 9, 2016 16:57
Entity/Controller mouseMoveEvents test
var id = Entities.addEntity({
lifetime: 600,
type: 'Shape',
shape: 'Icosahedron',
position: MyAvatar.position,
dimensions: Vec3.ONE,
color: { red: 255, green: 0, blue: 255 },
collisionless: true,
script: Script.resolvePath('testDifferentMouseMoveEvents.js')
});
@humbletim
humbletim / QNetworkReply-NetworkError.cpp
Created November 4, 2016 20:54
QNetworkReply-NetworkError switch template
// see: http://doc.qt.io/qt-5/qnetworkreply.html
switch(request->error()) {
case QNetworkReply::ConnectionRefusedError: // the remote server refused the connection (the server is not accepting requests)
case QNetworkReply::RemoteHostClosedError: // the remote server closed the connection prematurely, before the entire reply was received and processed
case QNetworkReply::HostNotFoundError: // the remote host name was not found (invalid hostname)
case QNetworkReply::TimeoutError: // the connection to the remote server timed out
case QNetworkReply::OperationCanceledError: // the operation was canceled via calls to abort() or close() before it was finished.
case QNetworkReply::SslHandshakeFailedError: // the SSL/TLS handshake failed and the encrypted channel could not be established. The sslErrors() signal should have been emitted.
case QNetworkReply::TemporaryNetworkFailureError: // the connection was broken due to disconnection from the network, however the system has initiated roaming to another