Skip to content

Instantly share code, notes, and snippets.

View Theodory's full-sized avatar
🥅

Theodory Faustine Theodory

🥅
  • Dar es salaam, Tanzania
  • 10:31 (UTC +03:00)
View GitHub Profile
@mpociot
mpociot / CanBeReplicated.php
Created June 12, 2019 12:32
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(),
@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
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);
});
}
@drakakisgeo
drakakisgeo / select2-remove-border-radius.css
Created November 7, 2017 14:39
Remove 4px border-radius from Select2
.select2 {
border-color:1px solid #cacaca;
box-shadow: inset 0 1px 2px rgba(10, 10, 10, 0.1);
background-color:#fefefe;
}
.select2-dropdown, .select2-container--default .select2-selection--single ,
.select2-container--default .select2-selection--multiple, .select2-container--default .select2-selection--multiple .select2-selection__choice,
.select2-container--classic .select2-selection--multiple , .select2-container--classic .select2-selection--multiple,
.select2-container--classic .select2-selection--multiple .select2-selection__choice, .select2-dropdown,
@rohitrawat
rohitrawat / sources.list
Created June 12, 2017 18:17
Ubuntu 16.04 Xenial default /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
@Repox
Repox / PaginationController.php
Created November 3, 2016 11:05
Laravel 5 Pagination with transform
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
class PaginationController extends Controller
{
@nashjain
nashjain / Snakes_n_Ladder_Game.php
Created September 13, 2015 02:12
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)
{
@roachhd
roachhd / README.md
Last active May 1, 2024 22:17
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: 😄