Skip to content

Instantly share code, notes, and snippets.

@jdiego
jdiego / codesign_gdb.md
Last active August 2, 2024 09:05 — forked from hlissner/codesign_gdb.md
Codesign gdb on OSX

If you are getting this in gdb on OSX while trying to run a program:

Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
  1. Open Keychain Access
  2. In menu, open Keychain Access > Certificate Assistant > Create a certificate
  3. Give it a name (e.g. cert-gdb)
#!/bin/bash
# When you upgrade Python using Homebrew and then run brew cleanup, the symlinks
# in the virtualenv point to paths that no longer exist (because Homebrew deleted them).
env="my-virtual-env"
# The solution is to remove the symlinks in the virtualenv and then recreate them
find ~/.virtualenvs/${env}/ -type l -delete
# Recreating link
virtualenv ~/.virtualenvs/${env}
@jdiego
jdiego / view.py
Created March 11, 2017 00:47 — forked from saketkc/view.py
Prevent multiple form submission for Django Forms
import hashlib
def register(request):
if request.method == 'POST':
request_post = request.POST
registration_form = RegistrationFormUniqueEmail(request_post)
hashstring=hashlib.sha1(str(request.POST.get('csrf_token'))) ## This is going to be unique ! A unique has
if request.session.get('sesionform')!=hashstring:
if registration_form.is_valid():
username = registration_form.cleaned_data['username']
email = registration_form.cleaned_data['email']
struct Connection {
void disconnected()
{
m_connection = Disconnected();
}
void interrupted()
{
m_connection = std::visit(InterruptedEvent(*this), m_connection);
}
#include <iostream>
#include <string>
#include <vector>
// Basic vocabulary first:
// A function
template<typename Result>
struct Function
#include <chrono>
#include <cstring>
#include <string>
#include <fstream>
#include <istream>
#include <iostream>
#include <sstream>
#include <boost/tokenizer.hpp>
@jdiego
jdiego / cpp11.cpp
Last active August 29, 2015 14:27 — forked from goldshtn/cpp11.cpp
A single function that uses a bunch of C++11/14 features and for "old-school" C++ developers will not even read like C++ anymore.Specifically, it uses:- lambda functions (C++11) with generalized capture semantics (C++14)- rvalue references (C++11)- auto variables (C++11)- decltype and trailing function return type syntax (C++11)- std::move and s…
#include <iostream>
#include <future>
using namespace std;
template <typename Fn, typename... Args>
auto do_async_with_log(ostream& os, Fn&& fn, Args&&... args) ->
future<decltype(fn(args...))>
{
os << "[TID=" << this_thread::get_id()