Skip to content

Instantly share code, notes, and snippets.

View loicnestler's full-sized avatar
🏠
Working from home

Loïc loicnestler

🏠
Working from home
View GitHub Profile
@loicnestler
loicnestler / make_the_world_a_better_place.md
Created April 20, 2023 19:55
I asked AgentGPT on how to make the world a better place.

Embarking on a new goal:Make the world a better place. Thinking...(Restart if this takes more than 30 seconds) Added task:Analyze global emissions data and create a comprehensive plan to reduce carbon footprint. Added task:Identify areas with high poverty rates and develop programs to provide job training and education opportunities. Added task:Research and implement solutions to improve access to clean water and sanitation in developing countries. Thinking...(Restart if this takes more than 30 seconds) Executing "Analyze global emissions data and create a comprehensive plan to reduce carbon footprint."

Executing task: Analyze global emissions data and create a comprehensive plan to reduce carbon footprint.

@loicnestler
loicnestler / ClassFor.ts
Created April 17, 2023 23:38
A utility function for creating a constructor signature out of a TypeScript type
export interface Type<Props, Args> extends Function {
new (args: Args): Props
}
export const ClassFor = <T extends object>(): Type<T, T> => {
const Class = function (options: T) {
for (const key in options) {
Class.prototype[key] = options[key]
}
}
@loicnestler
loicnestler / print_keys.js
Created April 13, 2022 22:11
Recursively print all keys of an object
const render = (obj, prefix = '') => {
Object.keys(obj).forEach((key, index) => {
if(obj[key]?.constructor === Object) return render(obj[key], `${prefix}${key}.`)
console.log(`${prefix}${key} ("${obj[key]}")`)
})
}
@loicnestler
loicnestler / date.scalar.ts
Created October 17, 2021 07:38
NestJS GraphQL Date Scalar
import { CustomScalar, Scalar } from '@nestjs/graphql';
import { Kind } from 'graphql';
@Scalar('Date', () => Date)
export class DateScalar implements CustomScalar<string, Date> {
description = 'Date custom scalar type';
parseValue(value: string): Date {
return new Date(value); // value from the client
}
#!/usr/bin/env zx
await $`cat package.json | grep name`
let branch = await $`git branch --show-current`
await $`dep deploy --branch=${branch}`
await Promise.all([
$`sleep 1; echo 1`,
$`sleep 2; echo 2`,
@loicnestler
loicnestler / macos_only_active_apps_in_dock.sh
Created April 9, 2021 13:43
MacOS only show active apps in dock
# by twitter.com/tmgBabul
defaults write com.apple.dock static-only -bool TRUE; killall Dock
@loicnestler
loicnestler / check-mailserver-for-openrelay.txt
Created February 7, 2021 19:11
Check mail server for OpenRelay
# Stolen from https://github.com/Mailu/Mailu/issues/1370#issuecomment-592447023
# $YOUR_PUBLIC_SERVER_IP = your mail server IP
# $YOUR_PUBLIC_SERVER_DOMAIN = your mail server domain (mail.example.org)
# $A_MAIL_NOT_MANAGED_BY_YOUR_SERVER = some mail address that is not managed by your mail server (for example a @gmail address)
$ nc -v $YOUR_PUBLIC_SERVER_IP
Ncat: Version 7.80 ( https://nmap.org/ncat )
Ncat: Connected to $YOUR_PUBLIC_SERVER_IP:25.
220 $YOUR_MAIL_SERVER_DOMAIN ESMTP ready
HELO $YOUR_MAIL_SERVER_DOMAIN

Keybase proof

I hereby claim:

  • I am loicnestler on github.
  • I am loicnestler (https://keybase.io/loicnestler) on keybase.
  • I have a public key ASB47QXq0Q6pSMvlLl7DotwLcLaEMIsfRYNs1S8gAkgoUAo

To claim this, I am signing this object: