- Twitter: @matiaskorhonen.fi
- GitHub: matiaskorhonen
- Email: [email protected]
- Web: matiaskorhonen.fi
- Blog: randomerrata.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"> <title>Offline for maintenance</title> <style>html, body { | |
font-family: sans-serif; | |
-ms-text-size-adjust: 100%; | |
-webkit-text-size-adjust: 100%; | |
background-color: #F7F8FB; | |
height: 100%; | |
-webkit-font-smoothing: antialiased; } | |
body { |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20;91;Prologue;ID=9600;TEMP=0104; | |
20;A0;Oregon TempHygro;ID=CC1D;TEMP=00fb;HUM=45;HSTATUS=0;BAT=OK; | |
20;A1;Prologue;ID=9600;TEMP=0104; | |
20;A2;Alecto V1;ID=0168;TEMP=0080;HUM=32;BAT=OK; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert signed hexadecimals from RFLink to floats | |
def signed_to_float(hex) | |
int = hex.to_i(16) | |
if int & 0x8000 > 0 | |
-(int & 0x7FFF).to_f / 10 | |
else | |
int.to_f / 10 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the Scheduler frequency to Hourly | |
if [[ $(TZ=Europe/Helsinki date +%H) = 07 ]] ; then echo "Do the thing!" ; else echo "Not 7am" ; fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "dnsruby" | |
rescue LoadError | |
puts "gem install dnsruby" | |
end | |
require "yaml/store" | |
include Dnsruby | |
trap("SIGINT") { exit 1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:8080 { | |
# Redirect only when the requested host *isn't* an IP address | |
redir 301 { | |
if {hostonly} not_match ^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$ | |
if {hostonly} not_match ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ | |
if_op and | |
http://www.{hostonly}{uri} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "fileutils" | |
require "json" | |
json = File.open("Contents.json", "r+") | |
contents = JSON.load(json.read) | |
contents["images"].map do |image| | |
ext = File.extname(image["filename"]) | |
new_filename = "#{image["size"]}@#{image["scale"]}#{ext}" | |
FileUtils.mv(image["filename"], new_filename) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthenticationToken | |
# Encode a hash | |
def self.encode(payload, ttl: 14.days.to_i) | |
keygen = ActiveSupport::KeyGenerator.new(Rails.application.secrets.token_secret) | |
key = keygen.generate_key(Rails.application.secrets.token_salt, 32) | |
crypt = ActiveSupport::MessageEncryptor.new(key) | |
payload[:expires] = ttl.seconds.from_now.to_i | |
crypt.encrypt_and_sign(JSON.dump(payload.deep_stringify_keys)) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// matches polyfill | |
this.Element && function(ElementPrototype) { | |
ElementPrototype.matches = ElementPrototype.matches || | |
ElementPrototype.matchesSelector || | |
ElementPrototype.webkitMatchesSelector || | |
ElementPrototype.msMatchesSelector || | |
function(selector) { | |
var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1; | |
while (nodes[++i] && nodes[i] != node); | |
return !!nodes[i]; |