Skip to content

Instantly share code, notes, and snippets.

insert into hero(name) values('Ms Nice');
insert into hero(name) values('Yes Man');
insert into hero(name) values('Bombastico');
insert into hero(name) values('Fennel');
insert into hero(name) values('Magnostic');
insert into hero(name) values('Duck Man');
insert into hero(name) values('Silly Putty Man');
insert into hero(name) values('Company Man');
package io.navan.heroesbackend;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;
public interface HeroRepository extends CrudRepository<Hero, Long> {
@RestResource(path = "name", rel="name")
@Query("from Hero h where lower(h.name) like CONCAT('%', lower(:contains), '%')")
@Entity
public class Hero {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
public Long getId() {
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
@finsterthecat
finsterthecat / remove-all-containers.sh
Last active January 16, 2018 20:58
Remove all docker containers in one step
docker rm -vf $(docker ps -a -q)
' Alt-F11 in Word to get into VBA mode
' Then Insert>>Module
' Paste this in and Run
Public Sub CreateOutline()
Dim docOutline As Word.Document
Dim docSource As Word.Document
Dim rng As Word.Range
Dim astrHeadings As Variant
@finsterthecat
finsterthecat / i_failed_a_twitter_interview.rb
Last active January 16, 2018 20:59
Ruby solution for http://qandwhat.apps.runkite.com/i-failed-a-twitter-interview/. A bit more verbose but perhaps slightly more efficient solution than others? Nope, just more verbose.
walls = [2,5,1,2,3,4,7,7,6]
# array of max values of elements to the left for each element
def running_max(_walls)
maxmin = 0
_walls.inject([]) do |maxes, c|
maxes << if (c < maxmin) then
maxmin
else
maxmin = c
@finsterthecat
finsterthecat / gist:5867525
Created June 26, 2013 13:52
subl command for windows. Example of how to use doskey to creating a command without having to pollute my path.
doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*
@finsterthecat
finsterthecat / fizzbuzz.rb
Created June 24, 2013 03:03
Now, am I hired or what?
1.upto(100).each do |x|
s = ""
s+= 'fizz' if (x % 3 == 0)
s += 'buzz' if (x % 5 == 0)
s = x.to_s if (s.empty?);
puts s
end
package ca.ontario.moh.stix.loadfile;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Decrypt file using 7zip
*
*/