Skip to content

Instantly share code, notes, and snippets.

@Storm-BE
Storm-BE / ArgumentValidation.cs
Created July 7, 2017 06:16
ArgumentValidation
using System;
using JetBrains.Annotations;
namespace Helpers
{
public static class ArgumentValidation
{
public static void ThrowIfNull<T>([ValidatedNotNull] [NoEnumeration] T argument)
where T : class
{
// To install as a global sbt plugin, place this file in:
// ~/.sbt/1.0/plugins/Semanticdb.scala
// ~/.sbt/0.13/plugins/Semanticdb.scala
// To use it, run `sbt semanticdb`. This will first enable the semanticdb
// compiler plugin for modules that have a compatible scala version and then
// trigger compilation for those projects.
import sbt._
import sbt.Keys._
import sbt.plugins.JvmPlugin
@oowekyala
oowekyala / README.md
Last active August 6, 2019 13:05
GSoC 2017 report -- Bringing Object-Oriented Metrics to PMD
@owainlewis
owainlewis / .gitignore
Created June 27, 2014 07:36
Scala gitignore
*.class
*.log
# sbt specific
.cache/
.history/
.lib/
dist/*
target/
lib_managed/
package util
object Slug {
def apply(input:String) = slugify(input)
def slugify(input: String): String = {
import java.text.Normalizer
Normalizer.normalize(input, Normalizer.Form.NFD)
.replaceAll("[^\\w\\s-]", "") // Remove all non-word, non-space or non-dash characters
.replace('-', ' ') // Replace dashes with spaces
@joshuashaffer
joshuashaffer / pointTriangleDistance.py
Created July 1, 2015 22:28
Computes the distance between a point an triangle. Python.
#!/usr/bin/env python
#
# Tests distance between point and triangle in 3D. Aligns and uses 2D technique.
#
# Was originally some code on mathworks
import numpy
from numpy import dot
from math import sqrt
@liabru
liabru / json-limit-precision.js
Last active May 3, 2023 07:45
Limit precision of floating point numbers in a JSON string in JavaScript
var testObject = {
pi: Math.PI,
e: Math.E,
one: 1,
x: 1.5,
str: "1.2345"
};
var places = 2,
json = JSON.stringify(testObject, function(key, value) {
@willianbs
willianbs / simple-docker-apache-php
Created August 26, 2019 17:18
Simple Docker Apache+PHP local dev in the current dir
docker run -d -p 8082:80 --mount type=bind,source="$(pwd)",target=/var/www/html php:apache
// That's it! If you try this, and it works for you, you're done!
// The command does the following:
// If the Docker image php:apache is not present in your machine's local Docker registry, it will be downloaded from Docker hub.
// It creates a new container based on the image php:apache.
// It maps port 80 from the container to port 8082 on your host machine.
// It mounts the current directory from your host machine to /var/www/html in the container.
@mucar
mucar / random_color_array.js
Created October 16, 2012 11:47
Javascript Random Color Array
var colorArray = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99', '#00B3E6',
'#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D',
'#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A',
'#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC',
'#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC',
'#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399',
'#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680',
'#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933',
'#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3',
'#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF'];
@shawndumas
shawndumas / .gitconfig
Created August 5, 2013 19:08
Using WinMerge as the git Diff/Merge Tool on Windows 64bit
[mergetool]
prompt = false
keepBackup = false
keepTemporaries = false
[merge]
tool = winmerge
[mergetool "winmerge"]
name = WinMerge