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 / 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>UI</title>
<style type="text/css">
#loader {
min-height: 100vh;
display: flex;
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 / 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
@edbond
edbond / spyke.rb
Created June 29, 2017 13:26
Spyke
class JSONParser < Faraday::Response::Middleware
def parse(body)
json = MultiJson.load(body, symbolize_keys: true)
{
data: json[:result],
metadata: json[:extra],
errors: json[:errors]
}
@edbond
edbond / doc.md
Last active September 9, 2018 08:54
external JS with react-native, clojurescript and re-natal