Skip to content

Instantly share code, notes, and snippets.

View mehmetkose's full-sized avatar
:electron:
Reacting

Mehmet Kose mehmetkose

:electron:
Reacting
  • Sour Cream LTD
  • Dublin, Ireland
  • 19:02 (UTC +01:00)
  • X @mehmetkose
View GitHub Profile
@paulirish
paulirish / what-forces-layout.md
Last active May 5, 2025 08:05
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@drgarcia1986
drgarcia1986 / tornado_asyncio.py
Last active August 7, 2021 15:57
Tornado and Asyncio Mixed example
# -*- coding: utf-8 -*-
import asyncio
import re
import asyncio_redis
import tornado.concurrent
import tornado.httpclient
import tornado.web
import tornado.platform.asyncio
@mrbobbybryant
mrbobbybryant / gist:f1714ab93b8171947ed7
Last active January 5, 2018 20:42
WordPress Custom Post Type (Using $singular and $plural)
<?php
//Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function dwwp_register_post_type() {
$singular = 'Job';
$plural = 'Jobs';
@staltz
staltz / introrx.md
Last active May 6, 2025 07:45
The introduction to Reactive Programming you've been missing
@arvidfm
arvidfm / asyncio-tornado.py
Last active December 4, 2018 12:56
Running Tornado on asyncio's event loop, including 'yield from' support in request handlers
import asyncio
import tornado.concurrent
import tornado.ioloop
import tornado.web
import tornado.platform.asyncio
import tornado.httpclient
class ReqHandler(tornado.web.RequestHandler):
async def get(self):
@ademilter
ademilter / gist:8972161
Created February 13, 2014 09:20
share & share count
// SHARE COUNT
$.getJSON("https://graph.facebook.com/fql?q=SELECT like_count FROM link_stat WHERE url=" + encodeURIComponent('"' + Screenshot.Meta.full_url + '"') + " &callback=?", function(t) {
t.data[0] && $("#share-button-fb .shot-social-count").html(shorterTotal(t.data[0].like_count))
})
$.getJSON("http://cdn.api.twitter.com/1/urls/count.json?url=" + encodeURIComponent(Screenshot.Meta.full_url) + "&callback=?", function(t) {
t.count && $("#share-button-twitter .shot-social-count").html(shorterTotal(t.count))
})
@tmichel
tmichel / index.html
Created November 9, 2013 22:07
simple websocket example with golang
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<div>
<form>
<label for="numberfield">Number</label>
<input type="text" id="numberfield" placeholder="12"/><br />
@taylanpince
taylanpince / s3.py
Created June 27, 2013 13:41
Async Tornado S3 uploader, doesn't block, continues uploading after the request is closed
import hashlib, hmac, mimetypes, os, time
from base64 import b64encode, b64decode
from calendar import timegm
from datetime import datetime
from email.utils import formatdate
from urllib import quote
from tornado.gen import coroutine, Return
from tornado.httpclient import AsyncHTTPClient, HTTPError
@akhenakh
akhenakh / gist:5825280
Last active April 21, 2016 16:12
Decorator for Tornado function, that will log all exception in MongodB, implies all handlers have a self.db properties connected to mongo
def log_exception(view_func):
""" log exception decorator for a view,
"""
def _decorator(self, *args, **kwargs):
try:
response = view_func(self, *args, **kwargs)
except:
if self.settings['debug']:
raise
tb = traceback.format_exc()
@gdamjan
gdamjan / README.md
Last active April 5, 2025 23:28
Setup for an easy to use, simple reverse http tunnels with nginx and ssh. It's that simple there's no authentication at all. The end result, a single ssh command invocation gives you a public url for your web app hosted on your laptop.

What

A lot of times you are developing a web application on your own laptop or home computer and would like to demo it to the public. Most of those times you are behind a router/firewall and you don't have a public IP address. Instead of configuring routers (often not possible), this solution gives you a public URL that's reverse tunnelled via ssh to your laptop.

Because of the relaxation of the sshd setup, it's best used on a dedicated virtual machine just for this (an Amazon micro instance for example).

Requirements