Skip to content

Instantly share code, notes, and snippets.

View smart--petea's full-sized avatar

Badarau Petru smart--petea

View GitHub Profile
#include <unistd.h>
#include <node.h>
#include <string.h>
#include <v8.h>
using namespace v8;
unsigned long long count = 0;
// native blocking/compute intensive function
# If you're looking into the C10M problem (10 million concurrent connections)
# you might want to play with DPDK (Originally proprietry Intel, now open source)
#
# C10M: http://c10m.robertgraham.com/
# DPDK: http://dpdk.org/
#
# This is a quick summary how to install dpdk on ubuntu
# running inside virtualbox on a mac
# On my Mac:
@maheshgattani
maheshgattani / fire_and_forget.php
Last active January 11, 2022 19:26
Fire and forget requests in PHP using fsockopen
<?php
/*
This script can be used by a server to make fire and forget requests to any given url.
This script assumes you have access to $_COOKIE and $_SERVER variable passed along via the server.
GET and POST requests are supported.
POST can have an attached file to it.
Author: Mahesh Gattani ([email protected])
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active March 20, 2025 17:17
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@clemensg
clemensg / curl_libuv_example.c
Last active November 21, 2024 09:50
An example on how to use libuv with libcurl's multi interface Should be equally fast on Unixes (uses epoll/kqueue/etc like libev/libevent) but MUCH faster on Windows due to libuv's usage of IO completion ports. Could come in handy if you have to manage several hundreds or thousands of connections!
#include <stdio.h>
#include <stdlib.h>
#include <uv.h>
#include <curl/curl.h>
uv_loop_t *loop;
CURLM *curl_handle;
uv_timer_t timeout;
typedef struct curl_context_s {
@clemensg
clemensg / curl_multi_test.c
Last active July 22, 2025 07:48
libcurl multi interface example
/* curl_multi_test.c
Clemens Gruber, 2013
<clemens.gruber@pqgruber.com>
Code description:
Requests 4 Web pages via the CURL multi interface
and checks if the HTTP status code is 200.
Update: Fixed! The check for !numfds was the problem.
@eendeego
eendeego / bindings-cheat-sheet.md
Created November 28, 2012 10:26
Node/V8 bindings cheat sheet
@jfromaniello
jfromaniello / gist:4087861
Last active February 6, 2022 03:53
socket-io.client send the cookies!
/*
* Little example of how to use ```socket-io.client``` and ```request``` from node.js
* to authenticate thru http, and send the cookies during the socket.io handshake.
*/
var io = require('socket.io-client');
var request = require('request');
/*
* This is the jar (like a cookie container) we will use always
@ifduyue
ifduyue / strip_tags.cpp
Created January 13, 2012 02:37
c++ strip_tags replace_all
string &replace_all(string &content, const string &from, const string &to)
{
size_t i = 0;
size_t j;
while((j = content.find(from, i)) != string::npos) {
content.replace(j, from.size(), to);
i = j + to.size();
}
return content;
}
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE