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
(ns app.fortune | |
#?(:cljs (:require-macros app.fortune)) | |
(:require #?(:clj [clojure.java.shell :as sh]) | |
[hyperfiddle.electric :as e] | |
[hyperfiddle.electric-dom2 :as dom] | |
[hyperfiddle.electric-ui4 :as ui])) | |
#?(:clj (defn fortune [] (:out (sh/sh "fortune")))) | |
#?(:clj (defonce !x (atom (fortune))) ) | |
(e/def x (e/server (e/watch !x))) |
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
(defmacro spy [expr] `(let [a# ~expr] (println (str '~expr " => " a#)) a#)) |
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
// ==UserScript== | |
// @name HackerNews Scrubbed | |
// @namespace http://jadn.com/bob | |
// @version 0.1 | |
// @description enter something useful | |
// @match https://news.ycombinator.com/* | |
// @copyright 2014+, bherrmann | |
// ==/UserScript== | |
document.getElementsByTagName("table")[0].getElementsByTagName("tr")[0].style.display="none"; |
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
// Java code for finding properties (is/get/set pairs) | |
for(Method method: bean1.getClass().getMethods()){ | |
if(method.getDeclaringClass()!=AccountRequest.class || !(method.getName().startsWith("get") || method.getName().startsWith("is")) || method.getTypeParameters().length!=0) | |
continue; | |
String propName = method.getName().substring(2,method.getName().length()); | |
if(method.getName().startsWith("get")){ | |
propName = method.getName().substring(3,method.getName().length()); | |
} | |
Method setter = null; | |
try { |
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
// Takes table columns and generates fields and get/setters for hibernate classes | |
def schema = ''' | |
full_name varchar(64) not null, | |
given_name varchar(32), | |
middle_initial varchar(1), | |
last_name varchar(32), | |
creation_time datetime, -- some comment | |
''' |
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
// Move text to the clipboard | |
def clfile = 'some interesting string' | |
java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(clfile); | |
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(data, data); | |
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
// assert schema2hibernate('take_this') == 'takeThis' | |
def schema2hibernate = { table_name -> | |
boolean lastUnder = false | |
table_name.collect { | |
if( it == '_' ){ | |
lastUnder = true | |
return '' | |
} | |
if (lastUnder) { | |
lastUnder = false |
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
assert getEnumName('getPoeHoeFoe') == 'POE_HOE_FOE' | |
String getEnumName(methodName){ | |
def str = methodName.collect { | |
(Character.isUpperCase(it as char)?'_':'') + it | |
}.join() | |
str = str[4..-1].toUpperCase() | |
} |
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
// Just cut/paste this into a GroovyConsole to evaluate. (last line is used for testing) | |
// input: MY_ENUM_NAME output: myEnumName | |
String enumToJava(String name){ | |
boolean lastUnder=false | |
name.collect { | |
if(it=='_') { | |
lastUnder = true; | |
return '' | |
} | |
def c = it |
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
// input: someGroovyCodeToTakeCamelCaseAndMakeItNicer | |
// output: Some Groovy Code To Take Camel Case And Make It Nicer | |
def str = 'someGroovyCodeToTakeCamelCaseAndMakeItNicer'.collect { | |
(Character.isUpperCase(it as char)?' ':'') + it | |
}.join() | |
str = str[0].toUpperCase() + str[1..-1] |
NewerOlder