This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LocalStorageSet { | |
constructor(key, fifoMaxEntries = null) { | |
this.key = key; | |
this.fifoMaxEntries = fifoMaxEntries; | |
this.entries = this.load(); | |
} | |
load() { | |
const rawValue = window.localStorage.getItem( | |
this.key, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getQueryParams() { | |
const queryString = document.location.search; | |
if (!queryString) { | |
return {}; | |
} | |
return ( | |
// Strip the initial ? | |
queryString.substring(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_trie(words, tokenize_fn=None, count_key='__count__', is_word_key='__is_word__'): | |
top_node = {} | |
if not tokenize_fn: | |
tokenize_fn = lambda word: list(word) | |
for word in words: | |
cursor = top_node | |
tokens = tokenize_fn(word) | |
tokens_length = len(tokens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$client = User::getClient(); | |
$facebook_id = null; | |
$connection_result = $client->oauth->connection->search(array( | |
"user_id" => "self" | |
)); | |
foreach($connection_result->items as $connection){ | |
if($connection->provider_id == 'facebook'){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DictionaryUtility: | |
""" | |
Utility methods for dealing with dictionaries. | |
""" | |
@staticmethod | |
def to_object(item): | |
""" | |
Convert a dictionary to an object (recursive). | |
""" | |
def convert(item): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var alphamail = require('alphamail'); | |
var emailService = new alphamail.EmailService("API-TOKEN"); | |
var data = {name:"Joe", pwns:true, likesCats:"certainly"}; | |
var payload = new alphamail.EmailMessagePayload() | |
.setProjectId(1235) // ID of your AlphaMail project | |
.setSender(new alphamail.EmailContact("My Company", "[email protected]")) | |
.setReceiver(new alphamail.EmailContact("Some dude", "[email protected]")) | |
.setBodyObject(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<h2>Hi <# capitalize(payload.user.name) #>!</h2><br><br> | |
<# capitalize(payload.sender.name) #> (<# payload.sender.id #>) sent you a message.<br> | |
<p> | |
<# shorten(payload.message.body, 25) #> | |
<# if(payload.message.body.length > 25){ #> | |
<a href="http://www.awesome.com/msg/<# urlencode(payload.message.id) #>/read/">login and read the full message</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once("comfirm.alphamail.client/emailservice.class.php"); | |
$email_service = AlphaMailEmailService::create() | |
->setServiceUrl("http://api.amail.io/v1") | |
->setApiToken("YOUR-ACCOUNT-API-TOKEN-HERE"); | |
$notification = array( | |
"user" => array( | |
"name" => "John" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'lib/swift_required.php'; | |
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25) | |
->setUsername('your username') | |
->setPassword('your password'); | |
$mailer = Swift_Mailer::newInstance($transport); | |
$message = Swift_Message::newInstance('Wonderful Subject') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// to, subject, body | |
mail('[email protected]', 'My Subject', "My awesome body text"); | |
?> |
NewerOlder