Skip to content

Instantly share code, notes, and snippets.

View alxarch's full-sized avatar

Alexandros Sigalas alxarch

View GitHub Profile
@alxarch
alxarch / geeklish.sql
Created October 26, 2014 10:21
Greek to greeklish for MySQL
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `greeklish`(input text charset utf8) RETURNS text CHARSET utf8
BEGIN
DECLARE result text charset utf8 DEFAULT '';
DECLARE len INT(4) DEFAULT 0;
DECLARE pos INT(4) DEFAULT 1;
DECLARE letter VARCHAR(10) charset utf8;
SET input = LOWER(input);
SET len = CHAR_LENGTH(input);
@alxarch
alxarch / transliterate-greek.php
Created November 16, 2011 20:32
Greek transliteration
<?php
/**
* Hackish transliteration rules for greek text.
* @author Alexandros Sigalas <alxarch@gmail.com>
* @license Apache License 2.0
*/
class TransliterateGreek
{
@alxarch
alxarch / cursor.rs
Created April 6, 2020 10:56
Effing cursor
pub mod cursor {
use std::ops::Deref;
pub struct Cursor<S> {
src: S,
cursor: Index,
}
enum Index {
Asc(usize),
Desc(usize),
Verifying my Blockstack ID is secured with the address 1FYD3TKnB9gFSpwtRLzmFgPYjRkvJteBfw https://explorer.blockstack.org/address/1FYD3TKnB9gFSpwtRLzmFgPYjRkvJteBfw
@alxarch
alxarch / once.go
Created November 5, 2018 12:53
Like sync.Once but with errors
// OnceNoError is like sync.Once but retries until no error occured.
type OnceNoError struct {
mu sync.Mutex
done uint32
}
func (once *OnceNoError) Do(fn func() error) (err error) {
if atomic.LoadUint32(&once.done) == 1 {
return
}
#/usr/bin/env python
import sys
[sys.stdout.write(line.decode('unicode_escape')) for line in sys.stdin]
@alxarch
alxarch / vw.md
Last active October 26, 2016 10:30

vouliwatch.gr

components

search

item feed

@alxarch
alxarch / monitor.sh
Last active October 7, 2016 09:29
Monitoring events and push to Redis
#!/bin/sh
if [ -z "$(which redis-cli)" ]; then
apk add --no-cache redis
fi
MONITOR_URL=$1
EVENT_NAME=${EVENT_NAME:=status}
REDIS_HOST=${REDIS_HOST:=localhost}
EVENT_QUEUE=${EVENT_QUEUE:=monitoring:events}
var db = require('Sequelize')();
db.dialect.supports.schemas = true;
var Q = db.dialect.QueryGenerator;
module.exports = function (req, res, next) {
var schema = req.schema;
var quoteTable = (param, as) {
if ('string' == param) {
param = { tableName: param };
}
param.schema = schema;
@alxarch
alxarch / numerals.xqm
Last active December 22, 2015 12:59
XQuery numerals module
module namespace num = "http://thinking.gr/modules/numerals";
declare variable $num:valid-greek := "^[ρστυφχψωϠϡͲͳ]?[ικλμνξοπϞϟ]?[αβγδεζηθςϜϝ]$";
declare function num:to-greek($i as xs:integer) as xs:string
{
if($i gt 0 and $i lt 1000) then
let $x100 := op:numeric-integer-divide($i, 100)
let $x10 := op:numeric-integer-divide($i mod 100, 10)
let $x1 := $i mod 10