Allows you to assign an event handler to an element.
function addEvent(obj, eventName, callback){
if (obj.addEventListener){
obj.addEventListener(eventName, callback, false);
} else if (obj.attachEvent){
getSize : function () { | |
if (isBody(this)) | |
return this.getWindow().getSize(); | |
return { | |
x : this.offsetWidth || styleNumber(this, 'width'), | |
y : this.offsetHeight || styleNumber(this, 'height') | |
}; | |
} |
/* | |
1. post a link in chat. (ex. https://github.com/) | |
2. post anything with 3 or more "w"s in a row. (ex. www, wowww,wwwwwwwwww) | |
3. use {/geturl} and you'll get the word with the 3 "w" in it and not the url. | |
Fix: Validate url. | |
*/ | |
var url:String = "http://www.google.com"; | |
var regex:RegExp = /^http(s)?:\/\/((\d+\.\d+\.\d+\.\d+)|(([\w-]+\.)+([a-z,A-Z][\w-]*)))(:[1-9][0-9]*)?(\/([\w-.\/:%+@&=]+[\w- .\/?:%+@&=]*)?)?(#(.*))?$/i; | |
trace(regex.test(url)); // returns true if valid url is found |
<?php | |
trait OrderByRandomTrait | |
{ | |
/** | |
* Scope to order by random. | |
* | |
* @param \Illuminate\Database\Query\Builder $query | |
* @return \Illuminate\Database\Query\Builder | |
*/ | |
public function scopeOrderByRandom($query) |
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
class User extends Model | |
{ | |
/** | |
* Scope a query to return a random users Model. |
// More elaborate code can be found here: | |
// https://github.com/jquery/jquery/blob/master/src/manipulation.js | |
function prepend(target, elem) { | |
target.insertBefore(elem, target.firstChild); | |
} | |
function append(target, elem) { | |
target.appendChild(elem); | |
} |
/* | |
cleaner than hard-coding the desired font size | |
refs: http://api.jquery.com/css/ | |
some use case: | |
all these websites that use *huge* font sizes, | |
painful to read even on a 1920x1080 screen. | |
*/ | |
$('.article-content').css('font-size', '-=2'); |
/* | |
It was just an idea I had to help mitigate some ddos by having many servers and hiding the real ip of the server using this then we could monitor each one and filter or turn them off as needed etc. | |
*/ | |
var net = require('net'); | |
function ProxyServer(localport, remoteip, remoteport) { | |
if (remoteport === undefined) | |
remoteport = localport; | |
var server = net.createServer({ | |
allowHalfOpen : false, |
'use strict'; | |
var forEach = angular.forEach; | |
angular.module('ngTouchNav') | |
.config(function($animateProvider) { | |
$animateProvider.register('', ['$window','$sniffer', '$timeout', function($window, $sniffer, $timeout) { | |
var noop = angular.noop; |