Skip to content

Instantly share code, notes, and snippets.

View andreabreu-me's full-sized avatar

André Abreu andreabreu-me

View GitHub Profile
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang3.SerializationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.jwt.JwtHelper;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
/// GENERAL METHODS FOR OAUTH'ING
/// using the Apache Oltu library
/// https://cwiki.apache.org/confluence/display/OLTU/Index
public String getAuthUrl() {
OAuthClientRequest request = null;
try {
request = OAuthClientRequest
.authorizationLocation("https://www.hackerschool.com/oauth/authorize")
@andreabreu-me
andreabreu-me / s3.sh
Last active August 29, 2015 14:20 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
import UIKit
func addViewAndButton() {
// iOS 9 availability coolness
guard #available(iOS 9, *) else {
return
}
// boilerplate view creation
@andreabreu-me
andreabreu-me / install-comodo-ssl-cert-for-nginx.rst
Created January 22, 2017 23:53 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@andreabreu-me
andreabreu-me / setdnstarget.sh
Created September 21, 2017 23:28 — forked from rtucker/setdnstarget.sh
A one-liner to set a Linode DNS Manager target to your client's current public IP address
ssh you@yourlinode "wget -O - -q https://api.linode.com/?api_key=$LINODE_API_KEY\&api_action=domain.resource.update\&domainid=$DOMAINID\&resourceid=$RESOURCEID\&target=\`echo \$SSH_CLIENT | cut -d' ' -f1\`"
@andreabreu-me
andreabreu-me / angular-get-service-console.js
Created October 9, 2017 16:51 — forked from justinobney/angular-get-service-console.js
Get a reference to some angular service in the console
// Get the injector
var injector = angular.element($0/*'[data-ng-app], [ng-app]'*/).injector();
// Get the service
var Service = injector.get('Service');
// Use it!
// Service.addNotification('Some Notification', 'info');
@andreabreu-me
andreabreu-me / kill_by_tcp_port.sh
Last active July 26, 2021 11:33
[Bash] kill process by tcp port
lsof -i tcp:8080 | tr -s " " | cut -d " " -f2 | tail -n 1 | xargs kill -9
@andreabreu-me
andreabreu-me / observer.ts
Created May 26, 2018 01:51 — forked from joelpalmer/observer.ts
TypeScript Observer Pattern - Observable
//we will use a push observer pattern
interface IObservable {
subscribe: Function;
unsubscribe: Function;
publish: Function;
}
class Observable implements IObservable {
private subscribers: any[] = new Array();
public subscribe(cb) {
//we could check to see if it is already subscribed