Skip to content

Instantly share code, notes, and snippets.

View mukunda-'s full-sized avatar

Mukunda Johnson mukunda-

View GitHub Profile
//-------------------------------------------------------------------------------------------------
@EventHandler( ignoreCancelled=true )
public void onPlayerPickupCookie( PlayerPickupItemEvent event ) {
ItemStack item = event.getItem().getItemStack();
if( item.getType() == Material.COOKIE ) {
if( !item.hasItemMeta() ) return;
if( !item.getItemMeta().hasDisplayName() ) return;
if( item.getItemMeta().getDisplayName().equals( "Pinata Candy" ) ) {
if( event.getPlayer().getInventory().contains( item ) ) {
event.setCancelled( true );
@mukunda-
mukunda- / gist:ffa824bbba5d7f572a77
Created September 13, 2014 06:58
Read element text with converted line breaks
// read element text with converted line breaks
function readText( element ) {
// invisible "workspace" element
mb = $('#magicbox');
// copy over the html, with replaced <br> tags
var content = $(element).html();
content = content.replace( /<br>/g, '[[br]]' );
mb.html( content );
@mukunda-
mukunda- / slinkedlist.h
Last active May 15, 2022 20:43
unique_ptr linked list
#pragma once
// Smart linked list.
namespace Util {
template <class T> class SLinkedList;
/// ---------------------------------------------------------------------------
/// Defines the links in an object. Objects added to a SLinkedList must
@mukunda-
mukunda- / build-lua-premake5.lua
Last active June 25, 2019 12:02
Premake5 script for compiling lua.
-------------------------------------------------------------------------------
-- WIN64 LUA buildscript.
-- Keep in mind that the working directory is /build/.
-------------------------------------------------------------------------------
-- Directory tree w/ outputs:
-- src Source files.
-- projects/library MSVC project files for building lua53.lib.
-- projects/interpreter MSVC project files for building lua.exe.
-- projects/compiler MSVC project files for building luac.exe.
// adder.go
package main
import (
"fmt"
"os"
"strconv"
"github.com/danishm/andornot/gates"
)
test code {
with a tab
}
@mukunda-
mukunda- / passhash.go
Created March 25, 2022 22:15
Argon2 password hashing in Go
// passhash.go
// * Argon2id password hashing.
//
// Copyright 2022 Mukunda Johnson
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
@mukunda-
mukunda- / certbot-auth-hook.py
Created July 23, 2022 21:43
Dreamhost Certbot DNS hook example
import requests, uuid, json, os, time
DREAMHOST_KEY = '<dreamhost API key>';
#----------------------------------------------------------------------------------------
def dh_request( **kwargs ):
params = kwargs
params["key"] = DREAMHOST_KEY
params["unique_id"] = str(uuid.uuid4())
params["format"] = "json"
@mukunda-
mukunda- / throttler.spec.ts
Created August 2, 2024 23:31
nestjs/throttler 6.x issue
import { Test } from "@nestjs/testing";
import { Controller, INestApplication, Post, UseGuards } from "@nestjs/common";
import * as supertest from "supertest";
import { Throttle, ThrottlerGuard, ThrottlerModule } from "@nestjs/throttler";
@Controller('test/throttle')
class ThrottleTestController {
@UseGuards(ThrottlerGuard)
@Throttle({ default: { limit: 1, ttl: 1000 } })