Skip to content

Instantly share code, notes, and snippets.

View dbilovd's full-sized avatar
💭
#StartingOver

David Lartey dbilovd

💭
#StartingOver
View GitHub Profile
@esdras-schonevald
esdras-schonevald / enum_sample.php
Created May 16, 2022 13:50
PHP ^8.1 ENUM - HOW TO USE
<?php
declare(strict_types=1);
/**
* This is a sample
* How to use Enum to create a custom exception cases
* PHP 8.1^
*/
@owen2345
owen2345 / remote_file_renamer.rb
Last active May 6, 2025 13:52
activestorage rename already uploaded files (Rails rename activestorage) Local and AWS storage support
# frozen_string_literal: true
module Storage
class RemoteFileRenamer < ApplicationService
attr_reader :file_blob, :new_name, :file
# @param file [ActiveStorage::File]
# @param new_name [String]
# @param variation [Symbol] Sample: :thumbnail
def initialize(file, new_name, variation = nil)
@mike1011
mike1011 / setup to make non-user model confirmable using rails devise
Last active January 28, 2024 13:02
Adding Rails Devise Confirmable module to a non-user model so that it can be confirmed
Use Case - Use Devise Confirmable module to confirm newly added organization(org) using email(association)
We want Three things to work -
Use confirmable - send_confirmation_instructions to send email when new org is added
Define Routes - organization_confirmation_url, so that user can use this route to confirm the org
Add confirmable columns inside existing organizations table, update token,timestamps on db
====== HERE WE START =========
- `organization.rb`
has_one :contact_detail ##contains email
@R3V1Z3
R3V1Z3 / vscode-snakecase-to-camelcase.md
Last active October 31, 2024 15:10
Convert all occurrences of snake_case to camelCase in VS Code. Windows/Linux walk-through here: https://youtu.be/vlHel1fN5_A

Convert snake_case to camelCase in VS Code

  • Press CTRL-H ( ⌥⌘F on Mac ).
  • Press ALT-R ( ⌥⌘R on Mac ).
  • Type _([a-zA-Z]).
  • Press TAB and type $1.
  • Press ALT-ENTER ( ⌥ENTER on Mac ).
  • Press F1 and type upper, then press ENTER.
  • Press CTRL-ALT-ENTER ( ⌥ENTER on Mac ).
<template>
<Page class="page">
<ActionBar class="action-bar" title="Miyha">
<NavigationButton text="Menu" icon="res://ic_list_black_24dp" @tap="toggleDrawer" />
<StackLayout orientation="horizontal">
<Image src="res://icon" width="40" height="40" verticalAlignment="center" />
<Label text="iyha" fontSize="24" verticalAlignment="center" />
</StackLayout>
</ActionBar>
<SideDrawer>
@akexorcist
akexorcist / index.js
Last active September 13, 2024 19:03
Axios post method requesting with x-www-form-urlencoded content type. See https://axios-http.com/docs/urlencoded
const axios = require('axios')
/* ... */
const params = new URLSearchParams()
params.append('name', 'Akexorcist')
params.append('age', '28')
params.append('position', 'Android Developer')
params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
params.append('awesome', true)
@oanhnn
oanhnn / how_to.md
Created May 14, 2017 16:47
How to fix composer error "Content-Length Mismatch"

First, run:

$ composer config --list --global        //this will get the composer home path.
[home] /root/.composer                   //it's my composer home path.

And then, edit the config.json in [home] directory, make it like this:

{
  "config": {
 "github-protocols": [

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "JSON API Schema",
"description": "This is a schema for responses in the JSON API format. For more, see http://jsonapi.org",
"oneOf": [
{
"$ref": "#/definitions/success"
},
{
"$ref": "#/definitions/failure"