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
# shortform git commands | |
alias g='git' | |
# get a list of all commit messages for a repo | |
git log --pretty=format:'%s' | |
# push changes to an empty git repository for the first time | |
git push --set-upstream origin master | |
# Remove + and - from start of diff lines |
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
#pragma once | |
class FakeInt { | |
public: | |
FakeInt(int value) | |
: value(value) | |
{ | |
} | |
operator int() const |
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
@SpringBootApplication | |
@EnableTask | |
public class SampleTask { | |
@Bean | |
public CommandLineRunner commandLineRunner() { | |
return new HelloWorldCommandLineRunner(); | |
} | |
public static void main(String[] args) { |
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
SQLClientHelper.inTransactionSingle(client, sqlConnection -> { | |
return sqlConnection.rxExecute("INSERT INTO albums (name) VALUES ('The Israelites')") | |
.andThen(sqlConnection.rxExecute("INSERT INTO tracks (album, name) VALUES ('The Israelites', 'Israelites')")) | |
.andThen(sqlConnection.rxExecute("INSERT INTO tracks (album, name) VALUES ('The Israelites', 'Too Much Too Soon')")) | |
.andThen(sqlConnection.rxQuery("SELECT name FROM tracks WHERE album = 'The Israelites'").map(ResultSet::getResults)) | |
}).map(rows -> { | |
// Transform DB rows into a client-friendly JSON object | |
}).subscribe(json -> { | |
// Send JSON to the client | |
}, t -> { |
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
rest("/api/") | |
.id("api-route") | |
.consumes("application/json") | |
.post("/bean") | |
.bindingMode(RestBindingMode.json_xml) | |
.type(MyBean.class) | |
.to("direct:remoteService"); | |
//... |
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
def clazz = new MethodCallExpression(new VariableExpression("this"), "getClass", EMPTY_ARGUMENTS) | |
def body = new ExpressionStatement(new MethodCallExpression(clazz, "getName", EMPTY_ARGUMENTS)) | |
classNode.addMethod('getDescription', ACC_PUBLIC, STRING_TYPE, EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body) |
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
//До 2.5 приходилось писать так: | |
def clazz = new MethodCallExpression(new VariableExpression("this"), "getClass", EMPTY_ARGUMENTS) | |
def body = new ExpressionStatement(new MethodCallExpression(clazz, "getName", EMPTY_ARGUMENTS)) | |
classNode.addMethod('getDescription', ACC_PUBLIC, STRING_TYPE, EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, body) | |
//После 2.5 первые две строчки превращаются в такое: | |
def body = macro(true) { | |
getClass().name |
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
object Config { | |
private val icon_ = AtomicReference<Image>() | |
val icon: Image | |
get() = icon_.get()!! | |
fun updateIcon(file: String) { | |
val imageData = Image(file) | |
icon_.compareAndSwap(icon_.get(), imageData.freeze()) | |
} | |
} |
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
<plugin> | |
<groupId>com.google.cloud.tools</groupId> | |
<artifactId>jib-maven-plugin</artifactId> | |
<version>0.9.6</version> | |
<configuration> | |
<to> | |
<image>gcr.io/my-project/image-built-with-jib</image> | |
</to> | |
</configuration> | |
</plugin> |