Skip to content

Instantly share code, notes, and snippets.

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

Massoud Asadi massoudasadi

🏠
Working from home
View GitHub Profile
@ncarandini
ncarandini / EditItem.razor
Last active February 17, 2022 07:21
[Blazor] Using IValidatableObject for form validation
<EditForm Model="@Item" OnValidSubmit="@(e => OnSave.InvokeAsync(Item))">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="form-group">
<label for="Title">Name:</label>
<InputText id="Title" @bind-Value="Item.name" class="form-control" />
</div>
<div class="form-group">
/*****************************************************
* This code was compiled and tested on Ubuntu 18.04.1
* with kernel version 4.15.0
*****************************************************/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
@yackx
yackx / hello-boot.asm
Created December 10, 2014 10:56
Hello World bootloader in assembly language
;----------------------------------------------;
;
; A minimal bootloader that prints a hello world
; then halts.
;
; nasm -f bin hello-boot.asm -o hello-boot.bin
;
; @YouriAckx
;
;----------------------------------------------;
@zupzup
zupzup / main.go
Created March 20, 2017 10:03
Go TCP Proxy / Port Forwarding Example (https://zupzup.org/go-port-forwarding/)
package main
import (
"flag"
"fmt"
"io"
"log"
"net"
"os"
"os/signal"
@leonid-ed
leonid-ed / udp_to_local.c
Last active July 10, 2023 15:36
Examples of using raw sockets (c, linux, raw socket)
/*
An example of using raw sockets.
You can capture packets by tcpdump:
tcpdump -X -s0 -i lo -p udp
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@montanaflynn
montanaflynn / context.go
Last active September 13, 2023 12:51
An example of using context to cancel goroutines between server handlers
package main
import (
"context"
"fmt"
"log"
"net/http"
"sync"
"time"
)
@geyslan
geyslan / shell_bind_tcp.asm
Last active October 7, 2023 10:00
Shell Bind TCP in Assembly (Linux/x86) - forlife
; This is a snippet of the original file in https://github.com/geyslan/SLAE/blob/master/1st.assignment/shell_bind_tcp.asm
global _start
section .text
_start:
; syscalls (/usr/include/asm/unistd_32.h)
; socketcall numbers (/usr/include/linux/net.h)
@oleksiiBobko
oleksiiBobko / tcp_server.c
Last active November 10, 2023 08:48
Simple socket server in C using threads (pthread library) Compiles on linux
/*
C socket server example, handles multiple clients using threads
Compile
gcc server.c -lpthread -o server
*/
#include<stdio.h>
#include<string.h> //strlen
#include<stdlib.h> //strlen
#include<sys/socket.h>
@aspyct
aspyct / signal.c
Last active February 19, 2024 11:24
Unix signal handling example in C, SIGINT, SIGALRM, SIGHUP...
/**
* More info?
* a.dotreppe@aspyct.org
* http://aspyct.org
*
* Hope it helps :)
*/
#include <stdio.h>
#include <stdlib.h>
@metafeather
metafeather / main.go
Created April 27, 2017 13:06
Get goroutine id for debugging
# ref: https://play.golang.org/p/OeEmT_CXyO
package main
import (
"fmt"
"runtime"
"strconv"
"strings"
"sync"
)