Skip to content

Instantly share code, notes, and snippets.

- (void)outlineView:(NSOutlineView *)outlineView
willDisplayCell:(id)cell
forTableColumn:(NSTableColumn *)tableColumn
item:(id)item {
NSColor *color = [cell backgroundColor];
NSLog(@"Colorizing Method B");
if (clicked == YES) {
if (color == [NSColor lightGrayColor]) {
}else{
[cell setBackgroundColor:[NSColor lightGrayColor]];
@eligrey
eligrey / chrome-i18n.js
Last active January 11, 2020 11:16
Easy i18n for your Chrome extensions and apps' DOM.
/* Chrome DOM i18n: Easy i18n for your Chrome extensions and apps' DOM.
* 2011-06-22
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
/*jslint laxbreak: true, strict: true*/
/*global self, chrome, document*/
@mrluanma
mrluanma / requirements.txt
Created September 4, 2012 14:40
Python 登录新浪微博(requests 真的比 urllib2 强了 2^^32 倍 pip install requests)
requests==2.4.3
rsa==3.1.4
@kosso
kosso / dataURItoBlob
Created December 9, 2012 20:26
convert base64 to raw binary data held in a string
/**
via http://stackoverflow.com/questions/4998908/convert-data-uri-to-file-then-append-to-formdata/5100158
via http://www.smartjava.org/content/face-detection-using-html5-javascript-webrtc-websockets-jetty-and-javacvopencv
**/
function dataURItoBlob(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var array = [];
for(var i = 0; i < binary.length; i++) {
@davoclavo
davoclavo / dataURItoBlob.js
Last active May 26, 2023 14:45
Convert dataURI to Blob so large images do not crash the browser. Based on: http://stackoverflow.com/questions/10412299 and http://stackoverflow.com/questions/6850276
/*
The MIT License (MIT)
Copyright (c) 2016 David Gomez-Urquiza
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
@thewei
thewei / TaskQe.js
Last active June 11, 2021 02:23
Javascript实现异步任务队列类
/*
@Author:thewei
@website:http://www.99is.com
@title: 异步事件任务队列类
*/
(function(){
TaskQe = function(){
this._arrayFn = []; //事件集合
@chzyer
chzyer / go-concurrent-programming.md
Last active June 30, 2020 02:27
golang并发编程 - 例子解析

最近在看《Programming in Go》, 其中关于并发编程写得很不错, 受益非浅, 其中有一些例子是需要多思考才能想明白的, 所以我打算记录下来, 强化一下思路

《Programming in Go》在 Chapter 7. Concurrent Programming 里面一共用3个例子来讲述并发编程的3个模式, 第一个是 filter , 筛选出后缀名和文件大小文件列表, 还算简单就不说, 然后第二个是升级版, 正则版 filter , 不同的是他是根据正则搜索出文件的文本并且列出来. 这个例子我起初看是有点蒙的, 这样写是没错, 但是为什么要这样写, 他的设计思路是什么, 和其他方法相比他有什么优势, 这些都不清楚, 于是决定好好分析一下. 实际上这个例子实现的功能并不复杂, 所以我的文章实际上是在讨论怎么产生出和作者相似的思路.

如果不考虑用 goroutine 的话, 思路其实很简单:

1. 列出文件列表, 编译正则.
2. 遍历文件, 打开并遍历每行, 如果正则能匹配, 记录下来.
3. 列出来.
@makotom
makotom / isbn.js
Last active March 10, 2019 14:44
ISBN tools by JS
var ISBN = (function(){
"use strict";
var validateISBN13 = function(isbnChars){
var checksum = 0;
isbnChars.forEach(function(isbnChar, key){
checksum += parseInt(isbnChar, 10) * (key % 2 === 1 ? 3 : 1);
});
@lanqy
lanqy / bytesToSize.js
Created March 19, 2013 03:05
JavaScript To Convert Bytes To MB, KB, Etc
// from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
if (i == 0) return bytes + ' ' + sizes[i];
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};
@binjoo
binjoo / CopyUtils.java
Last active December 12, 2018 12:56
JAVA:复制文件和文件夹
package com.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
/***
*
* @ClassName CopyUtils