Skip to content

Instantly share code, notes, and snippets.

@mohammed-io
mohammed-io / tailwind-jit-patch-plugin.ts
Created December 10, 2021 14:35
A patch to make the Vite HMR work with Tailwind JIT
import { utimes } from 'fs/promises'
import { debounce } from 'lodash'
import path from 'path'
import { ViteDevServer } from 'vite'
const touchFile = async path => {
const time = new Date()
return utimes(path, time, time)
}
from functools import wraps
def multi_format(default='json'):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
request = args[0]
request.match_format = lambda *args, **kwargs: _match_format(request, default_format=default, *args, **kwargs)
return func(*(request, *args[1:]), **kwargs)
'use strict'
const { useState, useCallback, useEffect } = React
const JobTitle = React.memo(function JobTitle(props) {
console.log('rendered')
return <h1>Hello, {props.name} {props.age}</h1>
})
@mohammed-io
mohammed-io / print_rx_resume.html
Created October 4, 2020 08:58
Prints the resume from rxresu.me
<a id="link" href="">Print Rx Resume</a>
<script id="js">
function init() {
if (window.location.host != 'rxresu.me') {
if (!confirm("This supposed to run on https://rxresu.me/.\nRun anyway?")) {
return;
}
}
<?php
namespace App\Concerns;
use Illuminate\Database\Eloquent\MassAssignmentException;
use Illuminate\Database\Eloquent\Model;
/**
* @package App\Concerns
* @mixin Model
@mohammed-io
mohammed-io / MultiFormatResult.cs
Last active August 21, 2019 13:25
A Multi-format response for ASP.net Core
/**
* Licensed under MIT license.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
const students = [
{firstName: 'Mohammed', lastName: 'Mwafaq', age: 24, married: false, avgScore: 79.3},
{firstName: 'Shaymaa', lastName: 'Adnan', age: 22, married: false, avgScore: 73.52},
{firstName: 'Sazgar', lastName: 'Omar', age: 22, married: false, avgScore: 75.39},
{firstName: 'Shakhawan', lastName: 'Shukr', age: 34, married: true, avgScore: null},
{firstName: 'Mahmood', lastName: 'Bashar', age: 29, married: false, avgScore: 70.2},
];
/**
* {name: 'Shakhawan', age: 34, married: true, avgScore: null},
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
var arrayOfFunctions = []
for (var i = 0; i < 5; i++) {
arrayOfFunctions.push( function () {
console.log(i);
});
}
arrayOfFunctions[0](); // Expected?
arrayOfFunctions[1](); // Expected?

ls command used to list files in a directory (folder)

Arguments:

-a     => Lists all files including hidden files (starts with .)

-l     => Long list (detailed)

-r => Reverse the order of the files