Skip to content

Instantly share code, notes, and snippets.

@filsinger
filsinger / find-url-at-point.el
Last active August 29, 2015 14:22
Emacs: Download a url to a buffer and open the buffer
(defun find-url-at-point (&optional url)
"Open the URL at point."
(interactive)
(switch-to-buffer
(url-retrieve-synchronously
(or url (let ((default-search-string (if (region-active-p) (buffer-substring-no-properties (region-beginning) (region-end)) (thing-at-point-url-at-point) )))
(read-string (format "URL: %s" (or default-search-string "")) nil nil default-search-string) ) )) ))
@filsinger
filsinger / main.cpp
Created October 18, 2012 09:06
C++11 : Split a string using regex
#include <regex>
#include <string>
#include <vector>
std::vector<std::string> Split(const std::string& str, const std::string& regex)
{
return {std::sregex_token_iterator(str.begin(), str.end(), std::regex(regex), -1), std::sregex_token_iterator()};
}
@filsinger
filsinger / fnv_hash_example.cpp
Created October 1, 2011 06:36
C++11 : FNV-1 and FNV-1a compile-time string hashing
// C++11 32bit FNV-1 and FNV-1a string hasing (Fowler–Noll–Vo hash)
//
// Requires a compiler with C++11 support
// See main(...) for examples
#include <iostream>
#include <cassert>
namespace hash
{