Pages

Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Sunday, May 3, 2020

Blogger Syntax Highlighting (Again)

I was working on a blog post with Kotlin and noticed SyntaxHighlighter had no brush for Kotlin, not even V4.  Given that, and the popularity of highlight.js, I've decided to switch to that. You just gotta add something like this in the <header> of your Blogger template.
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/default.min.css' rel='stylesheet'/>-->
<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/androidstudio.min.css' rel='stylesheet'/>
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/atom-one-dark.min.css' rel='stylesheet'/>-->
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/agate.min.css' rel='stylesheet'/>-->
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/darcula.min.css' rel='stylesheet'/>-->
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/rainbow.min.css' rel='stylesheet'/>-->
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/railscast.min.css' rel='stylesheet'/>-->
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/solarized-dark.min.css' rel='stylesheet'/>-->
<!--<link href='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/styles/zenburn.min.css' rel='stylesheet'/>-->
<script src='//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/highlight.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/autohotkey.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/bash.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/c-like.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/c.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/clojure.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/cpp.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/csharp.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/css.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/dockerfile.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/dos.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/fsharp.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/java.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/javascript.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/go.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/groovy.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/markdown.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/nsis.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/pgsql.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/plaintext.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/powershell.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/properties.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/python.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/ruby.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/scala.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/scss.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/sql.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/typescript.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/vbscript.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/xml.min.js'/>
<script charset='UTF-8' src='https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.0.0/languages/yaml.min.js'/>
<scrpt>hljs.initHighlightingOnLoad();</script>

There are many other languages and styles available. And as with SyntaxHighlighter, you need to escape < with &lt; and > with &gt.
Then you put your code inside
<pre><code class="kotlin"></code>

</pre>
or
<pre><code class="lang-kotlin">

</code></pre>
or
<pre><code class="language-kotlin">

</code></pre>

Thursday, October 3, 2013

HDFS NameNode Username Hack

I created a userscript to override the username when (when programmatically detectible) to allow you to read HDFS directories and files that aren't world readable.  Nothing fancy here, you could edit the URL yourself, this just makes it easier.  The script is hosted here: http://userscripts.org/scripts/show/179132, and the source is available here: https://gist.github.com/keeganwitt/6810986.

Tuesday, May 15, 2012

A Mercurial Userscript

I've got a minor complaint against the Mercurial web interface, and that is that when you are browsing around using the tip version, links will point to the nodeid tip points to rather than keeping the URLs with the relative tip version.  I think the way it should work is that you stay on the tip, unless you are click into a revision log (so that you can click specific revisions).  This is especially nice for sharing a link to the latest with someone, you would want to keep that link relative.
For the most part, I don't really care what Mercurial does, but since I do use their web interface because it's the SCM of choice for the OpenJDK project, I thought I'd whip up a userscript to remedy the situation.  Check out the script here, then test its effects by browsing the latest JDK sources:
http://hg.openjdk.java.net/jdk6/jdk6-gate/jdk/file/tip/src/share/classes/
http://hg.openjdk.java.net/jdk7/jdk7-gate/jdk/file/tip/src/share/classes/

Let me know if you have any problems or suggestions for improvement.

Thursday, September 1, 2011

A userscript for Viewvc

I've posted a userscript I've written as a workaround for a request for ViewVC that hasn't been done yet (despite the fact a patch has already been submitted).  The missing feature is a link to the log view for directories.