Skip to content

Instantly share code, notes, and snippets.

@mugifly
mugifly / circle.yml
Last active March 25, 2021 13:48
Faster test & Build of Android Studio Project (Gradle Project) on Circle-CI.
machine:
java:
version: oraclejdk8
environment:
# Java options
JAVA_OPTS: "-Xms512m -Xmx2048m"
# ADB options
ADB_INSTALL_TIMEOUT: 5000
dependencies:
@jonyt
jonyt / connect_heroku_to_amazon_rds
Last active April 13, 2017 00:11
How to connect a Heroku application to an Amazon RDS Postgresql instance
Download the certificate with:
`wget -O config/rds-combined-ca-bundle.pem http://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem`
Then connect with:
`postgres://user:password@amazon-host/db_name?sslmode=require&sslrootcert=config/rds-combined-ca-bundle.pem`
References:
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html#PostgreSQL.Concepts.General.SSL
https://github.com/jeremyevans/sequel/issues/897
http://www.postgresql.org/docs/9.3/static/libpq-connect.html#LIBPQ-CONNECT-SSLROOTCERT
http://dba.stackexchange.com/questions/77811/how-to-connect-to-an-amazon-postgresql-database-using-ssl
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>
@benjchristensen
benjchristensen / DebounceBuffer.java
Last active March 1, 2024 15:46
DebounceBuffer: Use publish(), debounce() and buffer() together to capture bursts of events.
import java.util.List;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Subscriber;
import rx.schedulers.Schedulers;
public class DebounceBuffer {
public static void main(String args[]) {
@BrandonSmith
BrandonSmith / AndroidManifest.xml
Last active July 19, 2023 19:11
Quick example of how to schedule a notification in the future using AlarmManager
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cards.notification">
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
class AppShare < ActiveRecord::Base
belongs_to :app
belongs_to :sharer, class_name: 'User'
belongs_to :sharee, class_name: 'User'
has_many :notifications, foreign_key: :notified_object_id, conditions: {notified_object_type: 'AppShare'}, dependent: :destroy
after_commit :create_notification, on: :create
def create_notification
@joshbirk
joshbirk / passport-fdc.js
Created January 31, 2012 21:09
Basic Passport / Force.com / Node.js example
var port = process.env.PORT || 3000;
var fs = require('fs');
var express = require('express');
var passport = require('passport')
, OAuthStrategy = require('passport-oauth').OAuth2Strategy;
passport.serializeUser(function(user, done) {
done(null, user);
});