Skip to content

Instantly share code, notes, and snippets.

var 凸 = (function(凸) {
"use strict";
var W = window,
D = document,
minFontSize,
floatMinFontSize,
newColor,
walkDOM = function (node, func) {
if (node.nodeType === 1) {
func(node);
@lucamug
lucamug / waitForSomething.js
Last active October 3, 2016 19:59
凸.waitForSomething
var 凸 = (function(凸) {
"use strict";
var id = 0,
waitForSomething = function (obj) {
obj = obj || {};
obj.c = obj.c || 1;
obj.cMax = obj.cMax || 10;
obj.verbose = obj.verbose || false;
obj.id = obj.id === undefined ? id++ : obj.id;
var log = function(text, text2) {
// gps-converter by lucamug
// more info at
// https://github.com/lucamug/gps-converter
// https://coding-and-design.blogspot.de/2016/11/gps-nmea-gpx-or-klm-converter-for.html
var fs = require('fs'),
folderOriginalData = 'data/original-gps-data/',
folderOutputData = 'data/',
r = [],
savePointsEvery = 4,
precision = 6,
@lucamug
lucamug / sftp-upload.js
Created November 15, 2016 16:12
Minimal Javascript code to upload a file using sftp. It requires ssh2
var fs = require('fs'),
client = require('ssh2').Client;
upoladFile({
localFolder: "",
localFile: "",
remoteFolder: "",
remoteFile: "",
host: "",
port: 0,
// See https://coding-and-design.blogspot.de/2016/11/are-all-element-tags-closed-testing-it.html for more info
var 凸 = typeof global === 'undefined' ? 凸 : global.tmp;
var 凸 = (function (凸) {
凸.buildGetPageFunction = function buildGetPageFunction() {
if (typeof global === 'undefined') {
// Browser
return function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
// Simple way to embed html in javasript
Array.prototype.joinHtml = function () {
return this.join('');
};
String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g,
function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
<?xml version="1.0" encoding="UTF-8"?>
<recipe version="1.1">
<line>
<originaltext>24 jalapeno peppers</originaltext>
<annotation>create_ing(ing0, "24 jalapeno peppers")</annotation>
</line>
<line>
<originaltext>1 pound sausage</originaltext>
<annotation>create_ing(ing1, "1 pound sausage")</annotation>
</line>
(function() {
function getSource(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
return callback(xhr.responseText);
}
};
xhr.open('GET', url, true);
xhr.send(null);
{
"labelAnnotations": [{
"mid": "/m/02wbm",
"description": "Food",
"score": 92
}, {
"mid": "/m/02q08p0",
"description": "Dish",
"score": 86
}, {
@lucamug
lucamug / downloadGoogleSpreadsheet.js
Last active January 16, 2017 20:32
Javascript snippet to download a Google Spreadsheet that as multiple worksheets in JSON
"use strict";
let request = require("request");
let organizeData = (feed) => {
// Parse data as it comes from Google Spreadsheet and
// reorganize it in a simplified data structure
let entry = feed.entry,
r = {
title: $t(feed, "title"),
orderedSheetsTitle: [],
orderedSheetsId: [],