Skip to content

Instantly share code, notes, and snippets.

View neofreko's full-sized avatar

Akhmad Fathonih neofreko

View GitHub Profile
@neofreko
neofreko / wait-until-async.js
Created June 1, 2018 01:16
wait until condition becomes truthy. Inspired by former works or wait-until libraries and tutorials.
const waitUntil = async (asyncCondition, timeoutMs) => {
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
const intervalMs = 1000;
const startTime = Date.now();
const result = await asyncCondition();
const endTime = Date.now();
const timeSpentMs = endTime - startTime;
console.log(`checking waitUntil condition, timeout in: ${timeoutMs}ms`);
Wed Apr 25 07:10:44 UTC 2018
@neofreko
neofreko / image_has_sentence.rb
Created April 25, 2018 03:55
extract sentence using rtesseract
# brew install tesseract
# gem install rtesseract
# gem install mini_magick
#
# example:
# puts image_has_sentence?('/Users/me/Pictures/hi.png', 'hello world')
require 'rtesseract'
require 'mini_magick'

Keybase proof

I hereby claim:

  • I am neofreko on github.
  • I am neofreko (https://keybase.io/neofreko) on keybase.
  • I have a public key ASBOuUtqWIaiFCPUC_qesLBjMUSCr05Tjiaw2BZgk0j_vgo

To claim this, I am signing this object:

@neofreko
neofreko / anno.txt
Created December 28, 2013 19:20
Given a node annotated with this JSON, how would you visualize those nodes. How do you browse thru it?
[ { start: 13,
end: 19,
spot: 'DESIGN',
confidence: 0.158,
id: 8560,
title: 'Design',
uri: 'http://en.wikipedia.org/wiki/Design',
abstract: 'Design is the creation of a plan or convention for the construction of an object or a system (as in architectural blueprints, engineering drawings, business processes, circuit diagrams and sewing patterns). Design has different connotations in different fields (see below). In some cases the direct construction of an object (as in pottery, engineering, management, cowboy coding and graphic design) is also considered to be design.',
label: 'Design',
categories: [ 'Design', 'Architectural design', 'Arts' ] },
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Akhmad Fathonih</author>
<description>URL 404 check</description>
<sampleQuery><![CDATA[
USE 'https://www.dropbox.com/s/n6xzivkwyfz3lhm/yql-404.xml?dl=1' AS mytable;select * from mytable where url = 'http://bit.ly/13uffkf']]></sampleQuery>
<documentationURL></documentationURL>
</meta>
<bindings>
@neofreko
neofreko / weather.pegjs
Created February 24, 2013 08:02
weather grammar for my poor man's nlp
start
= left:weather blank right:location {return [left, right]}
expr
= & blank* left:(primitive / compound)+ blank*
compounds
= left:compound+ {return left}
compound
= left:primitive blank right:primitive {return left+right}
@neofreko
neofreko / base.pegjs
Created February 24, 2013 07:47
A common validator
start
= expr
expr
= & blank* left:(primitive / compound)+ blank* {return left}
compounds
= left:compound+ {return left}
compound
= left:primitive blank right:primitive {return [left, right]}
@neofreko
neofreko / IndexController.php
Last active December 10, 2015 01:58 — forked from anonymous/IndexController.php
I wish I have mail-preview.rb in PHP. Originally, these are part of ZF (CLI) controller code. Converting to non-controller is left as exercise for the reader. Yes, I stole the template from the original erb
<?php
class IndexController {
public function mailpreviewAction() {
$getopt = $this->getRequest()->getOpt();
$extra = $getopt->getRemainingArgs();
// create new getopt
$cliopt = new Zend_Console_Getopt(array(
'filename|f=s' => 'Zend generated email',
'browser|b=s' => 'Open using specified browser app'
));
@neofreko
neofreko / version-bumper.sh
Created October 10, 2012 14:46
Version bumper for Android manifest
#configure this as external tool to run on your project
#!/bin/sh
#git revision
rev=$(git log --pretty=format:'%h' -n 1)
#version code
vc=$(grep android:versionCode AndroidManifest.xml | cut -f2 -d\")
vc=$(($vc+1))