This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” | |
- C.A.R. Hoare (British computer scientist, winner of the 1980 Turing Award) | |
2. “If debugging is the process of removing software bugs, then programming must be the process of putting them in.” | |
- Edsger Dijkstra (Dutch computer scientist, winner of the 1972 Turing Award) | |
3. “Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” | |
- Bill Gates (co-founder of Microsoft) | |
4. “Nine people can’t make a baby in a month.” (regarding the addition of more programmers to get a project completed faster) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# This script converts a WMA file into a MP3 file. | |
# Requisites: mplayer e lame | |
# Disclaimer: it worked last time I checked, but it was a long time ago, | |
# so I put it here just to reference. Use it at your own risk. | |
import os | |
list = os.listdir(".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Python implementations of the search relevance evaluation metrics described at | |
## https://opensourceconnections.com/blog/2020/02/28/choosing-your-search-relevance-metric/ | |
## | |
## | |
def precision(docs): | |
return sum(docs) / len(docs) if docs else 0 | |
def avg_precision(docs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gource -s .06 -1280x720 --auto-skip-seconds .1 --multi-sampling --stop-at-end --key --highlight-users --hide mouse,progress,files,filenames,dirnames --file-idle-time 0 --max-files 0 --background-colour 000000 --font-size 22 --title "Lucene/Solr" --output-ppm-stream - --output-framerate 30 | avconv -y -r 30 -f image2pipe -vcodec ppm -i - -b 65536K movie.mp4 | |
&& ffmpeg -i movie.mp4 -b:v 3048780 -vcodec libx264 -crf 24 output.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val list = (1 to 10).toList | |
// imutable map | |
val map1 = list.foldLeft(Map.empty[Int,String])( (map, value) => map + (value -> value.toString) ) | |
// this is equivalent to | |
val map1 = list.foldLeft(Map.empty[Int,String])( (map, value) => map + ((value, value.toString)) ) | |
// imutable map with more complex value (note the extra parenthesis) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import secrets | |
import sys | |
from hashlib import sha256 | |
from base64 import b64encode, b64decode | |
## | |
## Based on the logic here: https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/security/Sha256AuthenticationProvider.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Usage: | |
## $ chmod +x fetcher.sh | |
## $fetcher.sh <output file> | |
SOLR_URL="http://localhost:8983/solr" | |
COLLECTION="teste" | |
ROWS=10 | |
FL=*,score # No space around commas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.lucene.analysis.*; | |
import org.apache.lucene.analysis.core.WhitespaceTokenizer; | |
import org.apache.lucene.analysis.miscellaneous.DelimitedTermFrequencyTokenFilter; | |
import org.apache.lucene.document.Document; | |
import org.apache.lucene.document.Field; | |
import org.apache.lucene.document.FieldType; | |
import org.apache.lucene.index.*; | |
import org.apache.lucene.search.IndexSearcher; | |
import org.apache.lucene.search.MatchAllDocsQuery; | |
import org.apache.lucene.search.TopDocs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.company; | |
import java.math.BigInteger; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import java.util.Objects; | |
import java.util.stream.Collectors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WeakHashMap<Integer, String> map = new WeakHashMap<Integer, String>(); | |
map.put(new Integer(10), "aaa"); // remove entry | |
// map.put(10, "aaa"); // don't remove entry | |
// map.put(Integer.valueOf(10), "aaa"); // don't remove entry | |
for (int i = 0; i < Integer.MAX_VALUE; i++) { | |
if (map.size() != 0) { | |
System.out.println("At iteration " + i + " the map still holds the reference to object"); | |
} else { |
NewerOlder