Skip to content

Instantly share code, notes, and snippets.

View trickyBytes's full-sized avatar

Richard Tiffin trickyBytes

View GitHub Profile
@trickyBytes
trickyBytes / gist:d9fc2d8ba319e032294b5610fbf3f1d8
Last active October 22, 2020 09:53
Facts and definitions
Here are a few facts and definition about the text above:
- Everything is lowercase.
- There are only letters, full stops (`.`), and single whitespace characters.
- A _word_ is defined as a sequence of letters delimited by either a whitespace or a full stop `.` character.
- A full stop character is not considered a word. A full stop is never preceded or followed by whitespace.
- Any two words are separated either by a single whitespace character (`dolor sit`), or by a full stop with no spaces (`elit.sed`)
- A _sentence_ is defined as a sequence of words delimited by a full stop `.` character.
### Code answers to the following questions about the text above
lorem ipsum dolor sit amet consectetur lorem ipsum et mihi quoniam et adipiscing elit.sed quoniam et advesperascit et mihi ad villam revertendum est nunc quidem hactenus ex rebus enim timiditas non ex vocabulis nascitur.nummus in croesi divitiis obscuratur pars est tamen divitiarum.nam quibus rebus efficiuntur voluptates eae non sunt in potestate sapientis.hoc mihi cum tuo fratre convenit.qui ita affectus beatum esse numquam probabis duo reges constructio interrete.de hominibus dici non necesse est.eam si varietatem diceres intellegerem ut etiam non dicente te intellego parvi enim primo ortu sic iacent tamquam omnino sine animo sint.ea possunt paria non esse.quamquam tu hanc copiosiorem etiam soles dicere.de quibus cupio scire quid sentias.universa enim illorum ratione cum tota vestra confligendum puto.ut nemo dubitet eorum omnia officia quo spectare quid sequi quid fugere debeant nunc vero a primo quidem mirabiliter occulta natura est nec perspici nec cognosci potest.videmusne ut pueri ne verberibus quidem a
@trickyBytes
trickyBytes / service.java
Last active January 23, 2019 15:03
Pagination on service end-point
@PreAuthorize("hasAuthority('MOBILE_DEVICE')")
@GetMapping(path = uriListAssets)
@ResponseStatus(code = HttpStatus.OK)
public List<Asset> getAssets(@RequestParam(name = "page", required = false) Optional<Integer> page,
@RequestParam(name = "numOfResults", required = false) Optional<Integer> numOfResults) {
List<Asset> assets;
if (page.isPresent() && numOfResults.isPresent()) {
assets = assetRepository.findAll(PageRequest.of(page.get(), numOfResults.get())).getContent();
} else {
@trickyBytes
trickyBytes / tut.md
Created May 9, 2018 10:14 — forked from rain1024/tut.md
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@trickyBytes
trickyBytes / .java
Created April 11, 2018 14:35
Exposing the instantiation of an inner context for testing.
public class Enclosing {
public String methodA() {
getContext();
......
}
protected void getContext() {
Inner.getContext();
......
@trickyBytes
trickyBytes / example.java
Created July 25, 2017 08:21
Using Guava collection builders and Sets to create Cartesian product of some packages
List<List<IComponentsAction>> alternatives ...
Set<List<IComponentsAction>> product ...
final Builder<Set<IComponentsAction>> builder = ImmutableList.<Set<IComponentsAction>>builder();
alternatives.forEach(pkg -> {
builder.add(ImmutableSet.copyOf(pkg));
});
product = Sets.cartesianProduct(builder.build());
@trickyBytes
trickyBytes / atoms_use.clj
Last active November 18, 2015 09:41
Using atoms in Clojure
;A map stored in an atom
(def register (atom {}))
;An item to register
(defrecord register-item [item-name time-added])
(defn addSomethingToRegister [item-name register]
;Do the following inside a let
(let
;create new register-item and assing to ref item