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 / Dockerfile
Last active October 18, 2023 05:51
nodesource/distributions for Ubuntu on Docker
# Installing node.js (16) and npm: https://github.com/nodesource/distributions
ENV NODE_MAJOR=16
# 1. Download and import the Nodesource GPG key
RUN apt-get update
RUN apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
# 2. Add the NodeSource package repositories for Debian-based distributions
@facundofarias
facundofarias / lambda_handler.py
Created March 7, 2019 13:36
Use a AWS Lambda to send a notification when a file was added to AWS s3
#####################################
# Notify when a s3 file was created #
#####################################
import json
import boto3
import urllib.parse
import urllib.request
print('Loading function')
@facundofarias
facundofarias / SomeEntity.cs
Created February 26, 2019 16:39
Best ToString method on .NET Core
using Newtonsoft.Json;
...
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
@facundofarias
facundofarias / update_php.sh
Last active October 10, 2017 14:53
Update to PHP 7.0 on OSX with Homebrew
$ 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 14:21
Add a watermark using laravel-medialibrary
...
->setManipulations([
'w' => 350,
'fm' => 'src',
'mark' => public_path('assets/img/watermark.png'),
'markfit' => 'fill',
'markpos' => 'center',
])
...
@facundofarias
facundofarias / rails_log_rotation.md
Created February 6, 2017 08:33
Configure rotate logs on Rails

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 / 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/”
@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 / 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 / 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));