Skip to content

Instantly share code, notes, and snippets.

@AVGP
AVGP / index.js
Created November 22, 2014 17:39
Demo of node.js SOAP client
var soap = require("soap");
soap.createClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", function(err, client) {
if(err) {
console.error("Can't create client", err);
return;
}
client.CelsiusToFahrenheit({Celsius: "25"}, function(err, result) {
if(err) {
console.error("Can't call method", err);
@AVGP
AVGP / app.js
Created January 21, 2015 18:31
Karma sample
// js/app.js
function add(a, b) {
return a+b;
}
function say(text) {
document.body.textContent = text;
}
@AVGP
AVGP / webcamtexture-script.js
Created February 1, 2015 16:13
Three.js livecoding arena - WebcamTexture
// Setup your scene here
var tex = null;
var mat = new THREE.MeshBasicMaterial({});
var box = new THREE.Mesh(
new THREE.BoxGeometry(100, 100, 100),
mat
);
window.THREE = THREE;
var script = document.createElement("script");
@AVGP
AVGP / hg-prompt.bash
Last active October 26, 2015 13:02
Shell prompt that displays the current user, the working directory and the current mercurial bookmark.
DEFAULT="[0m"
PINK="[35m"
GREEN="[32m"
ORANGE="[33m"
hg_branch() {
BOOKMARK=`hg branch 2> /dev/null`
if [ -n "$BOOKMARK" ]; then
BOOKMARK="\e${DEFAULT} on \e${ORANGE}$BOOKMARK\e${DEFAULT}"
fi
@AVGP
AVGP / my-element.html
Last active May 4, 2023 14:05
A simple web component boilerplate
<template>
<style>
</style>
</template>
<script>
var Element = null;
(function(currentScript) {
var elemPrototype = Object.create(HTMLDivElement.prototype); // pick the appropriate prototype for your element!
@AVGP
AVGP / presentation.py
Created June 26, 2015 06:03
Python script to listen to Myo "WAVE" poses to send left/right key events under Linux
import sys
import os
sys.path.append('../lib/')
from device_listener import DeviceListener
from pose_type import PoseType
class WavePoseListener(DeviceListener):
def on_pose(self, pose):
pose_type = PoseType(pose)
@AVGP
AVGP / hg_changes.bash
Created August 10, 2015 18:58
Small bash function that outputs the number of lines added and removed in a commit
DEFAULT="[37;40m"
RED="[31;40m"
GREEN="[32;40m"
hg_changes() {
echo -e "\e${RED}`hg log -pr $1 | grep '^+' | wc -l` Additions\e${DEFAULT}"; echo -e "\e${GREEN}`hg log -pr $1 | grep '^-' | wc -l` Deletions\e${DEFAULT}";
}
[2015-09-08 14:56:17,530][WARN ][transport.netty ] [Captain Wings] exception caught on transport layer [[id: 0x93369774, /127.0.0.1:37573 :> /127.0.0.1:9300]], closing connection
java.io.StreamCorruptedException: invalid internal transport message format
@AVGP
AVGP / make-animated-gif.js
Last active August 9, 2023 00:18
Uses three.js, three-software-renderer & omggif to render an animated GIF from a Three.js Scene on the server with node.js
var fs = require('fs'),
omggif = require('omggif'),
THREE = require('three'),
SoftwareRenderer = require('three-software-renderer');
// How many frames and how large shall the GIF be?
var NUM_FRAMES = 200, WIDTH = 500, HEIGHT = 500;
// Our scene, camera and renderer and a box to render
var scene = new THREE.Scene(),
@AVGP
AVGP / index.html
Last active September 28, 2017 02:49
Example of using Three.js, the SoftwareRenderer
<!doctype html>
<html>
<head>
<title>Isomorphic Three.js</title>
<style>
html, body {
height: 100%;
height: 100vh;
padding: 0;