Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;dimensions of square world |
/* Sample JavaScript file added with ScriptTag resource. | |
This sample file is meant to teach best practices. | |
Your app will load jQuery if it's not defined. | |
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7. | |
Your app does not change the definition of $ or jQuery outside the app. | |
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2' | |
once the app is installed, even if the app uses jQuery 1.9.1: | |
jQuery.fn.jquery => "1.4.2" | |
$.fn.jquery -> "1.4.2" | |
*/ |
(require '[clojure.core.async :as async refer [<! go timeout]) | |
(defn sleepy-val | |
[v t] | |
(go (<! (timeout t)) v)) | |
;; Will this produce [1 2 3 1.5 2.5 3.5] or [1 1.5 2 2.5 3 3.5]? | |
(go | |
(prn (<! (async/into [] | |
(async/merge [(.async/merge [(sleepy-val 1 1000) |
#!/bin/bash | |
# Thanks to https://gist.github.com/wenzhixin/43cf3ce909c24948c6e7 | |
# Execute this script in your home directory. Lines 17 and 21 will prompt you for a y/n | |
# Install Oracle JDK 8 | |
add-apt-repository ppa:webupd8team/java | |
apt-get update | |
apt-get install -y oracle-java8-installer | |
apt-get install -y unzip make # NDK stuff |
#!/usr/bin/env bash | |
# Example: | |
# ./find-ecr-image.sh foo/bar mytag | |
if [[ $# -lt 2 ]]; then | |
echo "Usage: $( basename $0 ) <repository-name> <image-tag>" | |
exit 1 | |
fi | |
IMAGE_META="$( aws ecr describe-images --repository-name=$1 --image-ids=imageTag=$2 2> /dev/null )" |
As with any place, there are a few pros and a number of cons. Most of my experiences are derived from living and working in the country. A bird’s eye view if you like.
At a high level, to continue with the bird theme, Croatia has an attractive climate with four distinct seasons. There is a proper coast line with plenty to choose from in terms of places to go and hang out during the summer. It’s countryside quite beautiful. The country’s infrastructure generally works due almost entirely to EU largesse. Commercially there is a reasonably educated work force that is sadly bereft of opportunity. Relationships with Croats is generally transactional and individual success is punished.
Taxation rate is a whopping 61% with employers having to add an additional 17%. The effective impact of this means, with the best part of 80% going to income based taxation, there is a thriving cash or black market system and it functions as a massive disincentive for local companies to
#/bin/bash | |
# kill dev server | |
lsof -i :8081 | awk 'NR!=1 {print $2}' | xargs kill | |
# In gnome-terminal, go to Edit -> Profile Preferences -> Title. Click the Command tab. Select Hold the terminal from the drop-down menu labelled When command exits. Name the profile hold-terminal | |
echo "Starting Android Emulator" | |
AVD_NAME=$1 |
remove the nth element from a list
Clojure's two main sequences, lists and vectors, do not easily let you remove an item from the collection when that item is in the middle of the sequence. Sometimes we need to do that. Write a function remove-at that removes the element at position n from a sequence.
(remove-at 3 [1 2 3 4 5 6])
; => (1 2 3 5 6)
Make this robust. You'll have to make some hard design decisions like how to handle the empty sequence, how to handle out-of-bounds n, and more.