Skip to content

Instantly share code, notes, and snippets.

View benwills's full-sized avatar

Ben Wills benwills

View GitHub Profile
@joepie91
joepie91 / vpn.md
Last active July 3, 2025 09:58
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@nikolov-tmw
nikolov-tmw / multiple-roles-per-user.php
Last active September 5, 2024 01:45
Multiple roles per user WordPress plugin.
<?php
/**
* Plugin Name: Multiple Roles per User
* Description: Allows anyone who can edit users to set multiple roles per user. In a default WordPress environment that wouldn't have much of an effect, since the user would have the privileges of the top-privileged role that you assign to him. But if you have custom roles with custom privileges, this might be helpful.
* Version: 1
* Author: nikolov.tmw
* Author URI: http://paiyakdev.com/
* License: GPL2
*/
/*
@nikolov-tmw
nikolov-tmw / .htaccess
Last active December 28, 2015 00:09
WordPress login lock - try to prevent automated brute force attacks. Just place the login-lock.php file in /wp-content/mu-plugins/ and add the code in .htaccess to your root's .htaccess file. Note that if you have WordPress in a sub-directory, you would have to change the RewriteBase on line 8.
# Add this code to the .htaccess in your root WordPress directory
# If your wordpress files are in a sub-directory, just change the RewriteBase
# to something like:
# RewriteBase /wordpress/
# If your wordpress files are in a sub-directory called "wordpress"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Redirect to home page upon log-out
@mikeando
mikeando / Demo.c
Last active November 23, 2024 12:14
Example of using C++ from C.
#include "HMyClass.h"
#include <stdio.h>
void my_eh( const char * error_message, void * unused)
{
printf("my_eh: %s\n", error_message);
}
int main()
{
@alehandrof
alehandrof / subl-scopes
Last active November 23, 2023 20:09
scopes for sublime text schemes
comment
comment punctuation
comment.block.documentation
comment.block.preprocessor
comment.documentation
constant
constant.character
constant.character punctuation
constant.character.entity
constant.character.escape
@jboner
jboner / latency.txt
Last active July 2, 2025 06:46
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@gautambak
gautambak / gist:2836941
Created May 30, 2012 15:19
cuda memory example
// CUDA-C includes
#include <cuda.h>
#include <stdio.h>
#include "../common/book.h"
extern "C"
int runCudaPart();
// CODE goes below
@ibtaylor
ibtaylor / c89p90p2001.h
Created April 7, 2012 04:29
silly header with comments documenting c89 P90 P2001 c standard types and functions for reference
#ifndef __C89P90P2001_H__
#define __C89P90P2001_H__
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TODO:
add C11 additions
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
@gruber
gruber / Liberal Regex Pattern for All URLs
Last active June 6, 2025 01:10
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:[email protected]", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))