Skip to content

Instantly share code, notes, and snippets.

View edbond's full-sized avatar
🗽
Working from home

Eduard Bondarenko edbond

🗽
Working from home
View GitHub Profile
@edbond
edbond / xor.clj
Created November 6, 2010 13:03
Xor macro in clojure, with tests
(ns xor
(:use clojure.test))
(defmacro xor
"Evaluates exprs one at a time, from left to right. If only one form returns
a logical true value (neither nil nor false), returns true. If more than one
value returns logical true or no value returns logical true, retuns a logical
false value. As soon as two logically true forms are encountered, no
remaining expression is evaluated. (xor) returns nil."
([] nil)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>UI</title>
<style type="text/css">
#loader {
min-height: 100vh;
display: flex;
@edbond
edbond / main.dart
Last active March 19, 2021 14:28
Obfuscate emails
String safeEmail(String email) {
final match = RegExp(r"(?<a>.?)(?<x>[^@]*)@(?<b>.)(?<y>.+?)(?<c>\..+)").firstMatch(email);
if (match == null) {
return email.replaceAll(RegExp(r"."), "*");
}
var sb = StringBuffer();
sb.write(match.namedGroup("a"));
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@edbond
edbond / transition_drawer.dart
Created April 16, 2020 08:01
Flutter Drawer
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class TransitionDrawer extends StatefulWidget {
final Widget child;
final StreamController<void> toggleStream;
TransitionDrawer({
@edbond
edbond / active_job_retry_controlable.rb
Last active February 5, 2020 09:46 — forked from necojackarc/active_job_retry_controlable.rb
To enable ActiveJob to control retry
module ActiveJobRetryControlable
extend ActiveSupport::Concern
DEFAULT_RETRY_LIMIT = 5
class_methods do
def retry_limit(retry_limit)
@retry_limit = retry_limit
end
import 'package:puppeteer/puppeteer.dart';
import "package:test/test.dart";
cityAutocomplete(Browser browser) {
test("City Autocomplete include New York", () async {
// Open a new tab
var page = await browser.newPage();
// Go to a page and wait to be fully loaded
await page.goto(...);
@edbond
edbond / doc.md
Last active September 9, 2018 08:54
external JS with react-native, clojurescript and re-natal
@edbond
edbond / arrvsset.rb
Created March 29, 2018 20:12
Array include vs Set include
# frozen_string_literal: true
require 'set'
require 'benchmark/ips'
ARRAY = 100_000.times.map(&:itself)
SET = Set.new(ARRAY)
def array_include?
ARRAY.include?(50_000)
Rails.application.config.after_initialize do
ActiveSupport.on_load(:active_record) do
oid = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID
# https://github.com/rails/rails/blob/v4.2.3/activerecord/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
oid::Jsonb = Class.new(oid::Json) do
def type
:jsonb
end