This file contains 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
# Validates that MX record exists for domain to prevent typos and also block by MX servers | |
# Use by adding to app/models/user.rb | |
# validates_with EmailMXValidator, if: :email_changed? | |
# frozen_string_literal: true | |
require 'resolv' | |
class EmailMXValidator < ActiveModel::Validator | |
def validate(user) | |
domain = user.email.split('@', 2).last | |
mxs = Resolv::DNS.new.getresources(domain, Resolv::DNS::Resource::IN::MX).to_a.map { |e| e.exchange.to_s } |
This file contains 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
import 'dart:math' as math; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:flutter/widgets.dart'; | |
/// Signature for a function that creates a [TileSize] for a given index. | |
typedef TileSize IndexedTileSizeBuilder(int index); | |
/// Creates grid layouts with a fixed number of spans in the cross axis. |
This file contains 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
// Paste the code below into the JavaScript console while logged in to CloudPebble for | |
// a link to a zip file containing all your CloudPebble projects. | |
console.log("Requesting export..."); | |
Ajax.Post('/ide/transition/export', {}).then(function(data) { | |
console.log("Request result: "); | |
console.log(data); | |
console.log("Waiting for archive. This may take a long time."); | |
return Ajax.PollTask(data.task_id, {on_bad_request: console.error}); | |
}).then(function(result) { |
This file contains 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
// ==UserScript== | |
// @name thisandagain Summoner | |
// @namespace thisandagainPlsExplainThisPost | |
// @version 1.06 | |
// @description Adds a button to posts to magically summon thisandagain or thisandbatman | |
// @author Jonathan50 | |
// @match https://scratch.mit.edu/discuss/* | |
// @grant none | |
// ==/UserScript== |
This file contains 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
import SimpleHTTPServer | |
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def send_head(self): | |
"""Common code for GET and HEAD commands. | |
This sends the response code and MIME headers. | |
Return value is either a file object (which has to be copied | |
to the outputfile by the caller unless the command was HEAD, | |
and must be closed by the caller under all circumstances), or |