Skip to content

Instantly share code, notes, and snippets.

Marius Mathiesen zmalltalker

Block or report user

Report or block zmalltalker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View validate_bank_account.rb
# coding: utf-8
class NorwegianBankAccount
# Pass me any kind of string representing an account number
def initialize(str)
@numbers = str.gsub(/[^\d]/,'')
end
# Prettified output
def to_s
begin
View validate_bank_account.rb
class NorwegianBankAccount
# Pass me any kind of string representing an account number
def initialize(str)
@numbers = str.gsub(/[^\d]/,'')
end
# Prettified output
def to_s
begin
parts = @numbers.split(//)
View rage.rb
def place_text(text)
x = 130
y = 70
message = text.tr("abcdefghijklmnopqrstuvwxyz","nopqrstuvwxyzabcdefghijklm")
parts = message.scan(/.{16}/) #rot13
text_params = parts.map.with_index { |m, i|
y_pos = y + (i*10)
[i, x, y_pos]
"-fill orange -draw \"text #{x},#{y_pos} '#{m}'\""
@zmalltalker
zmalltalker / demo.rb
Created Dec 20, 2018
Callbacks, Ruby-style
View demo.rb
q1 = Question.new("What is the color of my eyes?", "blue")
q1.ask do |answer|
answer.correct { puts "Nice!" }
answer.incorrect { puts "LOL" }
end
View froken-ur.txt
#!/bin/sh
msg=`date +"Klokka er %H %M %S"`
say -v Nora $msg
View utm.py
import math, sys
def utm_to_lat_lng(easting, northing, zone=32, northernHemisphere=True):
"""Converts from utm to lat_lng. Default zone is the one in which
Oslo and Akershus falls."""
if not northernHemisphere:
northing = 10000000 - northing
a = 6378137
e = 0.081819191
e1sq = 0.006739497
View table.html
<HTML>
<HEAD>
</HEAD>
<BODY>
<TABLE WIDTH="100%" HEIGHT="100%" STYLE="BACKGROUND-COLOR:BLUE">
<TR>
<TD VALIGN="MIDDLE" ALIGN="CENTER">
YO
</TD>
</TR>
View table.html
<html>
<head>
</head>
<body>
<table width="100%" height="100%" style="background-color:blue">
<tr>
<td valign="middle" align="center">
Yo
</td>
</tr>
@zmalltalker
zmalltalker / android.xml
Created Apr 26, 2017
SVG from Sketch to Android
View android.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="31dp"
android:height="183dp"
android:viewportWidth="31"
android:viewportHeight="183">
<path
android:fillColor="#902e2e"
android:pathData="M0 0h31v183H0z " />
View json.go
type User struct {
CreatedAt time.Time `json:"created_at,string"`
UpdatedAt time.Time `json:"updated_at,string"`
FirstName string `json:"first_name,string"`
LastName string `json:"last_name,string"`
}
data = "{…json…}"
var u User
err := json.Unmarshal(data, &u)
You can’t perform that action at this time.