Skip to content

Instantly share code, notes, and snippets.

@CS1000
CS1000 / broscript.js
Created Sep 24, 2014
Bro Script (so chat)
View broscript.js
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 Aug 29, 2015
ext/mysql snippet
View mysql_ snippet.md

***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 Aug 29, 2015
A rel="prev"
View rel=prev.js
javascript:document.location.href=document.querySelector("a[rel=prev]").href
@CS1000
CS1000 / crazySwap.js
Last active Aug 29, 2015
Swap ALL the <div>s
View crazySwap.js
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 Oct 15, 2014
blogger.com PREVIEW select text
View remove_clickTrap.js
document.body.removeChild(document.querySelector('.blogger-clickTrap'))
@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()
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
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];
@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 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) {