Skip to content

Instantly share code, notes, and snippets.

@dangovorenefekt
dangovorenefekt / blockmetatwitter.md
Last active July 5, 2024 08:04
Block Meta and Twitter (nginx)
@jose-mdz
jose-mdz / README.md
Last active July 16, 2024 20:42
Orthogonal Diagram Connector

Orthogonal Connectors

This algorithm returns the points that form an orthogonal path between two rectangles.

How to Use

// Define shapes
const shapeA = {left: 50,  top: 50, width: 100, height: 100};
const shapeB = {left: 200, top: 200, width: 50, height: 100};
@pedromschmitt
pedromschmitt / conf-server-and-deploy-rails.md
Last active November 21, 2023 21:42
Setting up a new server and deploy Ruby

Setting up a new server and deploy Ruby on Rails project with Capistrano on VPS (Digital Ocean/Hetzner/etc)

This use Rails 5 or 6, RVM and Puma.

If you want to deploy with RBenv and Passenger, take a look at Phyl Smy script https://github.com/philsmy/cable-guy-example/blob/main/SetUpServer.txt and his video where he recorded each step https://www.youtube.com/watch?v=CZtYDplotiI&t=1s

If you need to deploy to a EC2 on AWS, check this video of how to create the server first: https://www.youtube.com/watch?v=M0avxObh8J8

Script

Dependencies

# One can write a class that wraps a Proc and calls it:
class Handler
def initialize(&@proc : -> String)
end
def call
@proc.call
end
end
@Robert-96
Robert-96 / README.md
Last active May 4, 2024 06:05
Ember.Js: Installing Tailwind CSS

Ember.Js: Installing Tailwind CSS

TL;DR

$ ember install ember-cli-postcss                   # Install ember-cli-postcss
$ npm install --save-dev tailwindcss                # Install tailwindcss

$ npx tailwind init app/styles/tailwind.config.js   # Optional: Generate a Tailwind config file for your project  
$ npm install -save-dev postcss-import # Optional: If you want to use the @import statement
@firejox
firejox / LL(1)-pg.cr
Created November 8, 2019 12:50
LL(1) parser generator
annotation ParserAttr
end
annotation TopSymbolAttr
end
annotation SymbolAttr
end
annotation Rule
@firejox
firejox / solution-1.cr
Last active June 8, 2020 05:47
The changes about prevent leaking container_of globaly
# channel.cr
class Channel(T)
struct Sender(T)
@link : Crystal::StaticList
end
Crystal::StaticList.container_of(ptr, Channel::Sender(T), @link)
end
# crystal/static_list.cr
@bcardiff
bcardiff / channel-select.md
Created October 8, 2019 20:11
Blocking and non-blocking channel actions

Blocking and non-blocking channel actions

Channel#receive vs Channel#receive? differs on their behavior for closed channels. Using them directly is always blocking.

Performing an operation over a closed and closing the channel during the operation must behave in the same way.

Channel#receive

@greggman
greggman / mousepos.js
Created August 29, 2019 15:45
Get element relative mouse position
// use clientX, clientY
someElement.addEventListener('mousemove', (e) => {
const rect = someElement.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
}
// the problem with clientX, clientY is they don't work with CSS transforms.
// The core app code
var myApp = (function () {
'use strict';
// Create a public methods object
var methods = {};
/**
* Extend the public methods object