<!-- 1px Transparent -->
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
<!-- 1px Gray -->
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==">
<!-- 1px Black -->
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=">
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
function hasClass(element, className) { | |
return element.className && new RegExp("(^|\\s)" + className + "(\\s|$)").test(element.className); | |
} | |
var myDiv = document.getElementById('MyDiv'); | |
hasClass(myDiv, 'active'); | |
// OR |
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 | |
// a simple key/val store using php & sqlite3 | |
// license: http://gist.github.com/375593 | |
// edited by alekssamos | |
class SqliteStore { | |
protected $db; | |
public function __construct($tableName, $filePath = 'db.sqlite') { | |
$this->db = new SQLite3($filePath); | |
$this->tableName = $this->db->escapeString($tableName); |
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> | |
<meta charset="UTF-8"> | |
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | |
</head> | |
<body> | |
<script> |
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
function arrayBufferToBase64(buffer) { | |
let binary = ''; | |
let bytes = new Uint8Array(buffer); | |
let len = bytes.byteLength; | |
for (let i = 0; i < len; i++) { | |
binary += String.fromCharCode(bytes[i]); | |
} | |
return window.btoa(binary); | |
} |
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 wx | |
import urllib.request | |
import json | |
import webbrowser | |
API_KEY = '' | |
class NewsPanel1(wx.Panel): | |
def __init__(self, parent): |
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 ARRAY_LENGTH = 16; | |
var MIN_HEX_LENGTH = 2; | |
class UUID { | |
static createUUID() { | |
const array = new Uint8Array(ARRAY_LENGTH); | |
window.crypto.getRandomValues(array); | |
let uuid = ''; |
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 | |
from contextlib import closing | |
import aiohttp | |
async def download_file(session: aiohttp.ClientSession, url: str): | |
async with session.get(url) as response: | |
assert response.status == 200 | |
# For large files use response.content.read(chunk_size) instead. |
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 | |
from collections import deque | |
class AsyncioPool: | |
def __init__(self, concurrency, loop=None): | |
""" | |
@param loop: asyncio loop | |
@param concurrency: Maximum number of concurrently running tasks | |
""" |
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 | |
from asyncio.queues import Queue | |
TERMINATOR = object() | |
class TaskPool(object): | |
def __init__(self, loop, num_workers): | |
self.loop = loop | |
self.tasks = Queue(loop=self.loop) |
OlderNewer