Skip to content

Instantly share code, notes, and snippets.

@programus
programus / ajaxPool.js
Last active October 8, 2021 07:40 — forked from Terrance/AjaxQueue.js
Limit concurrent jQuery ajax requests to at most 6 at a time, and queue the rest.
const ajaxPool = {
queue: [],
reqCount: 0,
activeCount: 0,
maxCount: parseInt(searchParams.get('ajaxLimit')) || 6,
add(obj) {
this.reqCount++
const originalSuccess = obj.success
const originalError = obj.error
const callback = () => {
@programus
programus / impbcopy.m
Last active November 7, 2022 09:02 — forked from yuchuanfeng/impbcopy.m
Command line copy an image file to the clipboard in Mac OS X. See first comment for install instructions.
#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <unistd.h>
BOOL copy_to_clipboard(NSString *path)
{
// http://stackoverflow.com/questions/2681630/how-to-read-png-image-to-nsimage
NSImage * image;
if([path isEqualToString:@"-"])
{
// http://caiustheory.com/read-standard-input-using-objective-c