Skip to content

Instantly share code, notes, and snippets.

View charlie-nguyen-goldenowl-zz's full-sized avatar
🚀
Focusing

C charlie-nguyen-goldenowl-zz

🚀
Focusing
  • Golden Owl Company
  • Ho Chi Minh
View GitHub Profile
@kkbt
kkbt / mk_mwe.zsh
Created January 1, 2022 05:48
Script to reproduce the problem in Laravel / tenancy ("There is no active transaction")
#!/bin/zsh
set -e # exit on error
# zsh running an a Mac
new_server_dir='server_mwe'
# Create fresh Laravel installation
rm -rf $new_server_dir
<?php
namespace App\Services\Dto;
abstract class AbstractDto
{
/**
* AbstractRequestDto constructor.
* @param array $data
*/
@earth774
earth774 / Controller.php
Created March 12, 2019 05:07
create upload image in lumen
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
public function uploadImage(Request $request)
@Agoreddah
Agoreddah / encrypter.js
Last active October 2, 2024 07:13
Laravel encrypt & decrypt in Node.js
// load variables
require('dotenv').config();
// load dependencies
const crypto = require('crypto');
'use strict';
const APP_KEY = process.env.APP_KEY;
@tim545
tim545 / lg-jquery-app-struct.md
Last active November 16, 2024 15:17
Structuring a large jQuery application

Structuring a large jQuery application

This document assumes you are building a traditional backend-heavy application as opposed to a frontend-heavy appliction which would typically use a framework like Angular or React. The use of these frameworks make this document irrelevant, however also require a change to your application architecture and a much larger overhead in order to get content onto a page, so as a simple way to build interactive web content a simple jquery based js stack will do fine.

Directory structure

It's important you use a directory structure which is impartial to your development environment, chosen server language (Python v. Java v. C# ...), and styling framwork (Twitter Bootstrap etc). This layer of separation means you can swap out the styles or the backend with minimal changes to the Js, simple and maintainable.

Here's an example from the project root:

@RuGa
RuGa / massInsertOrUpdate.php
Last active June 3, 2024 15:50
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@IsaacVanName
IsaacVanName / PHP Method Chaining from Constructor
Created December 23, 2010 17:39
PHP Method Chaining from Constructor
/*
new MyClass->my_method() isn't possible. However, there are a couple of solutions, of which the best seems to be the most unlikely as well.
****
Note: Make sure you read/skim to the end, even if you figure out the first solution quickly
(which you should). The second solution has a bit of brief research to go along with it! :-)
****
At times, it can be useful to have a class that maintains state long enough to complete a
cycle, but doesn't get stored in memory. No extra baggage needed, right?