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.springframework.context.ApplicationContext; | |
public class AppContext { | |
private static ApplicationContext context; | |
public static void setApplicationContext(ApplicationContext applicationContext) { | |
context = applicationContext; | |
} |
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
/* | |
* Code by @vmironov on Kotlinlang slack. | |
* | |
* This code uses dynamic proxies in Java to make it easier to access inaccessible classes via an accessible representation. | |
*/ | |
inline fun <reified T : Any> createMirror(value: Any) = createMirror(value, T::class.java) | |
fun <T> createMirror(value: Any, clazz: Class<T>): T { | |
val loader = clazz.classLoader |
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 com.google.devtools.ksp.getClassDeclarationByName | |
import com.google.devtools.ksp.processing.Resolver | |
import com.google.devtools.ksp.symbol.* | |
/** | |
* Reified function to check if receiver [KSType] is assignable from [T] class | |
*/ | |
inline fun <reified T> KSType.isAssignableFrom(resolver: Resolver): Boolean { | |
val classDeclaration = requireNotNull(resolver.getClassDeclarationByName<T>()) { | |
"Unable to resolve ${KSClassDeclaration::class.simpleName} for type ${T::class.simpleName}" |
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
abstract class CrudRepository <ID, DOMAIN, TABLE : Table> { | |
abstract val table: TABLE | |
abstract fun toDomain(row: ResultRow): DOMAIN | |
abstract fun toRow(domain: DOMAIN): TABLE.(InsertStatement<Number>) -> Unit | |
abstract fun match(id: ID): SqlExpressionBuilder.() -> Op<Boolean> | |
abstract fun extractId(domain: DOMAIN): ID | |
abstract fun updateRow(domain: DOMAIN): TABLE.(UpdateStatement) -> Unit | |
/** | |
* Get a particular record by its ID. |
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
const fs = require("fs"); | |
const path = require("path"); | |
function newItem(name, url) { | |
return { name, url }; | |
} | |
const bookmarkPath = path.join( | |
process.env.HOME, | |
"/Library/Application Support/Google/Chrome/Default/Bookmarks" |
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
require 'sidekiq/api' | |
# 1. Clear retry set | |
Sidekiq::RetrySet.new.clear | |
# 2. Clear scheduled jobs | |
Sidekiq::ScheduledSet.new.clear |
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
# First the end result of what we want: | |
class Foo | |
before_hook :whoa | |
before_hook :amazing | |
def test | |
puts "This is kinda cool!" | |
end |
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
export PGHOST=localhost |
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
# Copyright (c) 2014 Lukas Fittl <lukas@pganalyze.com> | |
# | |
# Released in the public domain - fork as you wish. | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'curses' | |
gem 'mixlib-cli' |
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
<div id="root"></div> | |
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script> | |
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | |
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> | |
<script type="text/babel"> | |
class Greeting extends React.Component { | |
render() { | |
return (<p>Hello world</p>); | |
} | |
} |
NewerOlder