Skip to content

Instantly share code, notes, and snippets.

@AnthoniG
AnthoniG / OperandOverload.cpp
Created February 26, 2022 11:43
C++ Operator Overloading
#include <iostream>
#include<string>
#include<list>
using namespace std;
struct YouTubeChannel {
string Name;
int SubscribersCount;
@AnthoniG
AnthoniG / ascii-cypher-example.cpp
Created February 26, 2022 15:25
C++ file handling for beginners
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
fstream Myfile;
// Taking the input string from the user
@AnthoniG
AnthoniG / CMakeLists.txt
Created March 5, 2022 20:13 — forked from silvercircle/CMakeLists.txt
Sample CMake Qt Project for CLion
#
# sample CMakeLists.txt for a simple Qt project using CLion IDE
# shows how to use AUTOMOC, AUTOUIC
#
# sources are expected in source/
# includes in include/
#
cmake_minimum_required(VERSION 3.0)
set(TARGET_NAME Qttest)
@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;
@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 / 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 / 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 / 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 / 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 / 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;
}