Skip to content

Instantly share code, notes, and snippets.

View loktar00's full-sized avatar
🏠
Working from home

Jason loktar00

🏠
Working from home
View GitHub Profile
// perf improvement for answer http://stackoverflow.com/questions/20452317/jquery-droppable-iframe-offset
var $scrollParent = m[i].element.closest("html,body");
m[i].offset.top -= $scrollParent.scrollTop();
m[i].offset.left -= $scrollParent.scrollLeft();
// iframe positioning
if (this.current.options.iframeOffset) {
m[i].offset.top += this.current.options.iframeOffset.top;
m[i].offset.left += this.current.options.iframeOffset.left;

So, you want to send a motherfucking XMLHttpRequest (XHR, or commonly and falsly known as AJAX.) Too bad, just ran out of motherfucking XMLHttpRequests; but I still have one regular. XHR is not magic. It does not autofuckinmagically send things the way you want them do be sent. It does not do the thinking for you. It just sends an Http Request.

You get a hold on such a prime beast like this:

@loktar00
loktar00 / chatfavicon userscript
Last active August 29, 2015 14:02
User script for animated favicon on the SO Chatrooms
// ==UserScript==
// @name Favicon update for pinned chat
// @version 0.1
// @description Updates the favicon with the message count
// @match http://chat.stackoverflow.com/*
// ==/UserScript==
var canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d'),
origFav = document.querySelector('[rel="shortcut icon"]'),
@loktar00
loktar00 / gist:06ee311ac63106d7d044
Last active August 29, 2015 14:15
JavaScript room meeting

Topics for the upcoming meeting February 21st 1pm (-6 Central)

Comment and bring up any topics and Ill add them to the list.

#Topic List

  1. Room Challenges, should we continue having them, change the way we do them, or just consider it a good but complete experiment?
  2. Discuss our policy on job postings within the chat.
  3. Discuss adding and removing room owners
  4. Room sponsored/hosted game jam?
@loktar00
loktar00 / conclusions.md
Last active August 29, 2015 14:15
Javascript Room Meeting

Conclusions to the JS meeting held Feb 21st 2015

  1. Room stars in the meeting room
  2. Do not unstar previous messages upon starting a new meeting
  3. Room Challenges
  4. No more organized room challenges, instead a list of resources that are refreshed weekly hosted at https://github.com/JavaScriptRoom/
  5. Job postings within the room
  6. If it's a regular they can pin it. If it's just some programmer can pin/star for a few hours and that's it. If it gets spammy, too out of hand we can readdress.
  7. Room owners promotions/demotions
  8. Jhawins - keep as is
@loktar00
loktar00 / gist:1211640
Created September 12, 2011 16:06
Get elements by classname cross browser
function byClass(matchClass){
if (!document.getElementsByClassName){
var elements = document.getElementsByTagName('*'),
i=0,
nodeList = [],
reg = new RegExp('(^|\\s)' + matchClass + '(\\s|$)')
for (i=0; i < elements.length;i++)
{
if(elements[i].className.match(reg) !== null){
@loktar00
loktar00 / gist:1228163
Created September 20, 2011 02:24
Finds all the points between 2 coordinates.
// find all points between 2 pooints http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
var x1 = mouseX,
x2 = lastX,
y1 = mouseY,
y2 = lastY;
var steep = (Math.abs(y2 - y1) > Math.abs(x2 - x1));
if (steep){
var x = x1;
@loktar00
loktar00 / extend.js
Created February 8, 2012 14:09
Extend a js object
// For extending the default object with properties
extend = function(obj, extObj){
for(var i in extObj){
if(obj.hasOwnProperty(i)){
obj[i] = extObj[i];
}
}
}
@loktar00
loktar00 / gist:2885774
Created June 7, 2012 00:45
metaball part 2
var grad = tempCtx.createRadialGradient(point.x, point.y, 1, point.x, point.y, point.size);
tempCtx.beginPath();
grad.addColorStop(0, 'rgba(' + colors.r +',' + colors.g + ',' + colors.b + ',1)');
grad.addColorStop(1, 'rgba(' + colors.r +',' + colors.g + ',' + colors.b + ',0)');
tempCtx.fillStyle = grad;
tempCtx.arc(point.x, point.y, point.size, 0, Math.PI*2);
tempCtx.fill();
@loktar00
loktar00 / gist:2885786
Created June 7, 2012 00:49
2d metaballs source
var canvas = document.getElementById("canvas"),
ctx = canvas.getContext("2d"),
tempCanvas = document.createElement("canvas"),
tempCtx = tempCanvas.getContext("2d"),
width = 512,
height = 512,
threshold = 210,
colors = {r:255,g:0,b:0}, cycle = 0,
points = [];