Skip to content

Instantly share code, notes, and snippets.

@saulshanabrook
saulshanabrook / README.md
Created October 19, 2016 14:20
Saving Web Crypto Keys using indexedDB

This is a working example on how to store CryptoKeys locally in your browser. We are able to save the objects, without serializing them. This means we can keep them not exportable (which might be more secure?? not sure what attack vectors this prevents).

To try out this example, first make sure you are in a browser that has support for async...await and indexedDB (latest chrome canary with chrome://flags "Enable Experimental Javascript" works). Load some page and copy and paste this code into the console. Then call encryptDataSaveKey(). This will create a private/public key pair and encrypted some random data with the private key. Then save both of them. Now reload the page, copy in the code, and run loadKeyDecryptData(). It will load the keys and encrypted data and decrypt it. You should see the same data logged both times.

@joashp
joashp / PushNotifications.php
Last active July 28, 2023 12:33
Simple PHP script to send Android Push Notification, iOS Push Notification and Windows Phone 8 Push Notification
<?php
// Server file
class PushNotifications {
// (Android)API access key from Google API's Console.
private static $API_ACCESS_KEY = 'AIzaSyDG3fYAj1uW7VB-wejaMJyJXiO5JagAsYI';
// (iOS) Private key's passphrase.
private static $passphrase = 'joashp';
// (Windows Phone 8) The name of our push channel.
private static $channelName = "joashp";

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@EGreg
EGreg / Q.Promises.js
Created November 11, 2014 22:36
A clear and tested Promises implementation
/**
* Q Promises implementation
* @module Q
*/
(function (Q) {
/**
* Q.Promise constructor.
* Call the .fulfill(...) or .reject(...) method to
* signal that the promise is fulfilled or rejected.
@jashkenas
jashkenas / semantic-pedantic.md
Last active November 29, 2023 14:49
Why Semantic Versioning Isn't

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

@dougreese
dougreese / apc_overloads.php
Last active October 12, 2015 08:12 — forked from aholmes/apc_overloads.php
APC replacement functions for code using apc_* user based caching functions for servers running PHP 5.5 (where APC is no longer supported) or where APC is otherwise not installed. Stores data in file based cache files.
<?php
/*
APC replacement functions
Replaces APC user cache functionality with file based caching.
Notes:
- cache files stored in result of sys_get_temp_dir()
- ttl not supported, cache files must be cleaned up manually
@aholmes
aholmes / apc_overloads.php
Created December 23, 2013 19:49
Overload apc_fetch and apc_add as a quick replacement for APC methods on systems that don't support it (like PHP 5.5 on OSX). These methods are not an exact reimplementation of the defined documentation on http://php.net. TTL is ignored, for one.
<?php
// apc crashed on my dev box, so overload the methods if they don't exist
if (!function_exists('apc_fetch')) {
function apc_fetch($key, &$success) {
if (!($filename = apc_get_tmpfile($key, $f))) {
return false;
}
if (!($d = fread($f, filesize($filename)))) {
<?php
/**
* Geohash
*
* @author Keisuke SATO
* @license MIT License
*
* # Based
* http://github.com/davetroy/geohash-js/blob/master/geohash.js
* Geohash library for Javascript