Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Facundo Farias facundofarias

🏠
Working from home
View GitHub Profile
@facundofarias
facundofarias / PhoneList
Created Dec 4, 2013
PhoneList Coding Problem
View PhoneList
/**
* 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 Aug 29, 2015
Time circular mean calculation
View MeanTimeOfDay.js
/**
* 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));
},
View gist:178cc64c89a874171649
@facundofarias
facundofarias / DefaultJobFactory.java
Created Apr 20, 2015
Quartz JobFactory implementation using HK2
View DefaultJobFactory.java
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 Aug 29, 2015
Hide Apache information with ServerTokens and ServerSignature directives (CentOS + Httpd24)
View gist:53d9322aeeed4f52b700
# 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 Mar 31, 2016
Apache Mobile Filter (AMF) installation on Ubuntu
View amf.sh
apt-add-repository ppa:pakin/other
apt-get update
apt-get install libapache2-apachemobilefilter-perl
@facundofarias
facundofarias / SplitInterval.java
Last active Oct 31, 2016
Split JodaTime Interval into intervals
View SplitInterval.java
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 Jan 28, 2019
Enabling WebSockets on Jersey (Tyrus)
View WebSocketResource.java
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 Nov 11, 2016
Enabling HK2 @Inject using WebSockets (Tyrus)
View CustomConfigurator.java
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 Jan 3, 2017
Installing and configuring Mutt on OSX
View mutt_on_osx.sh
# 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/”
You can’t perform that action at this time.