Skip to content

Instantly share code, notes, and snippets.

View jumar's full-sized avatar

jumar jumar

  • Montreal, Canada
View GitHub Profile
@jumar
jumar / gist:6381012
Created August 29, 2013 17:31
Strip file name from its extension. This expression will remove the last dot followed by one or more characters.
String fileNameWithOutExt = "test.xml".replaceFirst("[.][^.]+$", "");
@jumar
jumar / gist:9200840
Last active July 14, 2024 02:42
Send magic wol packet java
import java.io.*;
import java.net.*;
public class WakeOnLan {
public static final int PORT = 9;
public static void main(String[] args) {
if (args.length != 2) {
@jumar
jumar / gist:9754602
Created March 25, 2014 03:14
Write string to file: one liner
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class StringToFile {
public static void main(String[] args) throws IOException {
String msg = "hello";
Files.write(Paths.get("./duke.txt"), msg.getBytes());
}
}
@jumar
jumar / virtualKeyboard.java
Created August 14, 2014 20:29
Launch WIndows 8 touch keyboard from java
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "\"C:\\Program Files\\Common Files\\microsoft shared\\ink\\TabTip.exe");
builder.redirectErrorStream(true);
Process p;
try
{
p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true)
{
import javafx.animation.FadeTransition;
import javafx.application.Application;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.concurrent.Worker;
import javafx.event.ActionEvent;
import javafx.animation.*;
import javafx.application.Application;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.*;
import javafx.concurrent.*;
import javafx.event.*;
import javafx.geometry.*;
import javafx.scene.Scene;
import java.io.*;
import java.net.URL;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import javafx.application.Application;
import javafx.beans.property.*;
import javafx.concurrent.*;
import javafx.event.EventHandler;
import javafx.scene.*;
import javafx.scene.control.*;
@jumar
jumar / parallelStreamPool.java
Created January 21, 2015 01:29
Parellel strem on dedicated thread pool
ForkJoinPool forkJoinPool = new ForkJoinPool(2);
forkJoinPool.submit(() ->
range(1, 1_000_000).parallel().filter(PrimesPrint::isPrime)
.collect(toList())
).get();
//
// GifSequenceWriter.java
//
// Created by Elliot Kroo on 2009-04-25.
//
// This work is licensed under the Creative Commons Attribution 3.0 Unported
// License. To view a copy of this license, visit
// http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative
// Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
{"version":1,"notes":"","documentation":"\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n","keyboard":"crkbd/rev1","keymap":"crkbd_rev1_layout_mine","layout":"LAYOUT","layers":[["KC_TAB","KC_Q","KC_W","KC_E","KC_R","KC_T","KC_Y","KC_U","KC_I","KC_O","KC_P","KC_BSPC","KC_LSFT","LT(2,KC_A)","LSFT_T(KC_S)","LT(3,KC_D)","LCTL_T(KC_F)","KC_G","KC_H","RCTL_T(KC_J)","LT(5,KC_K)","RSFT_T(KC_L)","KC_SCLN","KC_QUOT","KC_LCTL","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_N","KC_M","KC_COMM","KC_DOT","KC_SLSH","KC_BSLS","KC_LGUI","KC_LALT","KC_SPC","KC_ENT","LT(1,KC_DEL)","LT(4,KC_APP)"],["KC_ESC","KC_EXLM","KC_EQL","KC_LPRN","KC_RPRN","KC_PIPE","KC_UNDS","KC_P7","KC_P8","KC_P9","KC_PPLS",