Skip to content

Instantly share code, notes, and snippets.

@AnthoniG
AnthoniG / app.py
Created July 18, 2022 14:26 — forked from carlos-jenkins/app.py
How to programatically add new menu items to menu item in PyGObject.
"""
Hierarchy is:
- GtkMenuBar
- GtkMenuItem
- GtkMenu
- GtkMenuItem
- GtkImageMenuItem
- GtkCheckMenuItem
- GtkRadioMenuItem
- GtkSeparatorMenuItem
@AnthoniG
AnthoniG / example.py
Created July 16, 2022 23:52
Python – CellRendererText in GTK+ 3
from gi.repository import Gtk
import gi
gi.require_version("Gtk", "3.0")
class CellRendererTextWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title ="Geeks For Geeks")
@AnthoniG
AnthoniG / mern-server-setup.md
Last active June 20, 2022 19:00 — forked from bradtraversy/mern-server-setup.md
Setup Ubuntu & Deploy MERN app

Brad's Youtube Duide

Linux Server Setup & MERN App Deployment

These are the steps to setup an Ubuntu server from scratch and deploy a MERN app with the PM2 process manager and Nginx. We are using Linode, but you could just as well use a different cloud provider or your own machine or VM.

Create an account at Linode

Click on Create Linode

Choose your server options (OS, region, etc)

@AnthoniG
AnthoniG / useLoaderStore.ts
Created June 7, 2022 00:05 — forked from andrelandgraf/useLoaderStore.ts
Wrapper hook for useMatches to quickly access loader data across components in Remix.run
import { useMatches } from 'remix';
// this base hook is used in other hooks to quickly search for specific data across all loaderData using useMatches
// see in action: https://codesandbox.io/s/usematches-loader-data-2h798?file=/app/db.server.ts
export default function useLoaderStore<T>(key: string): T | undefined {
const matchingRoutes = useMatches();
const route = matchingRoutes.find((route) => route.data && route.data[key]);
if (!route || !route.data || route.data[key] === undefined) {
return undefined;
}
@AnthoniG
AnthoniG / image.ts
Created May 25, 2022 17:49 — forked from jacob-ebey/image.ts
Remix Image Component
import { createHash } from "crypto";
import fs from "fs";
import fsp from "fs/promises";
import path from "path";
import https from "https";
import { PassThrough } from "stream";
import type { Readable } from "stream";
import type { LoaderFunction } from "remix";
import sharp from "sharp";
import type { Request as NodeRequest } from "@remix-run/node";
@AnthoniG
AnthoniG / sw-test-cleaup.js
Created May 3, 2022 10:52 — forked from gauntface/sw-test-cleaup.js
Function to unregister SW and clear out old caches.
window.__testCleanup = () => {
const unregisterSW = () => {
return navigator.serviceWorker.getRegistrations()
.then((registrations) => {
const unregisterPromise = registrations.map((registration) => {
return registration.unregister();
});
return Promise.all(unregisterPromise);
});
};
@AnthoniG
AnthoniG / Skrotlin.kt
Created April 22, 2022 15:11 — forked from marquesds/Skrotlin.kt
A simple web scraping with Kotlin
// Crawler.kt
import kotlinx.coroutines.*
import org.json.JSONObject
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
class Crawler {
@AnthoniG
AnthoniG / convert_bytes.php
Last active March 16, 2022 14:38 — forked from eusonlito/foldersize.php
PHP function to get the folder size including subfolders
function sizeFilter($bytes)
{
$label = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
for ($i = 0; $bytes >= 1024 && $i < (count($label) - 1); $bytes /= 1024, $i++) ;
return (round($bytes, 2) . " " . $label[$i]);
}
@AnthoniG
AnthoniG / AppServiceProvider.php
Created March 13, 2022 21:06 — forked from simonhamp/AppServiceProvider.php
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@AnthoniG
AnthoniG / mig-layout.java
Created March 7, 2022 18:00
Java Swing+MigLayout Tutorial - Simple Form
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;