Skip to content

Instantly share code, notes, and snippets.

Avatar
🌊
All is well.

Giuseppe giuseppeg

🌊
All is well.
View GitHub Profile
View just.sublime-snippet
<snippet>
<content><![CDATA[
import ${1:just} from "just-${2:package}";
]]></content>
<tabTrigger>just</tabTrigger>
</snippet>
View NFTLoremIpsum.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract NFTLoremIpsum is ERC721, Ownable {
constructor() ERC721("Lorem Ipsum", "NFTLI") {}
uint public totalSupply;
View rotate-classnames.js
// setup
let classes = ['a','b','c']
let counter = 0
el.classList.add(classes[counter])
function rotate() {
counter++
el.classList.replace(
classes[(counter-1) % classes.length],
classes[(counter) % classes.length]
View mediarecorder-check-mimeType.js
window.navigator.mediaDevices
.getUserMedia({
audio: true,
video: false,
}).then(mediaStream => {
const rec = new MediaRecorder(mediaStream)
rec.start()
setTimeout(() => {
rec.stop()
alert('mime-type: ' + rec.mimeType)
View basic-security.md
  • Common setup for engineers with
    • laptop with encrypted hard drive
    • automatic updates (possibly forced, disabling delay)
    • password manager
    • 2FA everywhere
    • dedicated browser for development without extensions except for the ones approved by devsec ops
    • VPN to access internal properties
    • work (dedicate) GitHub account
    • rotate passwords and tokens / keys
  • remote dev machines on premise that can be kept secure and up to date by IT - might reduce chances to compromise engineer machine (accessible only via vpn)
View track-debugging-attempt.js
function track(name) {
const dummy = /./;
dummy.toString = () => {
alert(`${name} was debugged`);
return 'tracked';
};
return dummy;
}
function test() {
@giuseppeg
giuseppeg / dependabot.yml
Created Sep 5, 2021
github workflow (action) to update dependencis
View dependabot.yml
name: Update Dependencies
on:
schedule:
# https://crontab.guru/#0_0_*_*_WED,SAT
# Run every Wednesday and Saturday at 00:00
# 0 0 * * WED,SAT
- cron: '0 0 * * WED,SAT'
jobs:
dependabot:
View next-typed-api.ts
import { NextApiRequest as DefaultNextApiRequest, NextApiResponse } from "next";
/**
* // Route /pages/api/posts/[id]
*
* const api = defineApi<{ id: string }>()
* .get<{ query: { foo: "1" } }, "foo" | "bar">(
* async function handler(req, res) {
* const session = await getSession({ req });
* if (!session) {
View streaming-styles.jsx
import * as React from "react";
/*
Usage
import { Style } from "style";
function Heading({children}) {
return (
<>
<Style>{`h1 { color: red }`}</Style>
@giuseppeg
giuseppeg / lagcheck.mrc
Created Mar 23, 2021
Old mIRC script to check for lag I wrote when I was a teenager
View lagcheck.mrc
on 1:connect: {
if (%Lagchk == on) { .timerLAG 0 %Lag.secs lagcheck }
}
alias lagcheck { .ctcpreply $me LAGGC $ticks }
on *:CTCPREPLY:LAGGC*: { if ($nick == $me) { set %lag $round($calc((($ticks - $2) / 2) / 1000),2) | echo -a $timestamp lag: %lag $+ secs.. | halt } }
alias lag {
if ($1 == on) { /set %lagchk on | echo -a Lag Meter: on. | goto { end } }
if ($1 == off) { /set %lagchk off | echo -a Lag Meter: off. | goto { end } }
if ($1 == delay) { set %Lag.secs $2 | echo -a Lag Meter: checking every: $2 $+ secs. | goto { end } }