Skip to content

Instantly share code, notes, and snippets.

View fffaraz's full-sized avatar
🚀
Focusing

Faraz Fallahi fffaraz

🚀
Focusing
View GitHub Profile
@fffaraz
fffaraz / math_unsigned.h
Created October 13, 2015 04:48
Arbitrary-precision integer arithmetic in C++
#ifndef MATH_UNSIGNED_H
#define MATH_UNSIGNED_H
#include <cstdint>
#include <vector>
#include <iostream>
#include <stdexcept>
#include <algorithm>
#include <sstream>
#include <cctype>
@fffaraz
fffaraz / exec.md
Last active March 1, 2021 12:23
execl, execlp, execle, execv, execvp, execvpe
- e p
l execl execle execlp
v execv execve execvp

  • int execl(char const *path, char const *arg0, ...);
  • int execle(char const *path, char const *arg0, ..., char const *envp[]);
@fffaraz
fffaraz / tcpKeepAlive.c
Created June 12, 2015 06:55
SO_KEEPALIVE
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int enableKeepAlive = 1;
int fd = tcpSocket->socketDescriptor();
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &enableKeepAlive, sizeof(enableKeepAlive));
int maxIdle = 300;
setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &maxIdle, sizeof(maxIdle));
@fffaraz
fffaraz / 1.cpp
Created June 5, 2015 20:38
C++ pthread
class C
{
public:
void *hello(void)
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
static void *hello_helper(void *context)
#include <iostream>
using namespace std;
int main()
{
for(long long i=1000000000; i <= 9999999999; i++)
{
long long a = i;
int x[10] = {};
@fffaraz
fffaraz / ghosttest.c
Created January 29, 2015 04:52
GHOST vulnerability tester
/* ghosttest.c: GHOST vulnerability tester */
/* Credit: http://www.openwall.com/lists/oss-security/2015/01/27/9 */
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
@fffaraz
fffaraz / ui512test.cpp
Created December 21, 2014 23:51
ui512test
#include <iostream>
#include <cstdint>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
#if 0
@fffaraz
fffaraz / apache.md
Created December 21, 2014 23:31
Apache Cheat Sheet

Source

Apache Cheat Sheet

Setup a Virtual Domain

NameVirtualHost *

DocumentRoot /web/example.com/www

@fffaraz
fffaraz / regex.html
Created December 21, 2014 23:28
Regex Cheat Sheet
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Regex Cheat Sheet</title>
<style type="text/css">
body { font-family: verdana; font-size: smaller; }
h2 { margin-bottom: 3px; font-size: small; }
th { background-color:#f6f6f6; }
td.sc { text-align:center; font-weight:bold; font-size:xx-large; font-family:"courier new", courier; }