Skip to content

Instantly share code, notes, and snippets.

View kmlx's full-sized avatar

Adrian Stanescu kmlx

View GitHub Profile
@kmlx
kmlx / concurrency-in-go.md
Created March 12, 2016 10:54 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy
import time
import threading
from threading import Thread
import base64
class EncodeToB64(Thread):
def __init__(self, imgUrl):
self.stopped = False
self.imgUrl = imgUrl
int ToBase64Fast( const BYTE* pSrc, int nLenSrc, char* pDst, int nLenDst )
{
int nLenOut= ((nLenSrc+2)/3)*4; // 4 out for every 3 in, rounded up
if ( nLenOut+1 > nLenDst ) {
return( 0 ); // fail!
}
WORD* pwDst= (WORD*)pDst;
while( nLenSrc > 2 ) {
DWORD n= pSrc[0]; // xxx1
n <<= 8; // xx1x
@kmlx
kmlx / jquery.hasattr.js
Created October 25, 2012 14:28 — forked from rwaldron/jquery.hasattr.js
A commonly requested feature that is simply not worth adding to jQuery core. Usage: http://jsfiddle.net/rwaldron/kSmP2/
/*!
* jQuery.fn.hasAttr()
*
* Copyright 2011, Rick Waldron
* Licensed under MIT license.
*
*/
(function( jQuery ) {
jQuery.fn.hasAttr = function( name ) {
for ( var i = 0, l = this.length; i < l; i++ ) {