Skip to content

Instantly share code, notes, and snippets.

@weberste
weberste / Perf Calc.carbide.md
Last active December 21, 2016 06:19
Perf Calc

Perf Calc

@weberste
weberste / gist:be32c7301576259e9f96
Last active August 29, 2015 14:01
Spinning wheel on button click
app.directive('clickSpinner', ['$q', function ($q) {
var spinnerId = 1;
var directive = {
restrict: 'A',
link: link,
transclude: true,
scope: {
clickHandler: '&clickSpinner'
},
@weberste
weberste / gist:354a3f0a9ea58e0ea0de
Last active January 28, 2022 13:47
Dates only with Angular-UI Bootstrap datepicker
app.directive('datepickerLocaldate', ['$parse', function ($parse) {
var directive = {
restrict: 'A',
require: ['ngModel'],
link: link
};
return directive;
function link(scope, element, attr, ctrls) {
var ngModelController = ctrls[0];
@weberste
weberste / gist:827705
Created February 15, 2011 16:05
Unzip source JARs to simplify browsing in text editors.
trait SourceExtractor {
self: BasicScalaProject =>
def srcManagedDir = info.projectPath / "src_managed"
def scalaPaths = info.projectPath / "project" / "boot" / ("scala-" + crossScalaVersionString) ** "*-src.jar"
def libPaths = (managedDependencyPath ** "*-sources.jar")
lazy val sources = sourcesAction
def sourcesAction = task {
@weberste
weberste / gist:764797
Created January 4, 2011 14:09
SBT task to create a distributable zip file
trait DistributableProject extends BasicScalaProject with MavenStyleScalaPaths {
// staging is currently done to make ensure the paths of the files within the resulting zip end up in the correct directory structure
def stagingDir = (outputPath ##) / (normalizedName + "-" + version)
def distributionZipName = normalizedName + "-dist-" + version + ".zip"
def distributionOutputPath = outputPath / distributionZipName
def libTargetDirectoryName = "lib"
@weberste
weberste / ReverseSubstring.scala
Created October 26, 2010 14:43
Find the longest substring (within a given string) that is the same in reverse.
object ReverseSubstring {
/**
* Find the longest substring (within a given string) that is the same in reverse.
* Example: "I like bananas but not cucumbers." should return "anana".
*/
def main(args: Array[String]) {
val biggestSubstring = findBiggestReverseSubstring(args(0))
println("biggest substring is '%s'".format(biggestSubstring))
}