Skip to content

Instantly share code, notes, and snippets.

View Theodory's full-sized avatar
🥅

Theodory Faustine Theodory

🥅
  • Dar es salaam, Tanzania
  • 09:20 (UTC +03:00)
View GitHub Profile
@Theodory
Theodory / CreatesWithLock.php
Created November 22, 2022 07:34 — forked from troatie/CreatesWithLock.php
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}
@Theodory
Theodory / Snakes_n_Ladder_Game.php
Created November 14, 2021 18:51 — forked from nashjain/Snakes_n_Ladder_Game.php
Simple Snakes and Ladders Game Implemented in PHP
<?php
function new_game($players, $mode = 'Easy', $board_size = 100)
{
$game_modes = ["Easy" => 5, "Medium" => 10, "Hard" => 20];
$snakes_ladders = random_board($game_modes[$mode], $board_size);
play($players, $snakes_ladders, $board_size);
}
function play($players, $snakes_ladders, $board_size)
{
@Theodory
Theodory / app.js
Created August 18, 2021 14:51 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@Theodory
Theodory / datetimepicker.md
Last active March 30, 2021 08:01
Caught Type: exception datetimepicker()........ is not a function

To resolve eonasdan-bootstrap-datetimepicker with exception Caught Type: exception datetimepicker()........ is not a function. Bootstrap-datetimepicker is trying to use it's own jquery force it to use same version of jquery used by other node_modules, inside your webpack configurations file add this.

.webpackConfig({
        resolve: {
            alias: {
                 // Force all modules to use the same jquery version.
            'jquery': path.join(__dirname, 'node_modules/jquery/src/jquery')
 }
@Theodory
Theodory / README.md
Created October 4, 2019 07:07 — forked from roachhd/README.md
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄

@Theodory
Theodory / gist:2115373b2d4baab20371c025c48ebcc5
Created September 20, 2019 13:31 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@Theodory
Theodory / PaginationController.php
Created September 10, 2019 08:47 — forked from Repox/PaginationController.php
Laravel 5 Pagination with transform
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
class PaginationController extends Controller
{
@Theodory
Theodory / CanBeReplicated.php
Created June 12, 2019 13:30 — forked from mpociot/CanBeReplicated.php
Add the ability to replicate Laravel models to other models.
<?php
use Illuminate\Support\Arr;
trait CanBeReplicated
{
public function replicateTo(string $model, array $with = null, array $except = null)
{
$defaults = [
$this->getKeyName(),
@Theodory
Theodory / time_elapsed_string.php
Created December 8, 2017 13:00
time_elapsed_string.php
<?php
$timenow = time();
class LANG {
public function sprintf($string) {
$arg_list = func_get_args();
$num_args = count($arg_list);
for($i = 1; $i < $num_args; $i++)