Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Facundo Farias facundofarias

🏠
Working from home
View GitHub Profile
@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));
},
@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 / 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 / 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 / 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 / rails_log_rotation.md
Created Feb 6, 2017
Configure rotate logs on Rails
View rails_log_rotation.md

To configure Rails to rotate your log files while in the development and test environments, add the following to your development.rb and test.rb files found within /config/environments/

# Rotate logs every day. You can use 'daily', 'weekly' or 'monthly'.
config.logger = Logger.new("#{Rails.root}/log/#{ENV['RAILS_ENV']}.log", 'daily')

Found Here

@facundofarias
facundofarias / update_php.sh
Last active Oct 10, 2017
Update to PHP 7.0 on OSX with Homebrew
View update_php.sh
$ php -v
PHP 5.6.30 (cli) (built: Feb 7 2017 16:18:37)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
$ brew update && brew upgrade
$ brew tap homebrew/dupes
$ brew tap homebrew/versions
$ brew tap homebrew/homebrew-php
# You might get an error if PHP 5.6 has not been installed by brew previously, but don't worry, you can simply continue
@facundofarias
facundofarias / your_model.php
Created May 18, 2017
Add a watermark using laravel-medialibrary
View your_model.php
...
->setManipulations([
'w' => 350,
'fm' => 'src',
'mark' => public_path('assets/img/watermark.png'),
'markfit' => 'fill',
'markpos' => 'center',
])
...
You can’t perform that action at this time.