This file contains hidden or 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
// Current way in Groovy | |
@Immutable | |
class Person { | |
String firstName, lastName | |
int age | |
Date dateCreated | |
} | |
// But: This would be nice | |
data class Person(String name, String lastName, int age, Date dateCreated) |
This file contains hidden or 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
allprojects { | |
tasks.withType(AbstractArchiveTask) { task -> | |
outputs.upToDateWhen { false } | |
task.doLast { | |
println "\nOutput location: ${archiveName}\n" | |
} | |
} | |
} |
This file contains hidden or 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 artifacts = [] | |
addListener(new TaskExecutionAdapter() { | |
void afterExecute(Task task, TaskState state) { | |
if(task in AbstractArchiveTask) { | |
artifacts << task.outputs.files.singleFile | |
} | |
} | |
}) |
This file contains hidden or 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
// querying and cursors | |
cursor = db.people.find(); null ; | |
cursor.hasNext() // returns true (if there is another set of results) and false (if not) | |
cursor.next() // returns the next result and move the cursor foward | |
// Limiting the set of results returned by the queries | |
cursor.limit(5); null; // limit the results returned by the cursor (default is 20) | |
// note: the 'null' keyword is used to prevent the mongoshell from printing that query out |
This file contains hidden or 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
#!/bin/bash | |
txt_green=$(tput setaf 2) | |
txt_purple=$(tput setaf 5) | |
txt_reset=$(tput sgr0) | |
for i in */ | |
do | |
cd $i | |
git_branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1'/` |
This file contains hidden or 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
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/' | |
} | |
function proml { | |
local BLUE="\[\033[0;34m\]" | |
# OPTIONAL - if you want to use any of these other colors: | |
local RED="\[\033[0;31m\]" |
This file contains hidden or 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 Light: | |
def __init__(self, id, name): | |
self.id = id | |
self.name = name | |
response = {"1": {"name": "bedroom"}, "2": {"name": "kitchen"}} | |
lights = [Light(id, response[id]["name"]) for id in response] |
This file contains hidden or 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
import json | |
class Light: | |
def __init__(self, id, name): | |
self.id = id | |
self.name = name | |
lights = [Light("1", "bedroom"),Light("2","kitchen")] |
This file contains hidden or 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
#!/bin/bash | |
# This script mirrors the gutenberg cache | |
# of generated file formats | |
# By Braddock Gaskill 2013 | |
DIR=/knowledge/data/gutenberg/cache/generated | |
mkdir -p "${DIR}" | |
cd "${DIR}" | |
pwd | |
while (true); do |
This file contains hidden or 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
public static void main(String[] args) throws IOException { | |
Process pb = new ProcessBuilder("sudo", "ls").start(); | |
OutputStream out = pb.getOutputStream(); | |
out.write(password.getBytes()); | |
String line; | |
BufferedReader input = new BufferedReader(new InputStreamReader(pb.getInputStream())); | |
while ((line = input.readLine()) != null) { | |
System.out.println(line); | |
} |
OlderNewer