Skip to content

Instantly share code, notes, and snippets.

@nothinking
nothinking / LazyImageLoader.js
Created May 9, 2012 02:36
javascript: LazyImageLoader.js
var LazyImageLoader = (function(){
var threshold = 150;
var isInitialized = false;
var tid = null;
var isFirst = true;
var loadImagesInHere = function(){
var images = daum.$$("img:not([src])");
var minY = daum.Browser.getScrollOffsets().top;
var maxY = minY + ( window.innerHeight || 800 );
@nothinking
nothinking / .bash_profile
Last active December 16, 2015 06:58
dotfile: .bash_profile
# Easier navigation: .., ..., ~ and -
alias ..="cd .."
alias cd..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# Detect which `ls` flavor is in use
@nothinking
nothinking / data-remove.sh
Last active December 16, 2015 14:39
bash: data remove: 데이타 수집서버나 mysql 리플리케이션 Master 서버의 경우 지속적으로 파일이 추가되고 늘어나기 때문에 주기적인 디스크 정리 정책이 없으면 금새 디스크 풀 의 상태에 도달하게 된다.이런 상황에서 간단하게 사용할 수 있는 디스크 정리 스크립트를 소개한다.
#데이타가 쌓이는 디렉토리가 /data1/crawl_data 라면 아래 스크립트는 최근 300 개만 남기고 파일을 지운다.
#!/bin/bash
DATE=`date +'%Y%m%d_%H%m%S'` ## 로그 기록을 위해 작업시간을 기록한다.
BACKUPCOUNT=300 ## 최근 300 개만 남기고 지운다.
WORKDIR=/data1/crawl_data
dirlist=`/bin/ls -t $WORKDIR`
i=1;
for fd in $dirlist; do

gist.io test

// Given a query string "?to=email&why=because&first=John&Last=smith"
// getUrlVar("to") will return "email"
// getUrlVar("last") will return "smith"
// Slightly more concise and improved version based on http://www.jquery4u.com/snippets/url-parameters-jquery/
function getUrlVar(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && unescape(result[1]) || "";
}
@nothinking
nothinking / jquery.textareaAutoResize.js
Created June 12, 2013 01:28
javascript: jquery.textareaAutoResize.js
/**
* This jQuery plugin resizes a textarea to adapt it automatically to the content.
* @author Amaury Carrade
* @version 1.1
*
* @example $('textarea').autoResize({
* animate: { // @see .animate()
* enabled: true, // Default: false
* duration: 'fast', // Default: 100
* complete: function() {}, // Default: null
@nothinking
nothinking / Prefix.pch
Created October 28, 2013 04:51
iOS Macro
// define UIColor macro
#define UIColorRGBMake(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]
// iOS version check macro
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#!/bin/sh
export DEVELOPER_DIR="/Applications/XCode.app/Contents/Developer"
SYMBOLICATECRASH=`find /Applications/Xcode.app -name symbolicatecrash -type f`
${SYMBOLICATECRASH} -v "$1"
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter