Skip to content

Instantly share code, notes, and snippets.

View padenot's full-sized avatar
🦊
counting bytes

Paul Adenot padenot

🦊
counting bytes
View GitHub Profile
HttpRequest::HttpRequest (const std::string& url)
:attributeCount_(0),
url_(url),
hostname_(url.substr(0, url.find_first_of('/'))),
path_(url.substr(url.find_first_of('/'))),
resolver_(io_service_),
socket_(io_service_)
{
//check if a port is in the hostname.
size_t index = hostname_.find_first_of(':');
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#define BUFFER_SIZE 128
#include <iostream>
#include <vector>
#include <assert.h>
int main()
{
std::vector<int> vec_int;
vec_int.push_back(1);
@padenot
padenot / .vimrc
Created January 27, 2011 18:16
Paul's .vimrc
"
" _ _(_)_ __ ___ _ __ ___
" / \ / / | '_ ` _ \| '__/ __|
" \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___|
"
"
" Paul ADENOT -- 2011
" You need the following plugins :
" DoxygenToolkit indent_guidesm syntasticm
@padenot
padenot / gist:849353
Created March 1, 2011 16:06
Wifi meter using Shoes
# A tiny wifi meter
# usage : shoes wifi.rb
Shoes.app(:title => "wifi meter", :width => 250, :height => 100) do
background gradient(rgb(0,0,0), rgb(40,40,40))
header = {
:font => 'Georgia',
:size => '48px',
:stroke=>'#'+'E'*3,
@padenot
padenot / Licenser
Created March 2, 2011 17:24
Quick script to add license block to files. The license block should be in a separate file, called license. New BSD license is provided as an example.
### add_license_block.sh
#! /bin/sh
OWNER="Paul ADENOT \& Martin Richard"
YEAR="2011"
ORGANIZATION="bim"
FILEAUTHOR="Paul ADENOT <paul@paul.cx>"
fill_license_block()
@padenot
padenot / gist:875097
Created March 17, 2011 20:48
Du blocage de l'internet pendant quelque minutes, ou comment gagner en productivité
#!/bin/sh
time=$(zenity --text="On bloque le net combien de temps ?" --scale --value=60 --min-value=1 --max-value=600)
echo $time
network_interface=$(ifconfig | grep Link | tr -s ' ' | cut -d ' ' -f1)
for i in $network_interface
do
@padenot
padenot / gist:1002059
Created June 1, 2011 09:56
How to save a file from js (from tiddlywiki code)
function mozillaSaveFile(filePath,content)
{
if(window.Components) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(filePath);
if(!file.exists())
file.create(0,0664);
var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
@padenot
padenot / timelapse.sh
Created September 28, 2011 14:01
Timelapse script
#!/usr/bin/zsh -x
mkdir timelapse_frames
cd timelapse_frames
# in seconds
if [ -z $1 ]
then
duration=10
else
duration=$1
fi
@padenot
padenot / timelapse.sh
Created September 28, 2011 14:02
A timelapse script
#!/usr/bin/zsh -x
mkdir timelapse_frames
cd timelapse_frames
# in seconds
if [ -z $1 ]
then
duration=10
else
duration=$1
fi