Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Muhammad Sumon Molla Selim SumonMSelim

🎯
Focusing
View GitHub Profile
@imasif
imasif / exportDB.sh
Last active Jun 22, 2020
Export mongodb database into JSON files, and import the JSON again.
View exportDB.sh
#!/bin/bash
if [ ! $1 ]; then
echo " Example of use: $0 database_name dir_to_store"
exit 1
fi
db=$1
out_dir=$2
if [ ! $out_dir ]; then
out_dir="./"
@mugli
mugli / anmeldung-termin-notifier.sh
Last active Oct 20, 2020
Little bash script to repeatedly check if any appointment slot is available for Anmeldung (apartment registration) in Berlin
View anmeldung-termin-notifier.sh
#!/bin/bash
# Check if xidell is present (required for extracting from webpage using xpath)
if ! command -v xidel &> /dev/null
then
printf "\n\nCould not find xidel \n\n"
echo "You can install it with (on a mac):"
echo "brew install xidel"
exit
fi
@reinink
reinink / query.sql
Last active Apr 21, 2021
Text search across multiple tables using MySQL
View query.sql
select
first_name,
last_name
from
users
left join
companies on companies.id = users.company_id
where (
companies.name like 'TERM%' or
first_name like 'TERM%' or
@zspine
zspine / Money.php
Created Apr 10, 2020
Doctrine brick money value object
View Money.php
<?php
namespace App\Entity\Embeddable;
use App\Model\Intl\MoneyInterface;
use Brick\Math\BigNumber;
use Brick\Math\Exception\NumberFormatException;
use Brick\Math\RoundingMode;
use Brick\Money\Context\CustomContext;
use Doctrine\ORM\Mapping as ORM;
@rubenvanassche
rubenvanassche / tests.yml
Last active Mar 26, 2021
A simple Laravel testing workflow for GitHub Actions
View tests.yml
name: Tests (PHP)
on: [push]
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
@ralphschindler
ralphschindler / SnapshotCommand.php
Created Jul 11, 2019
An example Laravel app command to create and load database snapshots using S3
View SnapshotCommand.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class SnapshotCommand extends Command
{
@theanam
theanam / logger.js
Created Apr 5, 2019
Stdout logs on Steroids
View logger.js
const moment = require('moment');
const colors = {
"green" :"\x1b[32m",
"yellow":"\x1b[33m%s\x1b[0m",
"red":"\x1b[31m",
"cyan":"\x1b[36m",
"blue":"\x1b[34m",
"default":""
}
module.exports = function (message,color="default"){
View controller.php
public function index(Request $request)
{
$sortBy = 'id';
$orderBy = 'desc';
$perPage = 20;
$q = null;
if ($request->has('orderBy')) $orderBy = $request->query('orderBy');
if ($request->has('sortBy')) $sortBy = $request->query('sortBy');
if ($request->has('perPage')) $perPage = $request->query('perPage');
@marufmax
marufmax / App\Exceptions\Handler.php
Last active Dec 17, 2018
Laravel/Lumen API Error Handleing
View App\Exceptions\Handler.php
<?php
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
View functions.php
<?php
// Visual composer get terms on dropdown params
if( !function_exists('vcdd_get_terms') ){
function vcdd_get_terms( $taxonomy = 'category' ){
$get_categories = get_categories( array(
'taxonomy' => $taxonomy,
) );
foreach ( $get_categories as $category ) {
$categories[] = [ $category->term_id => $category->name ];
}