Skip to content

Instantly share code, notes, and snippets.

View smac89's full-sized avatar

Nobleman smac89

View GitHub Profile
@beci
beci / gcc 5 on ubuntu 14.04
Created October 15, 2015 07:18
use gcc 5.x on ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
@thoop
thoop / .htaccess
Last active January 27, 2024 14:07
Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@trungly
trungly / simple_server.py
Last active February 1, 2024 18:51
A simple Python HTTP server that supports a GET that echoes some request data and a POST that reads a request body, parses it as JSON and responds with part of the data
from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse, json
class GetHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = urlparse.urlparse(self.path)
message = '\n'.join([
'CLIENT VALUES:',
'client_address=%s (%s)' % (self.client_address,
@atenni
atenni / README.md
Last active April 24, 2024 01:36
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@davidandrzej
davidandrzej / regex-unapply.scala
Created June 22, 2012 00:23
Scala regex unapply magic
scala> val myRegex = """Foo=([0-9]+) Bar=([A-Z]+)""".r
myRegex: scala.util.matching.Regex = Foo=([0-9]+) Bar=([A-Z]+)
scala> "Foo=123 Bar=ABC" match {
| case myRegex(foo, bar) =>
| println("foobar looks like %s-%s".format(foo,bar))
| case _ => println("not a match")
| }
foobar looks like 123-ABC