Skip to content

Instantly share code, notes, and snippets.

View MarvinXu's full-sized avatar

Marvin MarvinXu

  • 18:04 (UTC +08:00)
View GitHub Profile
@stevecondylios
stevecondylios / resize-image-in-github-issue-github-flavored-markdown.md
Last active May 16, 2024 06:14
How to Resize an Image in a Github Issue (e.g. Github flavored Markdown)

How to Resize an Image in Github README.md (i.e. Github Flavored Markdown)

Percentage:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width=50% height=50%>

Pixels:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width="150" height="280">

@claraj
claraj / gist:3b2b95a62c5ba6860c03b5c737c214ab
Created April 12, 2017 21:34
Custom JSON encoder for Flask
from flask import Flask
from flask import render_template
from flask import request
from flask import jsonify
import json
# This class tells Python how to turn a Delivery object into a JSON string.
# This class could encode various types of objects - use isinstance to check what type of thing it is, and return the appropriate JSON
# https://docs.python.org/3/library/json.html
@jgrodziski
jgrodziski / docker-aliases.sh
Last active May 28, 2024 09:13
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #
@freekrai
freekrai / demo.php
Last active June 7, 2024 09:58
PHP session-based rate limiter for APIs
<?php
date_default_timezone_set('America/Los_Angeles');
session_start();
include("ratelimiter.php");
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you.
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]);
$limit = 100; // number of connections to limit user to per $minutes
$minutes = 1; // number of $minutes to check for.