Skip to content

Instantly share code, notes, and snippets.

// Place your settings in this file to overwrite the default settings
{
"editor.folding": false,
"editor.lineNumbers": "off",
"editor.scrollBeyondLastLine": false,
"editor.snippetSuggestions": "top",
"explorer.openEditors.visible": 0,
"files.hotExit": "off",
"files.trimTrailingWhitespace": true,
"window.reopenFolders": "none",
### Keybase proof
I hereby claim:
* I am AlexanderEkdahl on github.
* I am alexanderekdahl (https://keybase.io/alexanderekdahl) on keybase.
* I have a public key whose fingerprint is C726 4796 22D7 91B3 3C32 CD4D 5ACC 53B5 78C9 9EC0
To claim this, I am signing this object:
sv:
activerecord:
models:
property:
one: Basal kompetens
other: Basala kompetenser
attributes:
document:
comment: Anteckningar
file: Fil
@AlexanderEkdahl
AlexanderEkdahl / gist:8912142
Created February 10, 2014 08:12
FileFinder by Fredrik Sydvart and AlexanderEkdahl
package hollow.harddrives.IO;
import java.io.File;
import java.io.FilenameFilter;
import java.nio.file.FileSystems;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
public class FileFinder {
public static File[] findAll(String glob) {
defmodule RandomModule do
defmacro __using__(module) do
quote do
import RandomModule
Module.register_attribute __MODULE__, :attributes, accumulate: true
def run do
RandomModule.run @attributes
end
@AlexanderEkdahl
AlexanderEkdahl / gist:7240643
Last active December 27, 2015 00:49
Converts all code from Ruby 1.8 hash style to 1.9 style. Copied from http://effectif.com/ruby/update-your-project-for-ruby-19-hash-syntax for safekeeping. Original author [@GrahamAshton](https://twitter.com/grahamashton)
find . -name \*.rb -exec perl -p -i -e 's/([^:]):(\w+)\s*=>/\1\2:/g' {} \;
@AlexanderEkdahl
AlexanderEkdahl / validate_personal_identity_number.rb
Last active December 26, 2015 15:49
Validate swedish personal identity number
def validate_personal_identity_number(number)
multiplier = 2
sum = 0
number[0..8].each_char do |digit|
x = multiplier * digit.to_i
if x > 9
sum += x % 10 + 1
else
def to_format(number, format = '+XX XXX XX XX XX')
format.gsub(/X/) { number.slice!(0) }
end
module Verifiable
extend ActiveSupport::Concern
def verification_key
ActiveSupport::MessageEncryptor
.new(Rails.application.config.secret_key_base)
.encrypt_and_sign("#{self.class} #{id}")
end
module ClassMethods
@AlexanderEkdahl
AlexanderEkdahl / erlang.rb
Created July 31, 2013 20:48 — forked from dch/erlang.rb
homebrew install Erlang/OTP R16B01 via `brew install https://gist.github.com/AlexanderEkdahl/6126022/raw/erlang.rb`
require 'formula'
class ErlangManuals < Formula
url 'http://erlang.org/download/otp_doc_man_R16B.tar.gz'
sha1 '48eaf215e5dcae8b4f02cc39ed557ec6f9dd026a'
end
class ErlangHtmls < Formula
url 'http://erlang.org/download/otp_doc_html_R16B.tar.gz'
sha1 '14729a486f331678d2c7ae1ca1608b7e9f3fd8f2'