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
>>> True = False | |
>>> print (True and 1 == 1) | |
False |
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
# At the beginning of .bashrc | |
zsh | |
exit 0 |
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
class httmock_assert: | |
def __init__(self, method=None, url=None): | |
self.method = method | |
self.url = url | |
self.data = None | |
self.headers = [] | |
self.response = {'status_code': 200} | |
def assert_header(self, key, value): | |
self.headers.append((key, value)) |
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
<?php | |
$url_info = parse_url($_SERVER["REQUEST_URI"]); | |
$path = $url_info["path"]; | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: http://www.newwebsite.com/" . $path); | |
?> |
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
package main | |
import ( | |
"fmt" | |
"strings" | |
"sort" | |
) | |
type CountingResult struct { | |
word string | |
count uint |
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 colorsys | |
from wand.image import Image | |
from wand.color import Color | |
def get_average(image, lower_threshold=50, upper_threshold=230, sample_size=6, liveliness_boost=0.3): | |
""" | |
Calculates the average of color in the given image and gives it a bit of a "colour boost" by incrementing their hue | |
and saturation. This function's default are also slightly biased to prefer "lighter" colors (looks better on the | |
mostly white backgrounds where the images will be displayed). |
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 math import ceil | |
class Pagination: | |
def __init__(self, items, page, per_page, total_items): | |
self.items = items | |
self.page = page | |
self.total_items = total_items | |
self.per_page = per_page | |
self.num_pages = int(ceil(total_items / float(per_page))) |
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 java.util.List; | |
import java.util.Map; | |
import java.util.Set; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.Context; | |
import javax.ws.rs.core.MediaType; | |
import javax.ws.rs.core.Response; |
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
// ==UserScript== | |
// @name Gitlab + Ubuntu + Fonts | |
// @namespace http://www.patrick-stegmann.de/ | |
// @version 1.1 | |
// @description More beautiful code display in Gitlab | |
// @match http://gitlab.cosee.biz/* | |
// @copyright 2014+, Patrick Stegmann | |
// ==/UserScript== | |
// Thanks from Google Fonts! |
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
class AmazonResponseMocker(): | |
def __init__(self, response=None, timeout=False): | |
import requests | |
self.response = response | |
self.timeout = timeout | |
self.get = requests.get | |
def __enter__(self): | |
def timeout(*args, **kwargs): | |
from requests.exceptions import Timeout |