Skip to content

Instantly share code, notes, and snippets.

View blopa's full-sized avatar
🏴‍☠️

Pablo Benmaman blopa

🏴‍☠️
View GitHub Profile
@blopa
blopa / test.py
Created October 10, 2016 01:32 — forked from JosXa/test.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Simple Bot to reply to Telegram messages
# This program is dedicated to the public domain under the CC0 license.
"""
This Bot uses the Updater class to handle the bot.
First, a few handler functions are defined. Then, those functions are passed to
the Dispatcher and registered at their respective places.
Then, the bot is started and runs until we press Ctrl-C on the command line.
@blopa
blopa / phaser3.sbx
Created December 28, 2019 19:34
Phaser 3 ShoeBox .sbx configuration
::ShoeBox:shoebox.plugin.spriteSheet::PluginCreateSpriteSheet:{
"fileFormatLoop":"\\t{\\n\\t\\t\"filename\":\"@id\", \\n\\t\\t\"frame\": {\"x\":@x, \"y\":@y, \"w\":@w, \"h\":@h},\\n\\t\\t\"anchor\": {\"x\":0,\"y\":1}\\n\\t}@,\\n",
"texCropAlpha":true,
"fileFormatOuter":"{\\n\"frames\": [\\n@loop\\n],\\n\"meta\": {\\n\\t\"size\": {\"w\": @W, \"h\": @H},\\n\\t\"scale\": \"1\"\\n}\\n}",
"useCssOverHack":false,
"fileName":"sprites.js",
"texPadding":1,
"texExtrudeSize":0,
"scale":1,
"renderDebugLayer":false,
// code by https://www.nayuki.io/res/convex-hull-algorithm/convex-hull.js
// Returns a new array of points representing the convex hull of
// the given set of points. The convex hull excludes collinear points.
// This algorithm runs in O(n log n) time.
// eslint-disable-next-line import/prefer-default-export
export const makeHull = (points) => {
const newPoints = points.slice();
newPoints.sort(comparePoints);
return makeHullPresorted(newPoints);
};
@blopa
blopa / Matrix.jsx
Last active August 17, 2023 14:06
Matrix Rain effect with a React functional hooks component
import React, { useEffect, useRef } from 'react';
function MatrixBackground({ timeout = 50 }) {
const canvas = useRef();
useEffect(() => {
const context = canvas.current.getContext('2d');
const width = document.body.offsetWidth;
const height = document.body.offsetHeight;
class HtmlFileInput {
constructor({
scene,
spriteKey,
}) {
// Phaser's parent HTML element
const mainElement = scene.sys.game.canvas.parentElement;
// create html input type
const fileInput = document.createElement('input');
@blopa
blopa / jekyll-markdown-script.py
Created April 17, 2021 14:34
jekyll-markdown-script.py
from bs4 import BeautifulSoup
import unidecode
import pprint
import json
import yaml
import os
PHP_ARRAYS = "<?php $redirect_map = ["
TAGS = []
CATEGORIES = []
export const pageQuery = graphql`
query Posts($locale: String) {
allMarkdownRemark(
filter: {
fields: { locale: { eq: $locale } }
frontmatter: { show: { eq: true } }
}
sort: { fields: [frontmatter___date], order: DESC }
) {
edges {
module.exports = {
...config,
plugins: [{
resolve: 'gatsby-plugin-intl',
options: {
path: `${__dirname}/src/intl`,
languages: ['en', 'pt-br'],
defaultLanguage: 'en',
redirect: true,
redirectComponent: require.resolve('./src/utils/redirect.js'),
name: Deploy to GitHub Pages
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
@blopa
blopa / generate-atlas-files.js
Created June 20, 2021 12:30
Generate Atlas Sprites for Phaser using Node script
/* eslint-disable import/no-extraneous-dependencies */
const { packAsync } = require('free-tex-packer-core');
const path = require('path');
const { readFileSync, readdirSync, writeFileSync } = require('fs');
const SOURCE_SPRITES_PATH = path.resolve(__dirname, 'original-files', 'sprites');
const SPRITES_PATH = path.resolve(__dirname, 'assets', 'sprites');
// TODO make it possible to generate only one new asset with `node generate-atlas-files.js assetName`
async function generateAtlasFiles(assetName = null) {