Skip to content

Instantly share code, notes, and snippets.

{-# LANG BangPatterns #-}
-- module SillyMapBench (main) where
import qualified Data.Map.Strict as Map
loopCount = 1000000
-- loopCount = 10
texts = [ "The", "quick", "brown", "fox", "jumped",
"over", "the", "lazy", "dog", "at", "a", "restaurant",
@RedFred7
RedFred7 / FizzBuzz.rb
Created May 7, 2015 21:58
3 approaches to solving FizzBuzz
require 'benchmark'
# using simple conditional statements
def conditional(n)
if (n % 3 == 0) && (n % 5 != 0)
'Fizz'
elsif (n % 3 != 0) && (n % 5 == 0)
'Buzz'
elsif (n % 3 == 0) && (n % 5 == 0)
'FizzBuzz'
@RedFred7
RedFred7 / Memoization.rb
Created May 9, 2015 10:53
recursive memoization with hashes
require 'benchmark'
def factorial(x)
x == 1 ? 1 : x * factorial(x-1)
end
factorial_hash ||= Hash.new do |hash,key|
key == 1 ? (key = 1) : (hash[key] = key * hash[key-1])
end
@karlhorky
karlhorky / vagrant-port-forwarding.md
Last active November 16, 2017 19:24 — forked from altryne/vagrant-port-forwarding.md
Vagrant Port Forwarding on OS X Yosemite

Vagrant Port Forwarding (8080 -> 80, 8443 -> 443) with pf on OSX Mavericks/Yosemite

This guide is a fork from this gist.

Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

1. Create the anchor file

Create an anchor file under /etc/pf.anchors/com.vagrant with your redirection rule like:

rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
@makella
makella / readme.md
Last active December 6, 2019 07:51
Spin the color wheel!!

Spin the color wheel!

Inside of CARTO Builder we offer a set of default color schemes, CARTOColors, that can be used for both qualitative and quantitative data.

But what about the times when you want to customize the colors on your map, because of its theme, a predefined brand color, or just because? There are a variety of tools and guidelines available to find harmonious color combinations that can be brought into Builder to customize your map.

Another option to get started, that we outline here, is using the CartoCSS color function spin to get started with custom color schemes, particularly for qualitative data.

With the basic building blocks in place, this function can be used in a variety of ways on many different maps. To demonstrate, we'll generate a series of well-known [color harmonies](https://en.wikipedia.org/wiki/Harmony_(co

@clyfish
clyfish / solarized-dark.xcs
Created December 21, 2011 07:06
xshell solarized dark color theme
[Solarized Dark]
text(bold)=839496
magenta(bold)=6c71c4
text=839496
white(bold)=fdf6e3
green=859900
red(bold)=cb4b16
green(bold)=586e75
black(bold)=073642
red=dc322f
// see build.gradle for imports
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;
...
public abstract class Utilities {
public static final Logger logger = LoggerFactory.getLogger( "AnyUniqueStringHere" );
...
public static void printLoggerState() {
@outbounder
outbounder / ClientHelper.java
Created July 7, 2011 13:08
jersey client helper for trusting all certificates in SSL/TLS
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@bantic
bantic / rails_route_recognizer.rb
Last active September 9, 2022 12:22
Programmatically list all routes (/paths) from within a rails app.
class RouteRecognizer
attr_reader :paths
# To use this inside your app, call:
# `RouteRecognizer.new.initial_path_segments`
# This returns an array, e.g.: ['assets','blog','team','faq','users']
INITIAL_SEGMENT_REGEX = %r{^\/([^\/\(:]+)}
def initialize