Skip to content

Instantly share code, notes, and snippets.

View DiniFarb's full-sized avatar
💭
🦈

DiniFarb

💭
🦈
View GitHub Profile
@DiniFarb
DiniFarb / Program.cs
Last active January 6, 2024 10:06
C# Example for connecting Oracle DB via LDAP
using System;
using System.Configuration;
using System.Data;
using System.DirectoryServices;
using System.Text;
using Oracle.ManagedDataAccess.Client;
namespace ORACLE_LDAP_TEST
{
class Program
@DiniFarb
DiniFarb / asus.js
Created February 10, 2022 20:10
Fetch connection table from ASUS RT-AC88U router and serialize it do js object (JSON)
/**
* Fetch connection table from ASUS RT-AC88U router and serialize it do js object (JSON)
*/
import fetch from 'node-fetch';
import * as cheerio from 'cheerio';
const account = "<username>:<password>";
const router_ip = "<router ip>";
@DiniFarb
DiniFarb / print_object_props.cs
Created February 24, 2022 09:59
Print all properties and their values of an object in one line
using System;
using System.Linq;
public class Program
{
public static void Main()
{
var obj = new Test()
{
A = "HELLO",
@DiniFarb
DiniFarb / progressbar_terminal.go
Created June 30, 2022 18:47
terminal_progress_bar.go
func printProgressBar(iteration, total int, prefix, suffix string, length int, fill string) {
percent := float64(iteration) / float64(total)
filledLength := int(length * iteration / total)
end := ">"
if iteration == total {
end = "="
}
bar := strings.Repeat(fill, filledLength) + end + strings.Repeat("-", (length-filledLength))
fmt.Printf("\r%s [%s] %f%% %s", prefix, bar, percent, suffix)
@DiniFarb
DiniFarb / main.go
Last active September 3, 2022 12:30
go minimal web api
package main
import (
"flag"
"log"
nhttp "net/http"
"os"
"runtime"
"../cycletls"
@DiniFarb
DiniFarb / find-nas-id.go
Last active January 6, 2023 17:44
radius accounting tests
// get in radius packet attribute bytes = b[20:length]
func getNASId(b []byte) (string, error) {
for len(b) > 0 {
if len(b) < 2 {
return "", errors.New("short buffer")
}
length := int(b[1])
if length > len(b) || length < 2 || length > 255 {
return "", errors.New("invalid attribute length")
}
@DiniFarb
DiniFarb / main.go
Created January 30, 2023 17:45
accter http
package main
import (
"bytes"
"encoding/json"
"errors"
"net/http"
"os"
"strconv"