String split 1 million line string from Heroku log file:
- Elixir 166s
- Clojure 8s
- Ruby 1s
- Python 0.5s
| #!/usr/bin/env node | |
| // This script uploads a local file to S3 | |
| // Depends on the aws4 npm package for AWS signatures | |
| // Usage: | |
| // AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... s3-upload | |
| const fs = require('fs') | |
| const https = require('https') | |
| const aws4 = require('aws4') // Handles complex AWS signatures: http://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html |
| ################################################################ | |
| # config/initializers/handlebars.rb: | |
| ################################################################ | |
| template_path = File.join(Rails.root.to_s, 'app/views') | |
| helpers = { | |
| t: lambda do |context, key| | |
| I18n.t(key) | |
| end, | |
| path: lambda do |context, path_name| |
| (require '[schema.core :as s]) | |
| (def StrOrKeyword (s/cond-pre s/Str s/Keyword)) | |
| (declare Schema) | |
| (declare SchemaValue) | |
| (def SchemaMap {s/Keyword (s/recursive #'SchemaValue)}) | |
| (def SchemaArray [(s/recursive #'SchemaValue)]) | |
| (def SchemaValue (s/cond-pre s/Str s/Num Nil s/Bool SchemaMap SchemaArray)) | |
| (def SchemaType (s/enum "string" "number" "integer" "null" "boolean" "array" "object")) |
| (ns versioned.crud-api-attributes | |
| (:require [versioned.model-support :as model-support] | |
| [versioned.model-spec :as model-spec :refer [Model]] | |
| [versioned.json-api :as json-api] | |
| [versioned.model-attributes :refer [api-writable-attributes api-readable-attributes]] | |
| [versioned.crud-api-audit :refer [updated-by created-by save-changelog]] | |
| [versioned.crud-api-types :refer [coerce-attribute-types]] | |
| [clojure.spec :as s] | |
| [schema.core :as schema])) |
We are using the Builder pattern here. Notice how each field is duplicated about five times and how we need to implement equals and hashCode manually (left as an exercise for the reader):
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonDeserialize(builder = User.Builder.class)Java:
public Optional<String> getType() {
return this.types.isEmpty() ?
Optional.empty() :
Optional.of(String.join(",", (Iterable)this.types.stream().map(Enum::name).collect(Collectors.toList())));
}| 'use strict'; | |
| // NOTE: this in memory locking approach will only work with a single process | |
| // You might use something like Redis och memcachached for storing the lock if you need to lock | |
| // across several processes. | |
| var synchronizedFunction = function(lockIdFn, fn) { | |
| var locks = {}; | |
| var synchronized = function() { | |
| var args = Array.prototype.slice.call(arguments), | |
| lockId = lockIdFn.apply(null, args); |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; BASE CLASS | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; public class ContentItem { | |
| ; public String foobar() { | |
| ; return "content_item"; | |
| ; } | |
| ; } |
| 'use strict'; | |
| var R = require('ramda'); | |
| var CATEGORIES = [ | |
| {category_type: 'cuisine', id: 1, name: 'French', type: 'categroy'}, | |
| {category_type: 'diets', id: 2, name: 'Vegetarian', type: 'category'} | |
| ]; | |
| var children = { |