Skip to content

Instantly share code, notes, and snippets.

@cruzer45
cruzer45 / GroovyAnsi.groovy
Created November 30, 2022 19:13 — forked from tvinke/GroovyAnsi.groovy
Simple ANSI colors in the terminal written in Groovy
// Ansi colors in Groovy
// Author: Ted Vinke
import static Ansi.*
println color("BOLD", Ansi.BOLD)
println color("ITALIC", Ansi.ITALIC)
println color("UNDERLINE", Ansi.UNDERLINE)
println color("BLINK", Ansi.BLINK)
println color("RAPID_BLINK", Ansi.RAPID_BLINK)
println color("REVERSE_VIDEO", Ansi.REVERSE_VIDEO)
@cruzer45
cruzer45 / Bootstrap.groovy
Created March 25, 2022 03:52
Using a service in Grails Bootstrap
import org.springframework.web.context.support.WebApplicationContextUtils
class BootStrap {
def init = { servletContext ->
def springContext = WebApplicationContextUtils.getWebApplicationContext(servletContext)
println "Initializing..."
def service = springContext.getBean("notificationService")
service.sendAdminNotification("[UP] started")
}
@cruzer45
cruzer45 / Bootstrap.groovy
Created March 23, 2022 16:31
Using a service in Grails Bootstrap
class BootStrap {
def init = { servletContext ->
def springContext = WebApplicationContextUtils.getWebApplicationContext(servletContext)
println "Initializing..."
def service = springContext.getBean("notificationService")
service.sendAdminNotification("[UP] started")
}
/**
* Note: this is not guaranteed to be called by the servlet container
@cruzer45
cruzer45 / SystemWebViewEngine.java
Created March 19, 2022 17:14
Enable remote debugging in Cordova Production webview.
//In {project}/platforms/android/CordovaLib/src/org/apache/cordova/engine/SystemWebViewEngine.java
//Determine whether we're in debug or release mode, and turn on Debugging!
ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
enableRemoteDebugging();
}
// ....
@cruzer45
cruzer45 / google-analytics-track-anchors.txt
Created January 12, 2021 01:06 — forked from bronwynv/google-analytics-track-anchors.txt
Gtag.js track URLS with anchor links
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX-Y"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXX-Y', {
'page_path': location.pathname + location.search + location.hash
});
@cruzer45
cruzer45 / Main.java
Last active October 25, 2019 09:20
A file demonstrating some mathematical errors while using Java Primitives. See it in action here https://repl.it/repls/ClientsidePinkChords
class Main {
public static void testWithFloats() {
System.out.println("testWithFloats\n");
float a = 0.1f;
float b = 0.1f;
float c = 0.1f;
float d = a + b + c;
float e = d * 3;
@cruzer45
cruzer45 / BootStrap.groovy
Created October 25, 2019 09:10 — forked from pledbrook/BootStrap.groovy
Embed Vert.x in Grails
import org.vertx.groovy.core.Vertx
class BootStrap {
def init = { servletContext ->
def vertx = Vertx.newVertx()
def httpServer = vertx.createHttpServer()
vertx.createSockJSServer(httpServer).installApp(prefix: '/events') { sock ->
sock.dataHandler { buff ->
sock << buff
server {
listen 80;
server_name xxx.com;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080;
proxy_read_timeout 1800;
@cruzer45
cruzer45 / check_available_package_versions.sh
Created July 31, 2018 01:10
Check the available version of a package in the repositories
apt-cache policy <packageName>
@cruzer45
cruzer45 / auto-orient-pictures.sh
Created June 7, 2018 03:44
Auto orient photos in a folder;
for i in *.jpg; do convert -auto-orient "$i" "$i"; done