Skip to content

Instantly share code, notes, and snippets.

View notificationHandler.js
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
};
View gist:73edac1566d2b2d73eebca8b1dd2ebd9
<?php
namespace Examples\Transmissions;
require dirname(__FILE__).'/../bootstrap.php';
use SparkPost\SparkPost;
use GuzzleHttp\Client;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
View locationService.js
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
View app.js
LocationService.askLocationPermission()
.then(LocationService.getCoords)
.then(function(coords) {
console.log(coords);
})
.catch(function(err) {
console.log(err);
});
View locationService.js
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) {
View app.js
LocationService.getCoords()
.then(function (coords) {
console.log(coords);
});
View hello_mailer.rb
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 Jan 6, 2016
Hot reload node module
View country.json
[
"countryA",
"countryB"
]
@thehungrycoder
thehungrycoder / Gemfile
Last active Dec 23, 2015
Example of using sparkpost's ruby gem Raw
View Gemfile
source 'https://rubygems.org'
gem 'sparkpost'
@thehungrycoder
thehungrycoder / email_settings.rb
Last active Oct 27, 2016
Integrate sparkpost in Rails app
View email_settings.rb
# 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'