Skip to content

Instantly share code, notes, and snippets.

View IliasDeros's full-sized avatar

Ilias Deros IliasDeros

View GitHub Profile
@IliasDeros
IliasDeros / machine.js
Created April 12, 2023 14:37
Generated by XState Viz: https://xstate.js.org/viz
// First step is "type" only when the order type was never selected
const newOrder = (context) => {
return !context.order.get('order_type')
};
// No order type selected
// No line-item errors
// No store selected for pickup
// No delivery day for delivery order
// No shipping fee for shipping order
@IliasDeros
IliasDeros / Dockerfile
Last active December 16, 2022 21:54
Run mongodb in memory on Docker without using TMPFS (https://github.com/docker-library/mongo/issues/224)
FROM node:16
RUN apt-get install libcurl4
WORKDIR /project
COPY ./db.mjs /project
RUN yarn add mongodb-memory-server
ENTRYPOINT ["node", "./in-memory-db.mjs"]
@IliasDeros
IliasDeros / reverse-proxy.conf
Last active May 31, 2022 20:08
Add HTTPS to your server using Nginx. Adapted from https://www.yeetpc.com/blog/nginx-reverse-proxy/
# /etc/nginx/sites-available/reverse-proxy.conf
server {
listen 80;
server_name yourdomain.com;
return 301 https://yourdomain.com$request_uri;
}
server {
listen 443 ssl;
server_name yourdomain.com;
@IliasDeros
IliasDeros / github_npm_publish_circleci__readme.md
Last active September 29, 2020 14:01
Set up a Github project to have CircleCI publish an npm patch
  1. From your local machine, generate an ssh key
ssh-keygen -m PEM -t rsa -C "[email protected]"
  1. Add the public key to your Github project's Deploy Keys
  2. Add the private key to your CircleCI project's SSH keys (set the domain to "github.com")
  3. Copy the fingerprint from the key you just added on CircleCI
  4. Paste that fingerprint in your .circleci/config.yml under steps > add_ssh_keys > fingerprints
@IliasDeros
IliasDeros / vscode_snippet_typescriptreact.json
Last active May 13, 2022 14:26
VSCode snippets. Add them in Preferences: Configure User snippets > typescriptreact.json
{
"React component test": {
"prefix": "react_test",
"body": [
"import React from 'react'",
"import { render } from '@testing-library/react'",
"import { $1 } from '../$1'",
"",
"describe('$1', () => {",
" let props",
@IliasDeros
IliasDeros / vscode_launch_ror_react.json
Last active June 17, 2022 01:18
A Ruby on Rails + React developer's common VSCode debug configurations
{
"version": "0.2.0",
"configurations": [
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rails",
"args": [
@IliasDeros
IliasDeros / shopify_pagination.liquid
Last active November 2, 2023 11:07
Shopify: Show all numbers in pagination, retaining query parameters. Inspired by: https://gist.github.com/kyleaparker/7588995
{% for part in (1..paginate.pages) %}
{% if forloop.index == 1 %}
{% if paginate.next.is_link %}
{%- assign next_page = current_page | plus: 1 -%}
{%- assign page_query_param_old = 'page=' | append: next_page -%}
{%- assign page_url_template = paginate.next.url -%}
{% elsif paginate.previous.is_link %}
{%- assign previous_page = current_page | minus: 1 -%}
{%- assign page_query_param_old = 'page=' | append: previous_page -%}
{%- assign page_url_template = paginate.previous.url -%}
@IliasDeros
IliasDeros / sidepots.js
Last active October 10, 2016 19:50
Calculate Poker side pots using this NodeJS script written in javascript ES6.
#!/usr/bin/env node
let players = process.argv.slice(2)
if (players.length < 2) return console.log('There has to be at least two players to calculate side-pots.')
players = players
// give each player a name
.map((p, i) => ({name: `Player ${i + 1}`, bet: p}))
// sort from lowest to highest