View Groovy executors and callables.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def messageTo = { num -> | |
println(Thread.currentThread().name + " --> A message for you number $num") | |
} | |
def pool = Executors.newFixedThreadPool(10) | |
(1..1000).each { num -> | |
pool.submit({ messageTo(num) }) | |
} | |
pool.awaitTermination(60, TimeUnit.SECONDS) |
View RunnableClosure.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Every closure in groovy is executable, and technically, implements the "Callable" interface | |
def a = { println "hello!"} | |
a() | |
// --> hello | |
a.call() | |
// --> hello |
View FishClassWithGetSet.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fish { | |
private var myName = "Default" | |
def name = myName | |
def name_= (newName: String) = myName = newName | |
} |
View FishWithJavaGetSet.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fish { | |
private var name = "Default" | |
def getName = name | |
def setName(newName: String) = name = newName | |
} |
View FishScopeDemo.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fish (var fishName: String){ | |
private var myName = fishName | |
def name = myName | |
def name_= (newName: String) = myName = newName | |
def sayHello(otherFish : Fish) = println ("hello, " + otherFish.myName) | |
} |
View robbyrussell.zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" | |
PROMPT='$fg[white]%* %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)${ret_status}%{$fg_bold[blue]%} % %{$reset_color%}' | |
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" |
View slugline_shortner.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var filePath = process.argv[2]; | |
var content = null; | |
fs.readFile(filePath, 'utf8', function (err, data) { | |
if (err) { | |
console.log('Error: ' + err); | |
return; | |
} |
View ssh-tunneling-via-dmz.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias ssh-tunnel='function _ssh_tunnel(){ set -x; port=$(gshuf -i 39152-65530 -n 1); ssh -f -N -L$port:$1:22 ec2-user@<DMZ_IP> -i ~/.ssh/dmz.pem ; ssh -i ~/.ssh/prod.pem ec2-user@127.0.0.1 -p $port ;};_ssh_tunnel' | |
# to run: | |
ssh-tunnel <SOME PROD IP> |
View S3 move file.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aws = require('aws-sdk'); | |
const s3 = new aws.S3({apiVersion: '2006-03-01'}); | |
const LambdaLog = require('lambda-log').LambdaLog; | |
const log = new LambdaLog({meta: {environment: process.env.ENVIRONMENT}}); | |
async function deleteObject(bucket, currentPath) { | |
var params = { |
View jackson-serde-config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class AppConfig { | |
private static final String dateFormat = "yyyy-MM-dd"; | |
private static final String dateTimeFormat = "yyyy-MM-dd HH:mm:ss"; | |
@Bean | |
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() { | |
return builder -> { | |
builder.serializers(new LocalDateTimeSerializer( |
OlderNewer