Skip to content

Instantly share code, notes, and snippets.

/* Lightweight ultrafast and powerful EventEmitter that built on the native JavaScript emitter.
*
* @param this (Object) An optional parameter that allows to extend any object
* @returns Object (EventBus|this)
*/
function EventBus (that) {
var that = that || this,
id = (new Date).getTime() + "" + Math.random(),
node = document.createElement("EventBus"),
recent = {};
@w3core
w3core / editor.html
Created July 11, 2016 17:37
Tiny code editor with preview
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ext-language_tools.js"></script>
</head>
<body>
<style>
body{
margin: 0;
}
iframe,
@w3core
w3core / crisp-images.css
Created June 16, 2016 11:37
CSS3 crisp image
* {
image-rendering: -webkit-optimize-contrast;
image-rendering: -moz-crisp-edges;
image-rendering: -o-crisp-edges;
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor;
}
@w3core
w3core / angular-translate-stylesheet-files.js
Last active May 19, 2016 13:01
Translates all textual parts of "content" rule in CSS stylesheet file. Accepts an optional `translate-values` interpolate parameters to pass dynamized values though translation.
/*!
* angular-translate - v2.10.0 - 2016-02-28
*
* Copyright (c) 2016 The angular-translate team, Pascal Precht; Licensed MIT
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define([], function () {
return (factory());
@w3core
w3core / youtube-vimeo-url-parser.js
Last active November 11, 2020 09:00 — forked from yangshun/youtube-vimeo-url-parser.js
YouTube Vimeo URL Parser
function parseVideo (url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - http://y2u.be/huKvjPQ-Xm4
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - http://www.youtube.com/embed/Ab25nviakcw
// - http://www.youtube-nocookie.com/v/Ab25nviakcw?version=3&hl=en_US
// - http://www.youtube.com/watch?feature=player_embedded&v=Ab25nviakcw#
// - Supported Vimeo URL formats:
@w3core
w3core / tools.js
Last active October 17, 2016 10:40
Tools
(new function(that){
var TRUE = !0, FALSE = !1, NULL = null, UNDEFINED = undefined, NAN = NaN, INFINITY = Infinity, PINFINITY = +Infinity, NINFINITY = -Infinity;
var _OBJECT_ = that._OBJECT_ = "object",
_STRING_ = that._STRING_ = "string",
_NUMBER_ = that._NUMBER_ = "number",
_BOOLEAN_ = that._BOOLEAN_ = "boolean",
_FUNCTION_ = that._FUNCTION_ = "function",
_UNDEFINED_ = that._UNDEFINED_ = "undefined",
_EMAIL_ = that._EMAIL_ = "email",
@w3core
w3core / dynamic.less.js
Created January 26, 2016 17:54
This plugin extends Less.JS processor for "attach(url)" and "detach(url)" methods, that allows dynamically attach/detach ".less" files to document.
/**
* Attach LESS file: less.attach(url)
* Detach LESS file: less.detach(url)
*/
(new function(){
if (typeof less == "undefined") less = {sheets:[], refresh:function(){}};
function extractId (href) {
return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain
.replace(/^\//, '' ) // Remove root /
@w3core
w3core / string.colors.node.js
Last active December 9, 2015 11:03
Extends String object with properties that returns colorized values of string. Can be useful for "console.log" output.
function StringStyler () {
function add (color, value) {
String.prototype.__defineGetter__(color, function(){
return "\u001b[" + value[0] + "m" + this + "\u001b[" + value[1] + "m";
});
}
var codes = {
reset: [0, 0],
bold: [1, 22],
@w3core
w3core / console.log.js
Created December 4, 2015 07:32
Google Chrome console.log() output with applied CSS
console.log('%c' + 'Hello Console!', '\
font-size: 2em; \
background: red url("http://a.im9.eu/blonde-milf-hardcore-fucking-big-boobs.gif") no-repeat center center; \
background-size: 100% 100%; \
font-weight: bold; \
color: white; \
text-shadow: 0 0 1px black; \
padding: 0 10% 25%; \
border: .1em solid rgba(0,0,0,.4); \
border-radius: 1em; \
@w3core
w3core / sqlmap-wizard.sh
Last active July 30, 2016 15:53
SQLMap wizard script
#!/bin/sh
SCRIPT="./sqlmap/sqlmap.py"
echo "SQLMap wizard script\n===================="
while true; do
read -p "Execute through the TOR (Y/n, default: [Y]es)? " TOR
TOR=${TOR:-Y}
case $TOR in