Skip to content

Instantly share code, notes, and snippets.

@neotam
neotam / main.go
Created June 13, 2023 19:12
GO Program to dump HTTP requests with headers and body
// Author: neotam
// https://neot.am
// MIT License
package main
import (
"fmt"
"io/ioutil"
"net/http"
def printArgsByKind(a, b, c, default=None, intype=int, *more, operation, print_result=False, return_type, ignore_exceptions=True, **kwargs):
print("Regular Positional Arguments a: {}, b: {}, c: {}".format(a, b, c))
print("Default Arguments default: {}, intype: {}".format(default, intype) )
print("Variable length positional arguments(tuple) more: {}".format(more))
print("Non-Default Keyword-Only Arguments operation: {}, return_type: {}".format(operation, return_type))
print("Default Keyword-Only Arguments print_result: {}, ignore_exception: {}".format(print_result, ignore_exceptions))
print("Variable length keyword arguments kwargs: {}".format(kwargs))
def foo(a, b, c, /, x, y, z="default", *, name, operation, **kwargs):
print(f"Position-only parameters {a}, {b}, {c}")
print(f"Positional or Keyword arguments {x}, {y}, {z}")
print(f"Keyword Only Arguments {name}, {operation}")
print(f"Variable length keyword arguments {kwargs}") #Since params left to / are not keywords those parameter names remain avaialbe in kwargs
print("{:^80}".format("_"*50))
#Valid Function Calls
foo(1, 3, 4, 8, 9, 2, name="test", operation="noop")
// https://neot.am
// Verifying if given year is leap year using switch wityout expression syntax
package main
import "fmt"
func main() {
var n int
fmt.Printf("Enter year: ")
package main
import "fmt"
func main() {
var n int
fmt.Printf("Enter year: ")
fmt.Scanf("%d", &n)
if n%4 == 0 {
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Information {
String name();
String description();
public enum BrandColor {
RED("#FF0000"), GREEN("#00FF00"), BLUE("#0000FF"),
NAVY("000080"), CORAL("#FF7F50"), LINEN("#FAF0E6"),
SESASHELL("#FFF5EE"), STEELBLUE("#4682B4");
private final String hexcode;
BrandColor(String hexcode) {
this.hexcode = hexcode;
}
public interface GameInterface extends Runnable, Closeable {
int MAXLIFES = 3;
String APISERVER = "https://api.example.com/v1/";
void start();
void pause();
void pause(double seconds);
int score(int playerID);
}
public class Student {
private int rollno;
private String lname;
private String fname;
protected int section;
private Map<String, Double> marks = new HashMap<>();
Student(int rollno, String fname, String lname, int section){
this.rollno = rollno;
this.fname = fname;
/*
Site: https://getkt.com
Print 32-bit HexDecimal Memory representation
*/
#include <stdio.h>
void dumpMemRep(char *ptr, int n) {
for(int i=0; i < n; i++)
printf(" %.2x", ptr[i]);