Skip to content

Instantly share code, notes, and snippets.

View alxarch's full-sized avatar

Alexandros Sigalas alxarch

View GitHub Profile
@alxarch
alxarch / .gitignore
Last active August 29, 2015 14:05
PhantomJS scripts to interact with service.eudoxus.gr
node_modules/
@alxarch
alxarch / tex2mathml.js
Created September 25, 2014 11:42
Hack MathJax to use as a TeX to MathML converter.
MathJax.Hub.Register.MessageHook("End PreProcess", function () {
[].slice.apply(document.querySelectorAll("script[type^=math]")).forEach(function (s) {
var mml = MathJax.InputJax.TeX.Parse(s.innerHTML).mml();
var math = document.createElementNS("http://www.w3.org/1998/Math/MathML", "math");
math.setAttribute("xmlns", "http://www.w3.org/1998/Math/MathML");
// tricks toMathML extension
mml.parent = {};
var mathml = mml.toMathML()
math.innerHTML = mathml
@alxarch
alxarch / url.coffee
Created October 8, 2014 11:02
url filters for angular
urlModule = angularModule "url", ["ngRoute"]
class Url
constructor: (@baseUrl) ->
absoluteUrl: (url) ->
unless url.match /^(\w+:)?\/\//
url = "/#{url}" unless url[0] is '/'
url = "#{@baseUrl}#{url}"
url
@alxarch
alxarch / katexparse.js
Created March 13, 2015 20:04
katex parse text
(function () {
var replacements = {
"α": "\\alpha",
"β": "\\beta",
"γ": "\\gamma",
"δ": "\\delta",
"ε": "\\epsilon",
"ζ": "\\zeta",
"η": "\\eta",
"θ": "\\theta",
@alxarch
alxarch / cc-proof.php
Created November 16, 2011 20:35
Cascading content proof of concept
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
define('BASE', str_replace('index.php', '', $_SERVER['SCRIPT_NAME']));
define('DS', DIRECTORY_SEPARATOR);
define('WEBDIR', dirname(__FILE__));
function cache($path, $output=null){
@alxarch
alxarch / vector-render.md
Created February 20, 2012 21:18
Vector Render for blender

Vector Render

Current status

Features implemented

Features wishlist

Priorities

@alxarch
alxarch / basex-daemon.sh
Created October 22, 2012 22:04
BaseX startup service script for Debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: skeleton
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: BaseX Server
# Description: Manage BaseX XML Database Server.
### END INIT INFO
module.exports = loopify = ([condition, sleep]..., action) ->
unless "function" is typeof condition
sleep ?= +condition
condition = -> yes
unless "function" is typeof action
throw new TypeError "Invalid callback"
sleep = +sleep
handle = null
start = -Infinity
UPDATE emails SET data = replace(data, "&Alpha;", "Α");
UPDATE emails SET data = replace(data, "&Beta;", "Β");
UPDATE emails SET data = replace(data, "&Gamma;", "Γ");
UPDATE emails SET data = replace(data, "&Delta;", "Δ");
UPDATE emails SET data = replace(data, "&Epsilon;", "Ε");
UPDATE emails SET data = replace(data, "&Zeta;", "Ζ");
UPDATE emails SET data = replace(data, "&Eta;", "Η");
UPDATE emails SET data = replace(data, "&Theta;", "Θ");
UPDATE emails SET data = replace(data, "&Iota;", "Ι");
UPDATE emails SET data = replace(data, "&Kappa;", "Κ");
@alxarch
alxarch / mnc-mcc.xquery
Last active November 10, 2015 12:48
Fetch mnc mcc data from wikipedia
declare option output:method "json";
let $page := doc("https://en.wikipedia.org/wiki/Mobile_country_code")
return
<json type="array">
{
for $h4 in $page//div[@id="bodyContent"]//h4
let $country-code := $h4/span[@id]/text()[last()]
let $rows := head($h4/following::table)/tr[td]