Skip to content

Instantly share code, notes, and snippets.

@gregsh
gregsh / - IDE Scripting.md
Last active May 20, 2024 02:43
IDE Scripting

Here are my attempts to script an IntelliJ-based IDE using javax.script.* API (ex-JSR-223).

The list of available scripting languages and engines:

  1. Groovy - built-in, via Groovy jars and <app>/lib/groovy-jsr223-xxx.jar
  2. JavaScript (Nashorn) - built-in, via Java Runtime <app>/jbr/... (deprecated and will be removed soon)
  3. JavaScript (GraalJS) - https://plugins.jetbrains.com/plugin/12548-intellij-scripting-javascript
  4. JPython - https://plugins.jetbrains.com/plugin/12471-intellij-scripting-python
  5. JRuby - https://plugins.jetbrains.com/plugin/12549-intellij-scripting-ruby
  6. Clojure - https://plugins.jetbrains.com/plugin/12469-intellij-scripting-clojure
@staltz
staltz / introrx.md
Last active June 6, 2024 03:19
The introduction to Reactive Programming you've been missing
@nk9
nk9 / largestFiles.py
Last active November 14, 2023 09:47
Python script to find the largest files in a git repository.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Python script to find the largest files in a git repository.
# The general method is based on the script in this blog post:
# http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
#
# The above script worked for me, but was very slow on my 11GB repository. This version has a bunch
# of changes to speed things up to a more reasonable time. It takes less than a minute on repos with 250K objects.
#
@melix
melix / README.adoc
Last active July 7, 2021 07:37
An automated solver for 2048

Automated solver for 2048

This is a script which runs a "bot" that tries to solve the incredibly addictive 2048 game. It makes use of Groovy and browser automation with Geb.

How to

  • First step, if you don’t have it, you need to install Groovy.

  • Second step is to install the Google Chrome WebDriver (just unzip the appropriate file to a local directory)

  • Next, edit the script to set the path to the Chrome Driver

  • then execute the script: groovy solver2048.groovy

package github.gist.testfx
import javafx.scene.Parent
import org.loadui.testfx.GuiTest
import spock.lang.Specification
abstract class GuiSpecification extends Specification {
GuiTest fx
@timyates
timyates / hexdump.groovy
Last active December 30, 2015 00:19
Hexdump byte[] in Groovy via the metaClass
byte[].metaClass.hexdump { int idx, int len ->
println ''' +--------------------------------------------------+
| | 0 1 2 3 4 5 6 7 8 9 a b c d e f |
| +----------+--------------------------------------------------+------------------+'''.stripMargin()
delegate[ idx..<(idx+len) ].with { bfr ->
def bytes = bfr.collect { String.format( '%02x', it ) }
.collate( 8 )
.collate( 2 )
.collect { a, b -> ( a + [ '' ] + b ).join( ' ' ).padRight( 48, ' ' ) }
def ascii = bfr.collect { it > 0x1f && it < 0x7f ? (char)it : '.' }
@mbostock
mbostock / .block
Last active December 17, 2023 21:17
Save SVG as PNG
license: gpl-3.0
@elsherbini
elsherbini / data.js
Last active December 18, 2015 16:58
Attempting to extend dc.js with a simpleLineChart
var dummyData = [
["2013/05/20","00:00","322.2","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:05","322.2","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:10","322.1","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:15","322.1","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:20","321.8","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:25","322.1","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:30","322.1","35.4","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:35","322.1","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
["2013/05/20","00:40","322.1","35.3","21.4","67","East","6","0","63","87%","30.05","+","0.00","1.40"],
@willurd
willurd / web-servers.md
Last active June 7, 2024 03:53
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@Jpunt
Jpunt / drobo_check.py
Created May 7, 2013 06:57
Python script I use to check the health of my Drobo, which is connected to a Raspberry Pi. Output is emailed by the cronjob daily. Needs Drobo-Utils to work properly: http://drobo-utils.sourceforge.net and you will have to edit the paths for your setup.
#! /usr/bin/env python
import subprocess
import re
# Settings
diskPath = '/dev/sda'
mountPath = '/media/drobo'
# Get status
command = "/usr/sbin/drobom status"