Skip to content

Instantly share code, notes, and snippets.

import { Notifications } from 'expo';
import { AppState, Platform } from 'react-native';
import { Component } from 'react';
const isIos = Platform.OS === 'ios';
export class NotificationHandler extends Component {
state = {
appState: AppState.current
};
<?php
namespace Examples\Transmissions;
require dirname(__FILE__).'/../bootstrap.php';
use SparkPost\SparkPost;
use GuzzleHttp\Client;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
@thehungrycoder
thehungrycoder / email_settings.rb
Last active October 27, 2016 15:59
Integrate sparkpost in Rails app
# config/initializers/email_settings.rb
ActionMailer::Base.smtp_settings = {
user_name: 'SMTP_Injection',
password: 'Any API Key with Send via SMTP permission',
address: 'smtp.sparkpostmail.com',
port: 587,
enable_starttls_auto: true,
format: :html,
from: 'mailer@yourawesomeapp.com'
angular.module('myapp.services', [])
.service('LocationService', function ($cordovaGeolocation) {
return {
askLocationPermission: function (successCallback, errorCallback) {
var permissions = cordova.plugins.permissions; // could not find a better way to access cordova; it's not in $window
permissions.requestPermission(permissions.ACCESS_COARSE_LOCATION, successCallback, errorCallback);
}
getCoords: function () {
// omitted for brevity
LocationService.getCoords()
.then(function (coords) {
console.log(coords);
});
LocationService.askLocationPermission()
.then(LocationService.getCoords)
.then(function(coords) {
console.log(coords);
})
.catch(function(err) {
console.log(err);
});
angular.module('myapp.services', [])
.service('LocationService', function ($cordovaGeolocation, $q) {
return {
askLocationPermission: function () {
var permissions = cordova.plugins.permissions, // could not find a better way to access cordova; it's not in $window
deferred = $q.defer();
permissions.requestPermission(permissions.ACCESS_COARSE_LOCATION, function(result) {
deferred.resolve();
}, function(err) {
class HelloMailer < ApplicationMailer
def welcome(user)
headers 'X-MSYS-API': { "options": { "open_tracking": true, "click_tracking": true } }.to_json
mail(to: user.email, subject: 'Welcome!')
end
end
@thehungrycoder
thehungrycoder / country.json
Last active January 6, 2016 21:28
Hot reload node module
[
"countryA",
"countryB"
]
@thehungrycoder
thehungrycoder / Gemfile
Last active December 23, 2015 21:53
Example of using sparkpost's ruby gem Raw
source 'https://rubygems.org'
gem 'sparkpost'