Skip to content

Instantly share code, notes, and snippets.

View talaatmagdyx's full-sized avatar
🔧
code

TalaatMagdy talaatmagdyx

🔧
code
View GitHub Profile
@JoelQ
JoelQ / month.rb
Last active September 2, 2024 18:44
require "date"
class Month
include Comparable
MONTHS_PER_YEAR = 12
def self.from_date(date)
self.from_parts(date.year, date.month)
end
@sulmanweb
sulmanweb / create_document.rb
Created January 7, 2022 11:50
ActiveStorage, Ruby on Rails 7, GraphQL and RSpec
# app/graphql/mutations/create_document.rb
module Mutations
class CreateDocument < Mutations::BaseMutation
description "Create a document"
argument :doc, ApolloUploadServer::Upload, required: true, description: "The document to upload"
field :document, Types::Objects::DocumentType, null: false
field :code, Types::Enums::CodeEnum, null: false
@ryan-blunden
ryan-blunden / .env
Last active June 24, 2025 04:02
Python Application Config and Secrets Class
API_KEY="357A70FF-BFAA-4C6A-8289-9831DDFB2D3D"
HOSTNAME="0.0.0.0"
PORT="8080"
# Optional
# DEBUG="True"
# ENV="development"
@GlenCrawford
GlenCrawford / schema_dumper.rb
Created April 17, 2020 13:59
Patching Rails database schema dumps to support multiple PostgreSQL schemas.
# Overrides Rails file activerecord/lib/active_record/schema_dumper.rb to
# include all schema information in the db/schema.rb file, for example, in the
# create_table statements. This allows for a working development database
# to be built from a schema.rb file generated by rake db:schema:dump.
#
# This is essentially a rebuild of the "schema_plus_multischema" gem (which is
# unfortunately only compatible with Rails ~> 4.2).
#
# Tested with Rails 6.0.
@ingeniousgenius
ingeniousgenius / README.md
Last active December 15, 2025 22:37
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@matutter
matutter / sqla_bulk_update.py
Last active January 26, 2023 03:56
Shows a bulk update using SQLAlchemy ORM.
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Boolean, String
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///:memory:', echo=True)
session = sessionmaker(bind=engine)()
Base = declarative_base()
class User(Base):
@ai-ml-architect
ai-ml-architect / app.rb
Created January 6, 2020 12:13 — forked from kyktommy/app.rb
Behance Project Images downloader `ruby app.rb http://www.behance.net/gallery/Web-SPIT-Mx/10331815 ~/Desktop`
require 'nokogiri'
require 'open-uri'
class ImageFetcher
EXCLUDES = [
"http://a2.behance.net/img/site/grey.png"
]
def self.get_all_img_src(url)
using System;
using System.IO;
using System.Threading.Tasks;
using System.Net.Http;
namespace Example
{
public interface IImageDownloader
{
Task DownloadImageAsync(string directoryPath, string fileName, Uri uri);