Skip to content

Instantly share code, notes, and snippets.

@jerieljan
jerieljan / How I Do PlantUML.md
Last active January 1, 2024 06:23
PlantUML with Style -- How I do PlantUML

I use PlantUML a lot. It's what I use for drawing all sorts of diagrams and it's handy because of its easy markup (once you get used to it) while making things easy to maintain as projects grow (thanks to version control)

This gist explains how I do my PlantUML workspace in a project.

  • The idea is to keep a globals directory for all diagrams to follow (like the "stylesheet" below) to keep things consistent.
  • I use a stylesheet.iuml file that keeps the use of colors consistent through use of basic FOREGROUND, BACKGROUND and ACCENT colors.
  • The style-presets.iuml file defines these colors so you can make "presets" or "themes" out of them.
  • As stated in the stylesheet.iuml, you'll need the Roboto Condensed and Inconsolata fonts for these to work properly.
  • You can choose to either run the PlantUML jar over your file/s, or use an IDE like VSCode with the PlantUML extension. Here's a preview of example-sequence.puml for example: https://imgur.com/Klk3w2F
@Youka
Youka / deque.ts
Created July 15, 2018 11:24
Double-ended queue (typescript)
// Linked data structure part
interface Node<T> {
previous: Node<T>,
value: T,
next: Node<T>
}
// Double-ended queue structure
class Deque<T> {
private first: Node<T> = null;
private last: Node<T> = null;
<!DOCTYPE html>
<html>
<head>
<title>Fireside Chat</title>
<link rel="stylesheet" href="/style/style.css">
</head>
<body>
<h1>Fireside Chat</h1>
<div id="app">
<div v-if="state == 0">
@stevebauman
stevebauman / Throttle.php
Last active October 27, 2023 14:02
Laravel Throttle Validation Rule
<?php
namespace App\Rules;
use Illuminate\Http\Request;
use Illuminate\Cache\RateLimiter;
use Illuminate\Contracts\Validation\Rule;
class Throttle implements Rule
{
@mrbar42
mrbar42 / README.md
Last active April 20, 2024 02:57
bash scripts to create VOD HLS stream with ffmpeg almighty (tested on Linux and OS X)

running:

bash create-vod-hls.sh beach.mkv

will produce:

    beach/
      |- playlist.m3u8
 |- 360p.m3u8
@drizzentic
drizzentic / index.php
Created July 19, 2016 14:20
Sample USSD Application
<!-- MIT License
Copyright (c) 2016 Derrick Rono
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@alexcorvi
alexcorvi / mime2ext.php
Created June 29, 2016 10:04
converting mime types to extension in php
function mime2ext($mime){
$all_mimes = '{"png":["image\/png","image\/x-png"],"bmp":["image\/bmp","image\/x-bmp","image\/x-bitmap","image\/x-xbitmap","image\/x-win-bitmap","image\/x-windows-bmp","image\/ms-bmp","image\/x-ms-bmp","application\/bmp","application\/x-bmp","application\/x-win-bitmap"],"gif":["image\/gif"],"jpeg":["image\/jpeg","image\/pjpeg"],"xspf":["application\/xspf+xml"],"vlc":["application\/videolan"],"wmv":["video\/x-ms-wmv","video\/x-ms-asf"],"au":["audio\/x-au"],"ac3":["audio\/ac3"],"flac":["audio\/x-flac"],"ogg":["audio\/ogg","video\/ogg","application\/ogg"],"kmz":["application\/vnd.google-earth.kmz"],"kml":["application\/vnd.google-earth.kml+xml"],"rtx":["text\/richtext"],"rtf":["text\/rtf"],"jar":["application\/java-archive","application\/x-java-application","application\/x-jar"],"zip":["application\/x-zip","application\/zip","application\/x-zip-compressed","application\/s-compressed","multipart\/x-zip"],"7zip":["application\/x-compressed"],"xml":["application\/xml","text\/xml"],"svg":

Nginx Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400,000 to 500,000 requests per second (clustered), most what i saw is 50,000 to 80,000 (non-clustered) requests per second and 30% CPU load, course, this was 2xIntel Xeon with HT enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

First, you will need to install nginx, my way to install nginx is compiling it from source, but for now we will use apt-get

@QuantumGhost
QuantumGhost / example.puml
Last active March 23, 2024 22:39
A simple template for PlantUML to draw ER diagram.The basic idea comes from http://plantuml.sourceforge.net/qa/?qa=331/database-modeling
@startuml
' uncomment the line below if you're using computer with a retina display
' skinparam dpi 300
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
' we use bold for primary key
' green color for unique
' and underscore for not_null
!define primary_key(x) <b>x</b>
!define unique(x) <color:green>x</color>
!define not_null(x) <u>x</u>
@petericebear
petericebear / .php_cs
Last active June 26, 2023 02:32
Laravel 5.x php-cs-fixer config file
<?php
$finder = Symfony\Component\Finder\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)