Skip to content

Instantly share code, notes, and snippets.

View vlfig's full-sized avatar

Vasco Figueira vlfig

View GitHub Profile
@vlfig
vlfig / fixed-strings.0.txt
Created July 11, 2018 15:34 — forked from dwijnand/fixed-strings.txt
Dual strings of the same length
lo/hi
src/dst
old/new
fst/snd
req/rsp
get/put/del
usr/pwd
new/add/mod/del/(rem)
0478ee04c185b5839cf6f9b659de46b095aafd0aa2fd21f43d48349a7b2ad26493821d9c1e757b299f81ad185f3a11b19a0804104a135eefafb628853b38dd6163;ixalon
@vlfig
vlfig / bumpme
Last active February 13, 2017 11:00
Mon Feb 13 11:00:27 UTC 2017

Keybase proof

I hereby claim:

  • I am vlfig on github.
  • I am vlfig (https://keybase.io/vlfig) on keybase.
  • I have a public key ASBLwErSmB-5tIbfuax-sfUVX-9Ml1Nxwz9sDiYQ4nBSRQo

To claim this, I am signing this object:

@vlfig
vlfig / lookup-artefact.sh
Last active December 22, 2015 20:19
Nexus SHA1 lookup script
#!/bin/bash
NEXUS_BASE_URL='https://repository.apache.org/'
NRA_SEG='service/local/data_index?sha1='
echo "Using $NEXUS_BASE_URL$NRA_SEG<SHA1 checksum>"
echo
lookup()
{
@vlfig
vlfig / TestCaseClassInterning.scala
Created September 20, 2012 17:27
Traits to easily make classes intern their instances assuring no duplicates exist at runtime. Don't forget to check your equals and hashCode.
import scala.collection.mutable.WeakHashMap
/**
* Utility traits for classes whose companion objects are to
* intern their instances, never creating repeated objects.
*
* Instances are cached based on their immutable
* arguments, as provided to companion object's {{apply()}}.
*/
@vlfig
vlfig / TestPathDependentTypeImplicit.scala
Created September 11, 2012 22:36
example of a path-dependent extension giving implicit external state-awareness to classes
case class MyClass(val value: Int)
/**
* maintains certain state about MyClass objects' dependencies
*
* between below and above are the interesting bits enabling
* the implicit state awareness leading to a clearer syntax
*/
class TestPathDependentTypeImplicit(val map: Map[MyClass, MyClass]) {
@vlfig
vlfig / ListSpanVariations.scala
Created August 27, 2012 16:55
List's span variations
import scala.collection.mutable.ListBuffer
/**
* Span-like inclusive methods for slicing list based on element predicates.
* @author Vasco Figueira
* @author Peter Empen
*/
class ListSpanVariations[A](l: List[A]) {
/**
@vlfig
vlfig / gist:2931792
Created June 14, 2012 17:57
Vessel, ship IMO number validator, validation function
public static final boolean isImoValid(String imo) {
if (imo == null || imo.length() != 7) {
return false;
}
char[] a = imo.toCharArray();
int sum = 0;
for(int i = 0; i < 6; i++) {
sum += (a[i]-48)*(a.length-i);
}
return sum % 10 == a[6]-48;
@vlfig
vlfig / gist:2429252
Created April 20, 2012 14:50
Educational pivot query
/* Educational pivot query
* rank() is oracle-specific, see http://www.adp-gmbh.ch/ora/sql/analytical/rank.html
*/
with tab_cols as (
select
table_name,
column_name,
rank() over (partition by table_name order by column_name asc) as ordinal
from user_tab_columns