Skip to content

Instantly share code, notes, and snippets.

@jewelsea
jewelsea / DynamicallyColoredBarChartWithLabel.java
Last active January 26, 2024 14:54
Colors the the bars in a JavaFX BarChart depending upon the value of each bar's data.
import javafx.application.Application;
import javafx.beans.value.*;
import javafx.geometry.Bounds;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.chart.*;
import javafx.scene.control.Label;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
@jewelsea
jewelsea / PieChartWithCustomColors.java
Created March 5, 2013 22:59
Set a custom color sequence for a JavaFX pie chart.
import javafx.application.Application;
import javafx.collections.*;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.chart.*;
public class PieChartWithCustomColors extends Application {
@Override public void start(Stage stage) {
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
new PieChart.Data("Grapefruit", 13),
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>fxxk_it_alert</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>/Users/ozaki/bin/fxxk_it_alert.scpt</string>
@jewelsea
jewelsea / PopupButton.java
Last active October 31, 2016 16:05
Shows how to make a small context sensitive dialog which popups on pressing a button.
import java.util.Random;
import javafx.application.Application;
import javafx.event.*;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
@takawitter
takawitter / ScalaJSR223Test.java
Last active March 12, 2021 10:38
The sample code to run scala via JSR223 API. I turn usejavacp option true at line 10. Unless that you have to use http://github.com/rjolly/jarlister to list classes in scala-library.jar into MANIFEST.MF of jar that contains this ScalaTest class. I use Scala-2.11.6 to run this code.
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import scala.tools.nsc.interpreter.IMain;
import scala.tools.nsc.settings.MutableSettings.BooleanSetting;
public class ScalaTest {
public static void main(String[] args) throws Exception{
ScriptEngine engine = new ScriptEngineManager().getEngineByName("scala");
((BooleanSetting)(((IMain)engine).settings().usejavacp())).value_$eq(true);
@takawitter
takawitter / gist:5895868
Last active December 19, 2015 04:18
ThreadPoolExecutorに値を返すlambda(or closure)をsubmitしたい。submit(Callable<T> task)が呼ばれればOKなんだけど、ThreadPoolExecutorにはsubmit(Runnable task)も存在するので、普通にlambdaを渡すと曖昧性が解消できない。そのためCallable<T>を明示する必要があるが、その方法が言語によって違うって話。 ScalaとJythonとJRubyは直接やる方法が無さそうなので、ラッパークラスをかましてる。
/*
* tp は Executors.newCachedThreadPool 等を使って生成
*/
// Rhino(JavaScript)
tp.submit(new Callable({call: function(){ return 1;}}));
// Groovy
tp.submit({1} as Callable)
@keijiro
keijiro / ScreenRecorder.cs
Last active January 26, 2022 05:01
Screen recording utility.
using UnityEngine;
using System.Collections;
public class ScreenRecorder : MonoBehaviour
{
public int framerate = 30;
public int superSize;
public bool autoRecord;
int frameCount;
@bsommardahl
bsommardahl / gist:8605208
Last active January 17, 2024 15:42
RTD Client in C#
public interface IRtdClient
{
object GetValue(params object[] args);
}
public class RtdClient : IRtdClient
{
readonly string _rtdProgId;
static IRtdServer _rtdServer;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
//Interfaces for working with excel
//this file allows me to not have a reference to excel in the project
//Adding a reference is to a specific version, these interfaces apply to all
//see Kenny Ker's blog http://weblogs.asp.net/kennykerr/archive/2008/12/16/Rtd7.aspx
import java.util.Random;
import sun.misc.Unsafe;
import sun.nio.ch.DirectBuffer;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;