Skip to content

Instantly share code, notes, and snippets.

View joakim's full-sized avatar
🌿

joakim

🌿
View GitHub Profile
@joakim
joakim / es6-collections.js
Created May 22, 2018 11:53
ES6 collections polyfill for Espruino
//shared pointer
var i;
//shortcuts
var defineProperty = Object.defineProperty, is = function(a,b) { return (a === b) || (a !== a && b !== b) };
/**
* ES6 collection constructor
* @return {Function} a collection class
*/
function createCollection(proto, objectOnly){
const PWRKEY = B4;
const TX = B6;
const RX = B7;
// Turn on the SIM7000 module
pinMode(PWRKEY, 'output');
digitalPulse(PWRKEY, 0, 100);
// Set up serial port (UART)
Serial1.setup(115200, {
@joakim
joakim / subgit.sh
Created October 9, 2014 10:22 — forked from rustyio/subgit
#!/usr/bin/env sh
# subgit
#
# A tiny wrapper around git to help you manage
# Git sub-projects easily, safely, and simply.
#
# Created by Rusty Klophaus (@rklophaus)
#
# See http://rklophaus.com/subgit for usage.
@joakim
joakim / text.md
Last active August 29, 2015 14:06
On Tent and messing up

I've been thinking about graue's criticism of Tent's immutability of posts, and I share his concern. People make mistakes. Imagine storing a nude photo of yourself and by accident making it public. Or sharing a sensitive post with the wrong group of people. Tent's subscription magic would immediately push that post to your subscribers, and there's nothing you can do about it.

So how about this…

Allow servers to be configured with functionality like Gmail's Undo Send feature for non-private posts (per post type), allowing users to undo a post within a specified amount of time. The post would only be pushed to subscribers after time runs out, and not if the user hits undo (in time).

Or not?

Maybe this is something that's better left to app developers to implement? I'm guessing that would be DJ[J](https://jes

@joakim
joakim / tent.md
Last active August 29, 2015 14:06
A short text about Tent's posts, subscriptions and push model

Tent is data-agnostic. All your data is stored as posts in your account on your Tent provider's server. Posts can be private or public, you decide who gets access to what.

Other Tent users may subscribe to your posts (the ones they have access to), and your Tent provider will then push any new posts you create to your subscribers. You subscribe by specifying what type of data you're interested in, and receive only posts matching that query.

This is in contrast to the web, where the browser usually goes out and actively fetches data from a server (i.e. pull). Tent's push model has many advantages and opens up some interesting possibilities for developers. Even so, it's not going to replace the web any time soon, but rather compliment the web in the areas where it comes up short.

Tent is a protocol that operates alongside the web and email, as an alternative decentralized and secure communication channel on the Internet.

@joakim
joakim / keybase.md
Created September 4, 2014 11:45
Keybase proof

Keybase proof

I hereby claim:

  • I am joakim on github.
  • I am joakim (https://keybase.io/joakim) on keybase.
  • I have a public key whose fingerprint is 63C6 DC0D 006B 114E 9CAE 4164 C276 DF89 4743 A4C8

To claim this, I am signing this object:

@joakim
joakim / Biting Bug Blues.md
Last active August 29, 2015 13:57
Biting Bug Blues

Biting Bug Blues

https://www.youtube.com/watch?v=5AsCimVAZM0

Just a biting bug been following me everywhere I go
Just a biting bug been following me everywhere I go
I'm gonna kill that biting bug, so she won't follow me no more

Just a biting bug been following me from file to file
Just a biting bug been following me from file to file

@joakim
joakim / path_save_subpage_alias.php
Last active December 25, 2015 18:49
Drupal: Save additional path aliases for subpages. Could be used with nodes to make node/123/edit (with alias "foo") look like foo/edit. Prettier.
/**
* Implements hook_node_presave().
*/
function custom_node_presave($node) {
// Get the source of the "base" path which has subpages.
$source = 'node/' . $node->nid;
// If the node's alias is "foo", foo/edit will be an alias for node/123/edit.
custom_save_subpage_alias($source, 'edit');
@joakim
joakim / taxonomy_term_remove_from_nodes.php
Created October 16, 2013 10:05
Drupal: Programmatically remove a term from multiple nodes
// ID of taxonomy term to remove.
$tid = 5;
// Name of the taxonomy field where the term is found.
$field_name = 'field_NAME';
_taxonomy_term_remove_from_nodes($tid, $field_name);
function _taxonomy_term_remove_from_nodes($tid, $field_name) {
$nids = taxonomy_select_nodes($tid, FALSE, FALSE);
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\033[1;33m\]'
c_path='\[\e[0;33m\]'
c_git_clean='\[\e[0;36m\]'
c_git_dirty='\[\e[0;35m\]'
else
c_reset=
c_user=