Skip to content

Instantly share code, notes, and snippets.

@fforbeck
fforbeck / add_ebs_to_ubuntu_ec2
Last active December 19, 2015 02:48
Add EBS to Ubuntu EC2 Instance
You need to format the EBS volume (block device) with a file system between step 1 and step 2. So the entire process with your sample mount point is:
Create EBS volume.
Attach EBS volume to /dev/sdf (EC2's external name for this particular device number).
Format file system /dev/xvdf (Ubuntu's internal name for this particular device number):
sudo mkfs.ext4 /dev/xvdf
Mount file system (with update to /etc/fstab so it stays mounted on reboot):
@fforbeck
fforbeck / fix_java_plugin_macos
Created June 25, 2013 01:21
Fixing Java plugin for osx
sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo ln -sf /System/Library/Frameworks/JavaVM.framework/Commands/javaws /usr/bin/javaws
@fforbeck
fforbeck / git_install.sh
Created June 21, 2013 20:28
To install the latest stable from command line...
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
@fforbeck
fforbeck / jdk.txt
Created June 10, 2013 14:44
installing jdk
$ sudo apt-get purge openjdk*
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
Install Java 8:
$ sudo apt-get install oracle-java8-installer
Or, install Java 7:
@fforbeck
fforbeck / ListaDuplamenteEncadeada.java
Created June 7, 2013 21:25
double linked list sample
public class ListaDuplamenteEncadeada {
private Pessoa primeiraPessoa;
private Pessoa ultimaPessoa;
private int totalPessoas;
public void insereInicio(Pessoa novaPessoa) {
@fforbeck
fforbeck / Solr setup steps
Last active December 18, 2015 02:19
Solr setup
0. Installing - http://www.apache.org/dyn/closer.cgi/lucene/solr/4.3.0
1. Setup your fields types in solr/collections/conf/schema.xml
2. POST JSON -
curl http://localhost:8983/solr/update/json?commit=true --data-binary @file-name.json -H 'Content-type:application/json'
3. CLEAR DATABASE
curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
@fforbeck
fforbeck / SolrConnector.java
Created June 4, 2013 22:11
SolrConnector using solrj
import java.io.IOException;
import java.util.List;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrInputDocument;
@fforbeck
fforbeck / Redis TTL
Created May 23, 2013 20:17
Redis TTL
redis> SET key "value"
OK
redis> EXPIRE key 15
(integer) 1
redis> TTL key
(integer) 10
redis> TTL key
(integer) 9
redis> TTL key
(integer) 8
@fforbeck
fforbeck / print_java_stacktrace
Created May 23, 2013 15:38
Print java stacktrace
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
sw.toString();
@fforbeck
fforbeck / mongo_ttl_indexes
Last active December 17, 2015 16:09
Activating MongoDB TTL for indexes
- Creating new index with ttl, the key must be date type and can not be a compound index.
> db.teste_ttl_idx.ensureIndex({ttl: 1}, {expireAfterSeconds: 5});
- Insert new documents
> db.teste_ttl_idx.insert({ttl: new Date()});
> db.teste_ttl_idx.insert({ttl: new Date()});
> db.teste_ttl_idx.insert({ttl: new Date()});
- You can do a find all to check if the elements were inserted and if they will be removed in the next 5 seconds after their creation.