This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from colorlog import ColoredFormatter | |
class TogglingColoredFormatter(ColoredFormatter): | |
""" | |
Blanks all color codes if not running under a TTY. | |
This is useful when you want to be able to pipe colorlog output to a file. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- credit: https://tapoueh.org/blog/2014/02/postgresql-aggregates-and-histograms/ | |
with drb_stats as ( | |
select min(drb) as min, | |
max(drb) as max | |
from team_stats | |
), | |
histogram as ( | |
select width_bucket(drb, min, max, 9) as bucket, | |
int4range(min(drb), max(drb), '[]') as range, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import unittest | |
def immediately(coro): | |
f = lambda self, *args, **kwargs: self.loop.run_until_complete(coro(self, *args, **kwargs)) | |
f.__name__ = coro.__name__ | |
return f | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
body { | |
font-family: -apple-system, BlinkMacSystemFont, San Francisco, Roboto, Segoe UI, Helvetica Neue, sans-serif | |
} | |
#clock { | |
display: flex; | |
flex-flow: column; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"><style type="text/css">ol{margin:0;padding:0}table td,table th{padding:0}.c3{background-color:#ffffff;max-width:468pt;padding:72pt 72pt 72pt 72pt}.c0{orphans:2;widows:2}.c1{height:11pt}.c2{font-weight:700}.title{padding-top:0pt;color:#000000;font-size:26pt;padding-bottom:3pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}.subtitle{padding-top:0pt;color:#666666;font-size:15pt;padding-bottom:16pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}li{color:#000000;font-size:11pt;font-family:"Arial"}p{margin:0;color:#000000;font-size:11pt;font-family:"Arial"}h1{padding-top:20pt;color:#000000;font-size:20pt;padding-bottom:6pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}h2{padding-top:18pt;color:#000000;font-size:16pt;padding-bottom:6pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* $ gcc shift_float.c | |
* $ a.out | |
*/ | |
#include <stdio.h> | |
void main() { | |
float f = 3.0; | |
long l; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Prompt user for a number, n | |
// 2. Print the square of every number between 0 and n | |
var number = parseInt(prompt("Give me a number")); // prompt is a built-in function | |
for(var i = 0; i <= number; i++) { | |
console.log(i * i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var number1 = parseFloat(prompt("Enter the first number")); | |
var number2 = parseFloat(prompt("Enter the second number")); | |
var operation = prompt("Choose one of +, -, *, /") | |
var result; | |
if(operation == "+") { | |
result = number1 + number2; | |
} else if(operation == "-") { | |
result = number1 - number2; | |
} else if(operation == "*") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<div class="icon-box left-icon width-2"> | |
<div class="icon"> | |
<img src="http://placehold.it/48x48"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#menubar { | |
position: absolute; | |
top: 300px; | |
left: 300px; | |
width: 500px; | |
background: #aaa; | |
} | |
.menu { | |
margin: 0; |
NewerOlder