Skip to content

Instantly share code, notes, and snippets.

View melastmohican's full-sized avatar

Mariusz Jurgielewicz melastmohican

View GitHub Profile
@melastmohican
melastmohican / del_parent_child.sql
Created September 13, 2017 20:48
Delete parent and child in one statement (Oracle)
delete from
(
select * from parent join child using (id)
where id = 9999
);
@melastmohican
melastmohican / ElapsedTime.groovy
Last active September 1, 2017 22:02
Elapsed time in groovy
import groovy.time.TimeCategory
import groovy.time.TimeDuration
Date start = new Date()
// do something here
Date stop = new Date()
TimeDuration td = TimeCategory.minus( stop, start )
println td
@melastmohican
melastmohican / benchmark.groovy
Created August 10, 2017 03:05
Measure execution time with a closure
def benchmark = { closure ->
start = System.currentTimeMillis()
closure.call()
now = System.currentTimeMillis()
now - start
}
@melastmohican
melastmohican / RussianRoulette.sh
Created July 20, 2017 02:40
Command line Russian roulette
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo *Click*
@melastmohican
melastmohican / create_gradle_properties.sh
Created May 26, 2017 22:05
Create gradle.properties
echo 'org.gradle.daemon=true' >> ~/.gradle/gradle.properties
echo 'org.gradle.configureondemand=true' >> ~/.gradle/gradle.properties
echo 'org.gradle.parallel=true' >> ~/.gradle/gradle.properties
echo 'org.gradle.jvmargs=-Xmx4G -XX:MaxPermSize=4G -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8' >> ~/.gradle/gradle.properties
@melastmohican
melastmohican / md2docx.sh
Created May 24, 2017 23:39
Markdown to DOCX
pandoc -o output.docx -f markdown -t docx README.md
@melastmohican
melastmohican / dumpCSVH2.groovy
Created May 18, 2017 06:27
Dump CSV using H2 CSV tools
#!/usr/bin/env groovy
@Grapes([
@Grab(group = 'com.h2database', module = 'h2', version = '1.4.194'),
@GrabConfig(systemClassLoader=true)
])
import java.sql.*;
import org.h2.tools.Csv;
@melastmohican
melastmohican / fix_macossierra_git.sh
Last active April 28, 2017 21:46
After upgrading to macOS Sierra, I tried to run git from Terminal but it kept giving me the following error: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun.
xcode-select --install
@melastmohican
melastmohican / pandoc_html_md.sh
Created April 24, 2017 21:41
Convert HTML page to Markdown with pandoc
pandoc T20.html -o T20.md
@melastmohican
melastmohican / setHostname.sh
Created April 22, 2017 06:02
macOS set hostname
sudo scutil --set ComputerName "newname"
sudo scutil --set LocalHostName "newname"
sudo scutil --set HostName "newname"