Skip to content

Instantly share code, notes, and snippets.

View cheeaun's full-sized avatar
📬
Subscribe to my newsletter https://cheeaun.substack.com/

Chee Aun cheeaun

📬
Subscribe to my newsletter https://cheeaun.substack.com/
View GitHub Profile
@cheeaun
cheeaun / Array.each.js
Created October 27, 2009 07:11
Array.each which allows 'return false' to break the loop.
// Array native is protected, so can't do Array.implement
Array.prototype.each = function(fn, bind){
for (var i = 0, l = this.length; i < l; i++){
var r = fn.call(bind, this[i], i, this);
if (r === false) break;
}
};
Native.genericize(Array, 'each', true);
/*!
* jQuery ie6ize: Emulate IE-6 rendering - 11/13/2009
* http://mankzblog.wordpress.com/2009/11/13/ie6-frame-to-battle-chrome-frame/
*
* Created by Mats Bryntse
*
* Plugin-ified by "Cowboy" Ben Alman
* http://benalman.com/
*/
@cheeaun
cheeaun / plugin.betterEmoticonsFormatter.js
Created November 18, 2009 16:57
Better Emoticons Formatter plugin for Talkerapp
// https://cheeaun.talkerapp.com/plugins/10
var path = '/images/icons/';
// 1. For humans
var emoticons = {
evil: {
image: 'smiley-evil.png',
text: '>:-) >:)'
},
@cheeaun
cheeaun / plugin.googleSearch.js
Created November 19, 2009 14:22
Google Search plugin for Talkerapp (by typing $google [query])
var url = 'http://ajax.googleapis.com/ajax/services/search/web';
plugin.onMessageInsertion = function(event){
var author = Talker.getLastAuthor();
var lastIns = Talker.getLastInsertion();
if (!lastIns.length) return;
var containsGoogle = lastIns.is(':contains($google )');
if (!containsGoogle) return;
var text = lastIns.text();
var query = $.trim(text.split('$google')[1]);
@cheeaun
cheeaun / plugin.githubGist.js
Created November 19, 2009 15:57
GitHub Gist Embed plugin for Talkerapp (just paste the gist link and voila)
(function(){
plugin.onMessageInsertion = function(event){
var lastRow = Talker.getLastRow();
if (!lastRow.length) return;
var lastP = lastRow.find('p:last');
if (!lastP.length) return;
if (lastP.find('iframe.talkerapp-plugin-gist-embed').length) return;
var gistLink = lastP.find('a[href^=http://gist.github.com]:first');
if (!gistLink.length) return;
@cheeaun
cheeaun / plugin.replyButton.js
Created November 24, 2009 06:41
Add reply button(s) plugin for Talkerapp
// https://cheeaun.talkerapp.com/plugins/56
(function(plugin, $){
var msgbox = $('#msgbox');
// Gladly stolen from
// http://github.com/mootools/mootools-more/blob/master/Source/Element/Element.Forms.js
var selectRange = function(el, start, end){
if (el.setSelectionRange) {
el.focus();
@cheeaun
cheeaun / plugin.oohEmbed.js
Created November 29, 2009 03:06
oohEmbed plugin for Talkerapp
// https://cheeaun.talkerapp.com/plugins/71
// http://code.google.com/p/jquery-oembed/
// Closure compiled jquery.oembed.js (simple)
(function(e){function n(b){for(var a=0;a<m.length;a++)if(m[a].matches(b))return m[a];return null}function f(b,a,c,i){this.name=b;this.urlPattern=a;this.oEmbedUrl=c!=null?c:"http://oohembed.com/oohembed/";this.callbackparameter=i!=null?i:"callback";this.maxWidth=500;this.maxHeight=400;this.matches=function(g){return g.indexOf(this.urlPattern)>=0};this.getRequestUrl=function(g){var d=this.oEmbedUrl;if(d.indexOf("?")<=0)d+="?";var j="";for(var h in this.params)if(h!=this.callbackparameter)if(this.params[h]!= null)j+="&"+escape(h)+"="+this.params[h];d+="format=json";if(this.maxWidth!=null)d+="&maxwidth="+this.maxWidth;if(this.maxHeight!=null)d+="&maxheight="+this.maxHeight;d+="&url="+escape(g)+j+"&"+this.callbackparameter+"=?";return d};this.embedCode=function(g,d,j){var h=this.getRequestUrl(d);e.getJSON(h,function(k){var l=e.extend(k),o=k.type;switch(o){case "photo":l.code=e.fn.oe
@cheeaun
cheeaun / plugin.privateChat.js
Created December 11, 2009 15:44
Private Chat plugin for Talkerapp, now with chat log storage.
// https://cheeaun.talkerapp.com/plugins/82
var vendorStyles = function(str){
var s = str.split('-');
if (s.length == 4 && s[0] == 'border'){
var value = s[3].split(':')[1];
return str + '-webkit-' + str + '-moz-border-radius-' + s[1] + s[2] + ':' + value + ';';
}
return str + '-moz-' + str + '-webkit-' + str;
};
@cheeaun
cheeaun / sleep.js
Created December 14, 2009 10:01
sleep() function for JavaScript.
// http://twitter.com/thomasfuchs/status/6657618059
var sleep = function(secs){
secs = (+new Date) + secs * 1000;
while ((+new Date) < secs);
};
@cheeaun
cheeaun / getGooglAuthToken.js
Created December 16, 2009 09:51
function to generate auth token from URL for goo.gl
var getGooglAuthToken = function(b){
var c = function(){
for (var l=0, m=0, ml=arguments.length; m<ml; m++) l = l + arguments[m] & 4294967295;
return l;
}
var d = function(l){
l = String(l > 0 ? l : l + 4294967296);
var m = l;
for (var o=0, n=false, p=m.length-1; p>=0; --p){
var q = Number(m.charAt(p));