This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "date" | |
| class Month | |
| include Comparable | |
| MONTHS_PER_YEAR = 12 | |
| def self.from_date(date) | |
| self.from_parts(date.year, date.month) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| API_KEY="357A70FF-BFAA-4C6A-8289-9831DDFB2D3D" | |
| HOSTNAME="0.0.0.0" | |
| PORT="8080" | |
| # Optional | |
| # DEBUG="True" | |
| # ENV="development" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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. |
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:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'nokogiri' | |
| require 'open-uri' | |
| class ImageFetcher | |
| EXCLUDES = [ | |
| "http://a2.behance.net/img/site/grey.png" | |
| ] | |
| def self.get_all_img_src(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
NewerOlder