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
# Assumptions | |
- OpenSSL is installed | |
- base working directory is /usr/lib/ssl/misc | |
# Create new certificate authority, created in demoCA directory | |
sudo ./CA.pl -newca | |
# Sign a certificate request using CA created above | |
sudo openssl x509 -req -CA demoCA/cacert.pem -CAkey demoCA/private/cakey.pem -in newreq.pem -out localhost.cer -days 1460 -CAcreateserial |
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
# Number indicates size, in bytes, to leave. Can run on a file that is currently being written to, like server logs. | |
sudo truncate -s 4 server.log | |
# Deletes files and directories older than 7 days | |
sudo find <full path dir> -ctime +7 -exec rm -rf {} \; | |
# Disk space | |
df | |
df -h // human-readable |
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
Grails externalized configuration files: | |
If you want to include a config groovy class, you have to include it as an object in the config location list. | |
Despite the comments saying this: | |
// grails.config.locations = [ "classpath:${appName}-config.properties", | |
// "classpath:${appName}-config.groovy", | |
// "file:${userHome}/.grails/${appName}-config.properties", | |
// "file:${userHome}/.grails/${appName}-config.groovy"] |
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
// Long-Polling is used in this example b/c of IE7 | |
// Add atmosphere to ApplicationResources.groovy | |
modules = { | |
... | |
atmosphere { | |
dependsOn 'jquery' | |
resource url:'js/atmosphere.js' // used jQuery atmosphere minified | |
} | |
} |
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
Benchmark your SSD or hard disk speed | |
To test write speed: | |
time dd if=/dev/zero bs=1024k of=tstfile count=1024 | |
To test read speed: | |
time dd if=tstfile bs=1024k of=/dev/null count=1024 | |
hdiutil convert -format UDRW -o ubcd.img /ubcd537.iso |
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
Ended up being too memory intensive, but it worked: | |
================================================== | |
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - | |
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' | |
sudo apt-get update |
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 java.util.Iterator; | |
import java.util.Map; | |
import java.util.TreeMap; | |
import javax.net.ssl.SSLServerSocketFactory; | |
public class Ciphers | |
{ | |
public static void main(String[] args) | |
throws Exception | |
{ |
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
/** | |
* fieldIdentifier = objectRoot.foo[0].bar, fieldValue = abc | |
* fieldIdentifier = objectRoot.foo[1].bar, fieldValue = xyz | |
*/ | |
public final class SimpleJsonGenerator { | |
private static final Set<String> ARRAY_NODES = getArrayNodes(); | |
private static final String BASE_JSON_PATH = "objectRoot"; |
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
/** | |
* fieldIdentifier = //ROOT/FOO[0], fieldValue = abc | |
* fieldIdentifier = //ROOT/FOO[1]/@Bar, fieldValue = xyz | |
*/ | |
public class SimpleXmlGenerator { | |
public static String createXml(String xmlRootName, List<FieldEnumeration> inputFields) { | |
StringBuilder xmlString = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | |
buildXml(xmlString, buildXmlNodes(xmlRootName, inputFields)); |
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 class JsonSchemaUtility { | |
public static void main(String[] args) throws Exception { | |
ObjectMapper objectMapper = new ObjectMapper(); | |
// Serialize a LocalDate using the corresponding ISO formatter | |
objectMapper.registerModule(new SimpleModule().addSerializer(new LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE))); | |
// Serialize a OffsetDateTime using the corresponding custom formatter | |
objectMapper.registerModule(new SimpleModule().addSerializer(new CustomOffsetDateTimeSerializer(OffsetDateTime.class))); | |
// Serialize a Year using the corresponding ISO formatter | |
objectMapper.registerModule(new SimpleModule().addSerializer(YearSerializer.INSTANCE)); |
OlderNewer