Skip to content

Instantly share code, notes, and snippets.

@chanshuikay
chanshuikay / patchjar.groovy
Last active July 19, 2022 10:54
Modified version of D's patchjar.groovy live plugin that uses Favourites Lists for classes to include in patch jar instead of changelists
import com.intellij.ide.bookmark.Bookmark
import com.intellij.ide.bookmark.FileBookmark
import com.intellij.ide.bookmark.BookmarkGroup
import com.intellij.ide.bookmark.BookmarksManager
import com.intellij.ide.favoritesTreeView.FavoritesManager
import com.intellij.ide.projectView.impl.AbstractUrl
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.CompilerModuleExtension
@dkandalov
dkandalov / d3js.md
Last active March 9, 2016 18:35
Interesting d3js blocks
@gregsh
gregsh / - IDE Scripting.md
Last active March 13, 2024 03:29
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
@mattbierner
mattbierner / life_comonadic.cpp
Created November 3, 2014 00:25
c++ Compile Time Comonaic Life
/**
* Conway's game of life implemented in C++ templates at compile time using Comonads.
*
* Logic based on: http://blog.emillon.org/posts/2012-10-18-comonadic-life.html
*/
#include <iostream>
/// Identity functor
template <typename X>
struct id {
(?s)^((?!my text).)*$
^((?!my text).)+$ <-- won't match empty lines
^((?!my text).)*$ <-- this doesn't work :(
@cholick
cholick / build.gradle
Last active October 24, 2018 21:08
Using Gradle & jarjar to repackage and embed incompatible transitive dependencies
apply plugin: 'groovy'
repositories {
mavenCentral()
}
configurations {
patch
[compile, testCompile]*.exclude module: 'jersey-server'
}
@3noch
3noch / Either.h
Last active July 9, 2020 15:27
An implementation of Haskell's "Either" type C++
#pragma once
#include <boost/optional.hpp>
/**
* Wraps any value with a context of Left for the Either class.
*
* By convention, Left represents some sort of less-desired condition.
*/
@dkandalov
dkandalov / gist:5066611
Last active December 14, 2015 09:39
simple d3 script for displaying timebased events from csv
var csv = ""; // paste csv into this string
var margin = {top: 20, right: 20, bottom: 30, left: 50},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var parseFormat = d3.time.format("%H:%M:%S");
var displayFormat = d3.time.format("%H:%M");
var x = d3.time.scale().range([0, width]);
@dkandalov
dkandalov / 12 years of "TODO"
Last active December 13, 2015 23:59
Beautiful code best practice enterprise patterns
/**
* Insert the method's description here.
* Creation date: (4/16/01 3:47:01 PM)
* @param newHierarchy com.xxxx.xxxxxxxx.reporting.xxxxx.api.datasource.Hierarchy
*/
public void setHierarchy(com.xxxx.xxxxxxxx.reporting.xxxxx.api.datasource.Hierarchy newHierarchy) {
@dkandalov
dkandalov / gist:4761632
Created February 12, 2013 11:13
AnalysisUtil
class AnalysisUtil {
static def aggregateByDuration = { events -> events.sum(0) { it.duration } }
static def aggregateByQueryDuration = { events -> events.sum(0) { it.queryDuration } }
static def aggregateByAmount = { events -> events.size() }
static def histogramOf(Closure criteria, amountOfIntervals, List lines) {
double maxValue = criteria(lines.max(criteria))
double minValue = criteria(lines.min(criteria))
double intervalSize = (maxValue - minValue) / amountOfIntervals