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 May 7, 2024 23:27
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.
@danielledeleo
danielledeleo / gcc-on-osx.md
Last active May 20, 2022 11:54
Compiling and Running C on Mac OS X 10.10 Yosemite

Compiling and Running C on Mac OS X Yosemite

If you're like me, you find working on the provided Ubuntu VM to be tortuous and inefficient. It's such a shame to be running an operating system with all of the tools to you need to compile and run simple toy C programs but being forced to use a clunky virtual machine without all your favourite software. Here's what I do to ease the pain.

Mac OS X

This guide was tested on Mac OS X 10.10 Yosemite, but should also work on any version of OS X that Homebrew supports. It should work just fine on Mavericks, plus you get access to valgrind. (valgrind hasn't been ported to 10.10 yet, but it does work on 10.9)

gcc on OS X

By default, if you have Xcode installed, typing gcc into Terminal.app links to the llvm/clang compiler. Although clang is a great, modern compiler it isn't what's specified by the professor and could potentially lead to incompatible code (and lost marks). To avoid this,

@nikolov-tmw
nikolov-tmw / multiple-roles-per-user.php
Last active October 5, 2021 03:56
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 March 20, 2024 10:47
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 May 8, 2024 16:32
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 May 6, 2024 21:38
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:foo@example.com", "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`!()\[\]{};:'".,<>?«»“”‘’]))