Skip to content

Instantly share code, notes, and snippets.

@glenbray
glenbray / extract_addresses_batch_job.rb
Last active February 11, 2020 11:29
extract address jobs
class Scheduled::ExtractAddressesBatchJob
include Sidekiq::Worker
sidekiq_options lock: :until_and_while_executing
def perform
sites = Site
.select(:id)
.addresses_not_checked
.limit(10_000)
@glenbray
glenbray / doccano_to_google_automl_annotations.rb
Last active February 10, 2020 08:33
doccano to google automl annotations
Annotation = Struct.new(:label, :start_offset, :end_offset)
LABELS = { 1 => 'address', 3 => 'po_box' }
class Snippet
attr_reader :text, :annotations
def initialize(text: '', annotations:, **other)
@text = text
@annotations = annotations
import React from "react";
import { StyleSheet, Text, View, ScrollView } from "react-native";
import { List, ListItem, Badge } from "react-native-elements";
import ConfidenceBadge from "./ConfidenceBadge";
import ErrorMessage from "./ErrorMessage";
const textDetections = [
{
text: "the quick brown",
confidence: 89
import Amplify, { API } from "aws-amplify";
import awsExports from "./aws-exports";
Amplify.configure({
...awsExports,
API: {
endpoints: [
{
name: "rekognition",
endpoint: "https://rekognition.ap-southeast-2.amazonaws.com",
import React from "react";
import { StyleSheet, Text, View, TouchableOpacity } from "react-native";
import { Camera, Permissions } from "expo";
import { Icon } from "react-native-elements";
import TextDetectingCamera from "./src/TextDetectingCamera";
import DetectedTextList from "./src/DetectedTextList";
import ErrorMessage from "./src/ErrorMessage";
export default class App extends React.Component {
import React from "react";
import { StyleSheet, Text, View, TouchableOpacity } from "react-native";
import { Icon } from "react-native-elements";
import { Camera } from "expo";
import Loader from "./Loader";
class TextDetectingCamera extends React.Component {
state = { loading: false };
constructor(props) {
@glenbray
glenbray / ConfidenceBadge.js
Created June 17, 2018 15:52
text-reader-components
import React from "react";
import { Badge } from "react-native-elements";
const ConfidenceBadge = ({ confidence }) => {
let color = "green";
if (confidence < 80) color = "orange";
if (confidence < 60) color = "red";
return (
<Badge
@glenbray
glenbray / gist:8033328
Created December 19, 2013 02:16
Example of a mini c# orm to insert
public static void insertObjectMapper(string sProcName, List<T> entities)
{
Type type = typeof(T);
PropertyInfo[] properties = typeof(T).GetProperties();
string[] paramNames = null;
using (SqlCommand command = new SqlCommand(sProcName, Connection))
{
command.CommandType = CommandType.StoredProcedure;
SqlCommandBuilder.DeriveParameters(command);
@glenbray
glenbray / gist:8033318
Created December 19, 2013 02:15
Example of a mini orm for c# to load from database
public static List<T> loadFromReader(string sProcName)
{
List<T> EntityCollection = new List<T>();
Type type = typeof(T);
PropertyInfo[] properties = typeof(T).GetProperties();
using (Connection)
{
SqlCommand command = new SqlCommand(sProcName);
command.CommandType = CommandType.StoredProcedure;
@glenbray
glenbray / gist:6349624
Last active December 21, 2015 18:48
Project Euler Question 20
puts (1..100).inject(&:*).to_s.split("").map(&:to_i).inject(&:+)