Skip to content

Instantly share code, notes, and snippets.

@sidmitra
sidmitra / benchmark_serializers.py
Created October 10, 2021 01:30
Benchmark json/pickle/orjson/msgpack/ormsgpack serialization performance.
"""
Trying to see if there's a reasonably fast/safe replacement to the default pickle serializer
used by django-redis.
See https://github.com/jazzband/django-redis#pluggable-serializer
# Adapted from https://raw.githubusercontent.com/Arvind2222/pickle-vs-json/master/pickle_vs_json.py
"""
import pickle
import json
@tanthammar
tanthammar / Media.blade.php
Last active October 19, 2022 00:01
LiveWire Spatie Media Image upload with VueCroppa
<div id="media-comp" class="display-contents">
<media inline-template>
<form>
<div v-for="(image, index) in form" :key="index" @touchstart.stop @mousedown.stop class="col-span-6">
<h3 class="text-3xl font-medium">@{{ image.label }}</h3>
<p class="py-3">Allowed Width @{{image.width}}px, Height @{{image.height}}px, Max file size @{{image.maxFileSize}}</p>
<input v-model="image.value" wire:model="@{{ image.name }}" type="hidden">
<croppa v-model="image.model" :width="image.width" :height="image.height"
:placeholder="locale == 'sv' ? 'Välj en bild' : 'Choose an image'"
:accept="'image/*'" :file-size-limit="image.maxByte" :zoom-speed="3" :disable-drag-and-drop="false"
@davestewart
davestewart / helpers.js
Last active November 26, 2019 04:31
Vue "route helpers" example
/**
* Helper function to reduce boilerplate in route creation
*
* @param {string} path The route's path
* @param {object} page A page component definition
* @param {Function} page A function that returns a page import
* @param {string} page A string path to a file in the view/pages folder
* @param {object} attrs Any additional attributes
*/
export function route (path, page, attrs = {}) {
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active November 4, 2024 09:03
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@bradtraversy
bradtraversy / docker_wordpress.md
Last active November 17, 2024 13:34
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@HSPDev
HSPDev / AllowSSHFromIP.php
Created July 2, 2018 22:56
Complementary code and IAM policy for "You don't need that Bastion host"
<?php
// For laravel 5 based systems
// /path/to/project/app/Console/Commands/AllowSSHFromIP.php
namespace App\Console\Commands;
use Aws\Ec2\Ec2Client;
use Carbon\Carbon;
use Illuminate\Console\Command;
@nickrouty
nickrouty / rd-class-text-extraction.php
Created May 9, 2018 04:14
Class for extraction the text from doc, docx, xlsx, pptx and wrapper for 3rd party pdf to text library.
<?php
/**
* Class RD_Text_Extraction
*
* Example usage:
*
* $response = RD_Text_Extraction::convert_to_text($path_to_valid_file);
*
* For PDF text extraction, this class requires the Smalot\PdfParser\Parser class.

Taylor Otwell : Yeah, so at first, I had no intentions of splitting off and writing a framework. But you're right, one of the first projects I wrote was CI injector, CInject or something like that. I was actually pretty proud of that. It was actually the first reflection-based IOC container in PHP at all that I'm aware of. There was one other IOC container that was also written in 2010, a few months later. That was one of the main pieces of .NET/.MVC that I really like was the auto-resolving container. Laravel's container still works, basically, like that first CodeIgniter container did. The other thing I was really interested in was the better ORM for CodeIgniter, and I wanted to get those two things in ... oh, there was a third thing.

I wanted better templating, like Blade, where you have an @extends at the top, and then you define these sections that override the parent template section, stuff like that. Template inheritance. I remember the final straw, that I couldn't really continue with CodeIgniter any

@edilsoncichon
edilsoncichon / AWS_Single_LetsEncrypt.yaml
Last active March 19, 2021 17:29 — forked from tony-gutierrez/AWS_Single_LetsEncrypt.yaml
AWS Elastic Beanstalk .ebextensions config for single instance free SSL using letsencrypt certbot and Apache.
# Dont forget to set the env variable "CERT_DOMAIN", and either fill in your email below or use an env variable for that too.
# Also note that this config is using the LetsEncrypt staging server, remove the flag when ready!
# @source https://gist.github.com/tony-gutierrez/198988c34e020af0192bab543d35a62a#file-aws_single_letsencrypt-yaml-L2
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
@lyudmil-mitev
lyudmil-mitev / index.html
Last active May 2, 2024 13:41
CSS Transform Scale element to fit its parent
<html>
<head>
<title>CSS Transform Scale element to fit its parent</title>
<script src="scale2fit.js"></script>
<link rel="stylesheet" href="style.css"/>
<script>
(function(window) {
function main() {
const margin = 10;
requestAnimationFrame(function fitToParentOnResize() {