Skip to content

Instantly share code, notes, and snippets.

View avermeulen's full-sized avatar

Andre Vermeulen avermeulen

  • project codeX
  • Cape Town, South Africa
View GitHub Profile
@avermeulen
avermeulen / basicAngular.js
Last active September 23, 2020 05:21
A very basic AngularJS application
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app="myApp">
<div ng-controller="CtrlOne">Hello, {{name}}</div>
<script>
@avermeulen
avermeulen / gist:11197548
Created April 22, 2014 23:10
Html Scraping using PhantomJS and JQuery
var page = require('webpage').create();
page.onAlert = function (msg) {
console.log('alert!!> ' + msg);
};
page.onConsoleMessage = function (msg, line, source) {
console.log('console> ' + msg);
};
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
h1 {
color : orange;
}
@avermeulen
avermeulen / gist:dd71099312277eb40614
Created February 1, 2015 16:17
Blinking an LED using ruby
require 'artoo'
connection :arduino, adaptor: :firmata, port: '/dev/tty.usbmodem411'
#connection :firmata, :adaptor => :firmata, :port => '127.0.0.1:8023'
device :board, :driver => :device_info
device :led, :driver => :led, :pin => 13
work do
puts "Firmware name: #{board.firmware_name}"
@avermeulen
avermeulen / betterAsync.js
Last active August 29, 2015 14:27
Taming callbacks with generators
'use strict'
// you need to use iojs for this... or something
function async(myGenerator){
return function(){
var theGenerator = myGenerator.apply(this, arguments);
function handle(result){
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="number"></div>
<div class="number"></div>
<div class="number"></div>
@avermeulen
avermeulen / webcam.html
Created August 18, 2016 10:29
basic html5 web cam example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<video id="video" width="640" height="480" autoplay></video>
@avermeulen
avermeulen / 101.md
Last active August 30, 2017 06:26
TypeScript 101

TypeScript 101

TypeScript is a superset of JavaScript it supports ES5, ES6, ES2016, ES2017 and more. TypeScript is JavaScript, but JavaScript is not TypeScript.

TypeScript add typing to JavaScript. It allows you to add types to variables and functions, TypeScript does type checking. Type checking is the process of ensure that variables have the correct types, it ensures type safety. Type safety leads to less errors in your code as the compiler is telling you about errors early. Typing is a safety harness for your code.

TypeScript is a typed superset of JavaScript that compiles into plain JavaScript.

The TypeScript compiler transpiles (converts) the TypeScript code into plain JavaScript using the the TypeScript compiler.

@avermeulen
avermeulen / index.js
Created September 13, 2017 08:51
Simple API using ExpressJS
const express = require('express');
const bodyParser = require('body-parser');
let app = express();
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
const fs = require('fs');
const {promisify} = require('util');
// Using Node 8.x to create a promise for us
let asyncReadFile = promisify(fs.readFile);
/**
Create your own Promise
**/
function readFile(fileName){
return new Promise(function(accept, reject){