Skip to content

Instantly share code, notes, and snippets.

@johankj
johankj / GroupBy.swift
Created December 26, 2015 14:16
A GroupBy method in Swift as seen in other languages
extension SequenceType where Generator.Element: Comparable {
func group() -> [[Generator.Element]] {
return self.group { $0 == $1 }
}
func group(by groupBy: (Generator.Element, Generator.Element) -> Bool) -> [[Generator.Element]] {
return self.reduce([]) { (xs, q) -> [[Generator.Element]] in
guard xs.count > 0 else { return [[q]] }
var xs = xs
let last = xs.count-1
if groupBy(xs[last][0], q) {
@johankj
johankj / tupper.ipynb
Last active August 29, 2015 14:26 — forked from tacaswell/tupper.ipynb
Notebook demonstrating Tupper's Self-Referential Formula
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Hi,
On Sunday we had some problems with the ShareLaTeX database and we had to revert some accounts and projects to a previous state. According to our logs, it's possible that your account was affected. No data has been lost that we know of. Your projects in ShareLaTeX may now be at an earlier version, as they were at 6am on Saturday morning (UTC), but you can still find the latest versions of your projects by logging in and going to the special page: https://www.sharelatex.com/restore.
If you created an account on Saturday, it's possible that you'll have to re-create it. Please get in touch if you created any projects with this account that need restoring.
It's also possible that any projects created on Saturday are no longer listed in your projects list. However these can still be found in https://www.sharelatex.com/restore.
Please get in touch if you have any questions or problems accessing your data.
@johankj
johankj / like-o-matic.js
Created January 25, 2013 17:55
A bookmarklet which adds a Facebook "Like"-button as well as a "Recommend"-button. Inspired by http://likeomatic.heroku.com
(function () {
try {
var url = encodeURIComponent(location.href);
var ifr = document.createElement('iframe');
ifr.style.position = 'absolute';
ifr.style.top = 10 + 'px';
ifr.style.left = 10 + 'px';
ifr.style.width = 450 + 'px';
ifr.style.height = 70 + 'px';
ifr.style.border = 'none';
@johankj
johankj / gist:1137691
Created August 10, 2011 18:22
Register Twitter for Mac with MacHeist license
# As it is no longer possible to register
# the app because of Apple's App Store Terms
# The only legal way to get the features,
# is to get an older version (from backup)
# and then upgrade to the latest version.
# Or you can run the following commands with you license information:
defaults write com.twitter.twitter-mac reg.email3 -string "your@email"
defaults write com.twitter.twitter-mac reg.license3 -string "yourMacHeistLicense"