Skip to content

Instantly share code, notes, and snippets.

View alxarch's full-sized avatar

Alexandros Sigalas alxarch

View GitHub Profile
@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 / ST_Distance_Sphere.sql
Created November 13, 2015 14:10
ST_Distance_Sphere Polyfill
CREATE FUNCTION `ST_Distance_Sphere` (a POINT, b POINT)
RETURNS float
no sql deterministic
BEGIN
declare R INTEGER DEFAULT 6371000;
declare `φ1` float;
declare `φ2` float;
declare `Δφ` float;
declare `Δλ` float;
@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]
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;", "Κ");