Skip to content

Instantly share code, notes, and snippets.

@CS1000
CS1000 / broscript.js
Created September 24, 2014 23:20
Bro Script (so chat)
Paste in SO chat room console bro:
(function() {
"use strict";
var chat = document.getElementById('chat');
function parseNode(node) {
if (node.classList
&& node.classList.contains('message')
&& !node.classList.contains('pending')
&& !node.querySelector('.onebox')
@CS1000
CS1000 / mysql_ snippet.md
Last active August 29, 2015 14:07
ext/mysql snippet

***Notice:*** There is **no more support** for `mysql_*` functions, they are [**officially deprecated**](https://wiki.php.net/rfc/mysql_deprecation), **no longer maintained** and will be [**removed**](http://php.net/manual/en/function.mysql-connect.php#warning) in the future. You should update your code with [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) to ensure the functionality of your project in the future.

>Notice: There is no more support for mysql_* functions, they are officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.

@CS1000
CS1000 / rel=prev.js
Last active August 29, 2015 14:07
A rel="prev"
javascript:document.location.href=document.querySelector("a[rel=prev]").href
@CS1000
CS1000 / crazySwap.js
Last active August 29, 2015 14:07
Swap ALL the <div>s
javascript:setInterval(function(){d=document.querySelectorAll('div');
l=d.length;a=d[parseInt(Math.random()*l)];b=d[parseInt(Math.random()*l)];
c=a.innerHTML;a.innerHTML=b.innerHTML;b.innerHTML=c;}, 42)
@CS1000
CS1000 / remove_clickTrap.js
Created October 15, 2014 06:26
blogger.com PREVIEW select text
document.body.removeChild(document.querySelector('.blogger-clickTrap'))
@CS1000
CS1000 / abbr.js
Created October 26, 2014 08:24
ABBReviate in JS (aka, remove vowels)
String.prototype.abbr = function() {return this.replace(/[aeiou]+/g,'')};
//eg:
'people'.abbr()
@CS1000
CS1000 / finance.fee.js
Last active August 29, 2015 14:08
After fee
Number.prototype.fee=function(fee){return /%$/.test(fee)?this-this*parseInt(fee)/100:this-fee}
/*
// 5 off
parseInt('100').fee(5)
// 15% off
/*
* @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];
@CS1000
CS1000 / log_setContrast.js
Last active August 29, 2015 14:08
Logarithmic contrast
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
@CS1000
CS1000 / setContrast.js
Created November 2, 2014 09:44
Linear contrast
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) {