Skip to content

Instantly share code, notes, and snippets.

@certik
certik / gist:994243
Created May 26, 2011 22:25
Fortran epsilon test
program test
implicit none
integer, parameter :: dp = 8
real(dp) :: a, b
a = 1.0_dp
b = a + epsilon(1.0_dp)
print *, "First we show, that we have two different 'a' and 'b':"
print *, "a == b:", a == b, "b-a:", b-a
print *, "using (es22.15)"
print "(es22.15)", a
@certik
certik / README.md
Created July 20, 2011 22:12
C vs Fortran benchmark

On my machine, the timings are:

Fortran:

$ time ./a.out 
   249999999500000000

real	0m0.510s
user	0m0.510s
sys	0m0.000s
@matthewoden
matthewoden / README.md
Last active January 21, 2016 22:14
Your CSS doesn't have to be a mess.

CSS in 2016

So this is roughly how I handle CSS these days. As much as I'd like to use CSSModules for everything, I work on a lot of different projects, for a lot of different clients. They can't all be a SPA.

Some of this seems blindingly obvious. But until I stop cleaning up messy, repetitive CSS, I figure it all merits being said.

Create a Baseline

I use one file to style HTML. This creates a baseline for the body, defines my box model, sets global typography rules, etc. If I need to style an HTML element, I style it globally. Otherwise, I give an element a class, and only style that class.

@bdarnell
bdarnell / ssltest.py
Created May 24, 2014 16:26
Test case for interrupted SSL handshake
import contextlib
import os.path
import socket
import ssl
import unittest
from tornado.iostream import SSLIOStream
from tornado import netutil, testing
from tornado.testing import AsyncTestCase, bind_unused_port
@sharoonthomas
sharoonthomas / gist:2785473
Created May 25, 2012 02:52
Serve files based on google authentication
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Authentication proxy for Tornado to use Google apps authentication to
serve the files in a protected location. Ideal to serve files like
sphinx documentation behind a password.
:copyright: (c) 2011 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
@danverbraganza
danverbraganza / hangman.py
Last active April 20, 2017 18:52
Hangman implemented in 3 lines of Python! For an explanation of how this works, see http://danverbraganza.com/writings/hangman-in-3-lines-of-python
license, chosen_word, guesses, scaffold, man, guesses_left = 'https://opensource.org/licenses/MIT', ''.join(filter(str.isalpha, __import__('random').choice(open('/usr/share/dict/words').readlines()).upper())), set(), '|======\n| |\n| {3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}\n|', list('OT-\\-//\\||'), 10
while not all(letter in guesses for letter in chosen_word) and guesses_left: _, guesses_left = map(guesses.add, filter(str.isalpha, raw_input('%s(%s guesses left)\n%s\n%s:' % (','.join(sorted(guesses)), guesses_left, scaffold.format(*(man[:10-guesses_left] + [' '] * guesses_left)), ' '.join(letter if letter in guesses else '_' for letter in chosen_word))).upper())), max((10 - len(guesses - set(chosen_word))), 0)
print 'You', ['lose!\n' + scaffold.format(*man), 'win!'][bool(guesses_left)], '\nWord was', chosen_word
@gaspanik
gaspanik / capture.js
Last active November 6, 2018 06:19
Take screenshot at single viewport size using CasperJS
var screenshotUrl = 'http://example.com/'
var casper = require("casper").create({
viewportSize: {
width: 1024,
height: 768
}
});
if (casper.cli.args.length < 1) {
@soemarko
soemarko / theme.html
Created November 26, 2011 16:18
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@tuantm8
tuantm8 / rabbitmq-server.monit
Created January 20, 2017 08:19
Monit configuration for rabbitmq-server
check process rabbitmq-server matching "/usr/lib/erlang/erts-6.2/bin/beam"
group rabbitmq
start program = "/etc/init.d/rabbitmq-server start"
stop program = "/etc/init.d/rabbitmq-server stop"
if failed port 5672 type tcp then restart
if 3 restarts within 3 cycles then timeout
@jordanyaker
jordanyaker / arr configuration.xml
Last active June 14, 2019 06:06
This is a web.config file for doing reverse proxy with the ARR module from IIS. The configuration file was based on instructions from here: http://blogs.iis.net/carlosag/archive/2010/04/01/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr.aspx
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime enableVersionHeader="false" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite API" stopProcessing="true">
<match url="^api\/(.*)$" />