Skip to content

Instantly share code, notes, and snippets.

@ivanteoh
ivanteoh / 203-bash1.txt
Created July 7, 2020 10:19
Jolla SSH Using Public Key
$ chmod 700 /home/hub/.ssh
@ivanteoh
ivanteoh / 188-template1.html.django
Created July 7, 2020 10:08
Python Web Templating Battle
{% extends "base_generic.html" %}
{% block title %}{{ section.title }}{% endblock %}
{% block content %}
<h1>{{ section.title }}</h1>
{% for story in story_list %}
<h2>
<a href="{{ story.get_absolute_url }}">
@ivanteoh
ivanteoh / 176-step1.html
Created July 6, 2020 11:56
D3: Tutorial - Scale graph
<!DOCTYPE html>
<html>
<head>
<title>Scale Graph</title>
</head>
<body>
<div id="demoContainer">
<div id="option">
<input name="updateButton" type="button" value="Update"/>
</div>
@ivanteoh
ivanteoh / 174-homework1.html
Created July 6, 2020 11:44
Javascript: 101 Week 5 Track 2
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>JavaScript 101</title>
<script type="text/javascript">
function load()
{
function forEach(array, action) {
@ivanteoh
ivanteoh / 173-reflection1.js
Created July 6, 2020 11:41
Javascript: 101 Week 5 Track 1
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
@ivanteoh
ivanteoh / 172-homework1.js
Created July 6, 2020 11:37
Javascript: 101 Week 4
// from Douglas Crockford's video 'An Incovenient API - The Theory of the DOM'
// http://video.yahoo.com/watch/111582/992708
function walkTheDOM(node, func) {
func(node);
node = node.firstChild;
while (node) {
walkTheDOM(node, func);
node = node.nextSibling;
}
}
@ivanteoh
ivanteoh / 171-exercise61a.js
Created July 6, 2020 11:32
Javascript: 101 Week 3 Track 2
function forEach(array, action) {
var i;
for (i = 0; i < array.length; i++) {
action(array[i]);
}
}
function reduce(combine, base, array) {
forEach(array, function (element) {
base = combine(base, element);
@ivanteoh
ivanteoh / 170-exercise61a.js
Created July 6, 2020 11:26
Javascript: 101 Week 3 Track 1
function forEach(array, action) {
for (var i = 0; i < array.length; i++)
action(array[i]);
}
function reduce(combine, base, array) {
forEach(array, function (element) {
base = combine(base, element);
});
return base;
@ivanteoh
ivanteoh / 167-exercise41.js
Created July 6, 2020 11:10
Javascript: 101 Week 2 Track 2
var cat = {}; // a 'set' of names
cat['Red Lion'] = {'colour': 'grey', 'size': 46}; // a name is added to this set
cat['Doctor Hobbles'] = {'colour': 'white', 'size': 15};
cat['Little Iroquois'] = {'colour': 'yellow', 'size': 30};
delete cat['Doctor Hobbles']; // a name is removed from this set
if ('Red Lion' in cat) { // check whether a name occurs in this set.
alert('you have "Red Lion" cat.');
}
@ivanteoh
ivanteoh / 166-homework1.js
Created July 6, 2020 10:58
Javascript: 101 Week 2 Track 1
function absolute(number) {
if (number < 0)
return -number;
return number;
}