Skip to content

Instantly share code, notes, and snippets.

@CS1000
CS1000 / JamExchange.js
Last active Jul 17, 2017
JamExchange Room @so Live Radio like Player with "User Requests" (YouTube only, UserScript)
View JamExchange.js
// ==UserScript==
// @name JamExchange Player
// @namespace jamexchange
// @description JamExchange Room @SO Live Radio like Player with "User Requests" (YoutTube only)
// @include http://chat.stackoverflow.com/rooms/39426/*
// @version 1.1.0
// @grant none
// ==/UserScript==
/*
@CS1000
CS1000 / syntax-highlight_regex.MD
Last active Aug 29, 2015
google-code-prettify renderings of REGEX with supported Languages
View syntax-highlight_regex.MD

sh

/^(d*([.,](?=d{3}))?d+)+((?!\2)(?R)(?1)\K\R\n\r[a-z\d])[.,]dd)?$/

c

@CS1000
CS1000 / hide_answers.js
Created Apr 2, 2015
SNIPPET to hide all answers on a StackExchange post, except the one linked to (hash anchor, eg. #id) if exists.
View hide_answers.js
javascript:(function(){$(".answer").each(function(i,n){if(n.id!==('answer'+document.location.hash).replace(/#/,'-'))n.style.display="none"})})()
@CS1000
CS1000 / colornames.js
Last active Aug 29, 2015 — forked from rlemon/colornames.js
For use on Miaou (add "color: <#hexcolor || colorname>" somewhere in your profile->about me)
View colornames.js
function hashCode(str) {
var hash = 0;
str += '!';
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return -hash;
}
function colorCode(i) {
return '#' + (Math.min((i >> 24) & 0xFF, 200).toString(16) +
View setContrast.js
function setContrast(rgb, perc)
{
perc = perc / 100;
ret = {}
Object.keys(rgb).map(function(v) {
col = rgb[v];
if (perc <= 0) {
col += (col - 128) * perc; // ---> 128
} else {
if (col < 128) {
@CS1000
CS1000 / log_setContrast.js
Last active Aug 29, 2015
Logarithmic contrast
View log_setContrast.js
function setContrast(rgb, perc)
{
ret = {}
Object.keys(rgb).map(function(v) {
col = rgb[v];
if (perc <= 0) {
col += (col - 128) * perc / 100; // ---> 128
} else {
if (col < 128) {
//bad start
View shadeColorTone.js
/*
* @param rgb = Object {r, g, b}
* @param percent = int (-100 to 100)
*/
function shadeColorTone(rgb, percent)
{
perc = 1 + percent / 100;
ret = {}
Object.keys(rgb).map(function(v) {
col = rgb[v];
View finance.fee.js
Number.prototype.fee=function(fee){return /%$/.test(fee)?this-this*parseInt(fee)/100:this-fee}
/*
// 5 off
parseInt('100').fee(5)
// 15% off
@CS1000
CS1000 / abbr.js
Created Oct 26, 2014
ABBReviate in JS (aka, remove vowels)
View abbr.js
String.prototype.abbr = function() {return this.replace(/[aeiou]+/g,'')};
//eg:
'people'.abbr()
@CS1000
CS1000 / remove_clickTrap.js
Created Oct 15, 2014
blogger.com PREVIEW select text
View remove_clickTrap.js
document.body.removeChild(document.querySelector('.blogger-clickTrap'))