Skip to content

Instantly share code, notes, and snippets.

View bahmanm's full-sized avatar

Bahman Movaqar bahmanm

View GitHub Profile
@bahmanm
bahmanm / shapeofthedate.groovy
Last active November 17, 2017 20:58
Convert dates to alien looking plots using partial sums - https://github.com/bahmanm/datedreamer
//
// This has evolved into a fully-fledged project called DateDreamer.
// Please check the project's page for releases and more information.
// https://github.com/bahmanm/datedreamer
//
@Grab(group='com.github.yannrichet', module='JMathPlot', version='1.0.1')
@Grab(group='org.apache.commons', module='commons-math3', version='3.6.1')
import static java.lang.Math.*
import org.apache.commons.math3.complex.Complex
@bahmanm
bahmanm / gradle-init.sh
Last active January 30, 2019 09:00
Groovy and Spock (with Gradle)
#!/usr/bin/env bash
###
# Initialises a Gradle project with Groovy and Spock.
#
# How To Use?
#
# 1. Save the file, e.g. `gradle-init.sh`
# 2. Make it executable: `$ chmod +x gradle-init.sh`
# 3. Initialise the project: `$ ./gradle-init.sh YOUR_PROJECT_NAME`
@bahmanm
bahmanm / my-custom-config-loader.el
Created June 15, 2023 20:39
eLisp: Save and parse JSON
;; to save an object into a json file
(with-temp-buffer
(json-insert '(:foo "bar"))
(write-file "~/tmp/my.json"))
;; load a json file as hash table
(with-temp-buffer
(insert-file-contents "~/tmp/my.json")
(json-parse-buffer))
@bahmanm
bahmanm / simple-atoi.java
Created June 20, 2023 23:30
Nested or sequential try-catch blocks?
/**
* Using nested try-catch blocks.
*
* @param str a string representing an integer
* @return smallest integer type or null
*/
Number atoi_NestedTryCatch(String str) {
try {
return Integer.valueOf(str);
} catch (NumberFormatException ignore1) {