Skip to content

Instantly share code, notes, and snippets.

@ptn
ptn / spam.md
Last active December 28, 2020 15:19
Doom Emacs + mu4e + ProtonMail Bridge: mail always ends up in Spam

Solution

When you install Bridge, you're supposed to get a certificate in ~/.config/protonmail/bridge, but I didn't get it. I extracted it with:

   openssl s_client -starttls smtp -connect 127.0.0.1:1025 -showcerts

and saved it at ~/.cert/protonmail.smtp.crt. I then had to point gnutls to it, I used the customize interface and now I have this entry in my custom.el:

@ptn
ptn / bench.js
Created November 27, 2014 00:38
forEach benchmark
var x = [];
// one million elements
for (var i = 0; i < 1000000; i++) {
x.push(i);
}
function testFor(x) {
console.time('benchmark');
for (var i = 0; i < x.length; i++) {
x[i];
class NativeDictionary:
def __init__(self):
self.dictionary = {}
def add_key_value_pair(self, key, value):
self.dictionary[key] = value
def get_value(self, key):
return self.dictionary[key]
@ptn
ptn / router.clj
Last active August 29, 2015 13:56
(ns router.core
(:gen-class)
(:use [clojure.string
:only [replace]
:rename {replace str-replace}]))
(defn- build-route [[url-spec handler]]
(let [regex (re-pattern (str-replace url-spec #":.+?\/" "(.+?)/"))]
`(fn [url#]
(if-let [match# (re-matches ~regex url#)]
@ptn
ptn / ascii_accumulator.rb
Last active December 11, 2015 18:38
Bit Zeppelin Hack Party - Code Kata #2
# -*- coding:utf-8 -*-
def main(path)
accumulator = 0
read_ascii(path) { |char| accumulator += with_sign(to_num(char)) }
accumulator
end
def read_ascii(path)
File.open(path) do |f|
@ptn
ptn / 20111218135715_globalize_models.rb
Created September 2, 2012 00:58 — forked from kevinansfield/20111218135715_globalize_models.rb
Globalize3 support with tabs in Active Admin
# db/migrate/20111218135715_globalize_models.rb
class GlobalizeModels < ActiveRecord::Migration
def up
NewsItem.create_translation_table!(
{:title => :string, :body => :text},
{:migrate_data => true}
)
end
class MapManager
constructor: ->
path = @buildPath()
map = new GMaps
div: "#map"
lat: -10
lng: -76
zoom: 6
idle: ->
$(document).ready ->
if $("#map").length > 0
class MapManager
constructor: ->
@defaultLat = -12.043333
@defaultLng = -77.028333
@latEl = $("#experience_latitude")
@lngEl = $("#experience_longitude")
coords = @initialCoords()
@ptn
ptn / s.rb
Created April 11, 2012 14:19 — forked from jacksonwillis/s.rb
Sentences as Ruby code
class S; def initialize *w; @s=w; end; def method_missing *w;@s<<w;self;end;def
to_ary;[@s.map{ |e| e=~/[\,\.\:\-\(\)\/\'\"]/?[e]:[" ",e] }.join.strip];end;end
def Object.const_missing(c);S.new c;end; ###### https://gist.github.com/2354740
puts This.is.a.sentence.represented.by.a.Ruby.expression(",").try.it.out! #####
<?php
require_once('../wp-load.php');
/*
* --------------------------------------------------------------------
* SELECT
* --------------------------------------------------------------------
/*