Skip to content

Instantly share code, notes, and snippets.

View rockwellll's full-sized avatar
🏠
Working from home

Ahmed Khattab rockwellll

🏠
Working from home
View GitHub Profile
@rockwellll
rockwellll / useUpdatableTimestamp.js
Last active September 23, 2022 09:04 — forked from shuber/date_helper.js
fuzzy timestamps, time ago in words
export const useUpdatableTimestamp = (controller) => {
return Object.assign(controller, {
timeAgoInWordsWithParsing(from) {
const date = new Date;
date.setTime(Date.parse(from));
return this.timeAgoInWords(date);
},
timeAgoInWords(from) {
return this.distanceOfTimeInWords(new Date(), from);
import { Controller } from "stimulus";
export default class extends Controller {
static targets = ["submit", "inputs" ];
static values = {
enabled: Boolean,
}
connect() {
if(this.enabledValue) {
frozen_string_literal: true
module Conversation::PgSearch
extend ActiveSupport::Concern
included do
include PgSearch::Model
pg_search_scope :where_participant_name_is, associated_against: {
contacts: %i[first_name last_name],
lists: :name
#!/usr/bin/env bash
# resetting and seeding the database
echo "[ bin/ci ] migrating the test database"
bin/rails db:migrate:reset RAILS_ENV=test
echo "[ bin/ci ] Running rspec tests"
bin/bundle exec rspec spec
class TodoFacade
include ActiveModel::Validations
attr_reader :todo_set, :todos
validates_presence_of :author
def initialize(todo_set:)
@todo_set = todo_set
@todos = @todo_set.books
import 'dart:convert' as json;
import 'package:dio/dio.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uni_capstone_project/models/patient.dart';
enum Result {
SUCCESS,
FAILED,
}
class CartService
include ActiveModel::Attributes
include ActiveModel::Validations
attr_accessor :cart
validates_presence_of :cart
def initialize(cart:)
@cart = cart
import 'dart:io';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:path_provider/path_provider.dart';
class FirebaseCloudWrapper {
FirebaseStorage _storage = FirebaseStorage(
storageBucket: "gs://sapphire-restaurant.appspot.com/",
def fizzbuzz(last_number:)
(1..last_number).each do |number|
if (number % 15).zero?
puts "FizzBuzz"
elsif (number % 5).zero?
puts "Buzz"
elsif(number % 3).zero?
puts "Fizz"
else
puts number
class MultiplicationTable
def initialize(from:, to:)
@from = from
@to = to
end
def print_multiplication_table
(@from..@to).each do |number|
puts multiplication_table_for number
end