Skip to content

Instantly share code, notes, and snippets.

View facundofarias's full-sized avatar
🏠
Working from home

Facundo Farias facundofarias

🏠
Working from home
View GitHub Profile
@facundofarias
facundofarias / PhoneList
Created December 4, 2013 16:35
PhoneList Coding Problem
/**
* Created with IntelliJ IDEA.
* User: ffarias
* Date: 11/29/13
* Time: 9:46 AM
* To change this template use File | Settings | File Templates.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@facundofarias
facundofarias / MeanTimeOfDay.js
Last active August 29, 2015 14:04
Time circular mean calculation
/**
* Created by ffarias on 2/4/14.
*/
var meanTimeOfDay =
{
timeToDegrees: function (datetime) {
return (360 * datetime.getHours() / 24.0 + 360 * datetime.getMinutes() / (24 * 60.) + 360 * datetime.getSeconds() / (24 * 3600.0));
},
@facundofarias
facundofarias / gist:178cc64c89a874171649
Created September 5, 2014 08:24
Installing jRuby on OSX
@facundofarias
facundofarias / DefaultJobFactory.java
Created April 20, 2015 10:09
Quartz JobFactory implementation using HK2
import javax.inject.Inject;
import javax.inject.Singleton;
import org.glassfish.hk2.api.ServiceLocator;
import org.jvnet.hk2.annotations.Service;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.spi.JobFactory;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
@facundofarias
facundofarias / gist:53d9322aeeed4f52b700
Last active August 29, 2015 14:22
Hide Apache information with ServerTokens and ServerSignature directives (CentOS + Httpd24)
# Open httpd.conf file
$ vi httpd.conf
# Append/modify config directive as follows:
ServerSignature Minimal
ServerTokens Prod
Header always append X-Frame-Options SAMEORIGIN
# Save and close the file. Then, check the configurations
$ apachectl configtest
@facundofarias
facundofarias / amf.sh
Created March 31, 2016 13:55
Apache Mobile Filter (AMF) installation on Ubuntu
apt-add-repository ppa:pakin/other
apt-get update
apt-get install libapache2-apachemobilefilter-perl
@facundofarias
facundofarias / SplitInterval.java
Last active October 31, 2016 14:37
Split JodaTime Interval into intervals
private static Collection<Interval> splitDuration(Interval interval, int chunks)
{
long startMillis = interval.getStartMillis();
long endMillis = interval.getEndMillis();
long durationMillis = endMillis - startMillis;
long chunkSize = durationMillis / chunks;
Collection<Interval> list = new ArrayList<Interval>();
for (int i = 1; i <= chunks; ++i) {
list.add(new Interval(startMillis, startMillis += chunkSize));
@facundofarias
facundofarias / WebSocketResource.java
Last active January 28, 2019 14:10
Enabling WebSockets on Jersey (Tyrus)
import java.io.IOException;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.slf4j.Logger;
@facundofarias
facundofarias / CustomConfigurator.java
Created November 11, 2016 07:59
Enabling HK2 @Inject using WebSockets (Tyrus)
package cyf.rest.resources;
import javax.inject.Singleton;
import javax.websocket.server.ServerEndpointConfig.Configurator;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
/**
@facundofarias
facundofarias / mutt_on_osx.sh
Created January 3, 2017 10:55
Installing and configuring Mutt on OSX
# Install mutt using brew
$ brew install mutt
# Configure mutt
$ vim ~/.muttrc
# Put the following on the mutt config file (.muttrc)
set imap_user = “YOUR_USERNAME@GMAIL_OR_YOUR_DOMAIN.com”
set imap_pass = “YOUR_PASSWORD”
set smtp_url = “smtp://YOUR_USERNAME@GMAIL_OR_YOUR_DOMAIN@smtp.gmail.com:587/”