Skip to content

Instantly share code, notes, and snippets.

View nsouto's full-sized avatar

Nuno Souto nsouto

View GitHub Profile
/* Apply a default duration to all .transition classes */
[class*="transition"] {
@apply duration-300;
}
/* Default transition class must come _before_ utilities,
so it can be overridden by any .duration-x utilities */
@tailwind utilities;
<html>
<head>
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.js" defer></script>
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<script>
function imageData() {
return {
previewUrl: '',
updatePreview() {
var reader, files = document.getElementById('thumbnail').files;
@mattstauffer
mattstauffer / example.html
Created March 3, 2020 15:46
Example of logging Laravel Livewiure component state
<script src="{{ asset('js/app.js') }}"></script>
<script>
let logComponentsData = function () {
window.livewire.components.components().forEach(component => {
console.log(component.name);
console.log(component.data);
});
};
document.addEventListener("livewire:load", function(event) {
@calebporzio
calebporzio / tinker_helper.php
Created January 30, 2019 23:56
A quick, memorable way to initiate an "artisan tinker" session and play with variables.
<?php
function tinker(...$args) {
// Because there is no way of knowing what variable names
// the caller of this function used with the php run-time,
// we have to get clever. My solution is to peek at the
// stack trace, open up the file that called "tinker()"
// and parse out any variable names, so I can load
// them in the tinker shell and preserve their names.
@calebporzio
calebporzio / chain_helper.php
Last active July 23, 2023 04:27
Handy "chain()" helper method for making non-fluent classes/objects fluent.
<?php
function chain($object)
{
return new class ($object) {
protected $lastReturn = null;
public function __construct($object)
{
$this->wrapped = $object;
@calebporzio
calebporzio / HiddenInput.vue
Created May 2, 2018 14:47
Little Vue component for turning JSON into native HTML for inputs
<script>
import _ from 'lodash'
export default {
props: [ 'name', 'value' ],
methods: {
flatInputsFromDeepJson(item, key, h) {
if (typeof item === 'object') {
return _.flatMapDeep(item, (value, newKey) => {
@adamwathan
adamwathan / 1-add-macros.php
Last active June 11, 2022 19:55
Multiformat Endpoints in Laravel
<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\ServiceProvider;
use App\Http\Middleware\CaptureRequestExtension;
class AppServiceProvider extends ServiceProvider
@adamwathan
adamwathan / vue.sublime-snippet
Created February 5, 2018 20:24
Vue Component Snippet for Sublime
<snippet>
<content><![CDATA[
<template>
${0}
</template>
<script>
export default {
props: [${1}],
data() {
@levelsio
levelsio / btc-eth-dca-buy.php
Last active January 21, 2025 12:12
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
@calebporzio
calebporzio / timer_helpers.php
Last active August 18, 2019 00:07
A simple helper function and macro for timing php scripts and eloquent queries
<?php
// Helper function.
if (! function_exists('timer')) {
function timer($expression)
{
$start = microtime(true);
if ($expression instanceof Closure) {
$expression();