Skip to content

Instantly share code, notes, and snippets.

View vivithemage's full-sized avatar

Reza vivithemage

View GitHub Profile
@vivithemage
vivithemage / libmagic_example.c
Last active October 18, 2022 21:24
libmagic.h example
#include <stdio.h>
#include <magic.h>
int main(void)
{
char *actual_file = "/file/you/want.yay";
const char *magic_full;
magic_t magic_cookie;
/* MAGIC_MIME tells magic to return a mime of the file,
@james2doyle
james2doyle / getBrowser.php
Last active February 20, 2024 06:06
a PHP function to sniff the user agent of the browser and return a nice object with all the information
<?php
// http://www.php.net/manual/en/function.get-browser.php#101125
function getBrowser() {
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$bname = 'Unknown';
$platform = 'Unknown';
$version= "";
// First get the platform?
if (preg_match('/linux/i', $u_agent)) {