Skip to content

Instantly share code, notes, and snippets.

View CezaryDanielNowak's full-sized avatar

Cezary Nowak CezaryDanielNowak

View GitHub Profile
@CezaryDanielNowak
CezaryDanielNowak / gist:5048861
Last active December 14, 2015 07:09
auto-fill form by javascript console.
$($0 || 'body').find('input[type=text], input[type=text], textarea,input[type=password]').filter(':visible').each(function(){
if( $(this).attr('type')==='password' )
return $(this).val('12345678');
if( $(this).attr('id')==='email' || $(this).attr('name')==='email' )
return $(this).val('[email protected]');
if( $(this).attr('name') == 'cvv2' )
return $(this).val('123');
@CezaryDanielNowak
CezaryDanielNowak / windows-command-line-helpers-generator
Last active December 16, 2015 13:29
Window commands. Put it in:c:\windows\system32\or add yours include path.
echo @dir /O:G %* > ls.bat
copy /A ls.bat ll.bat
echo C:\wamp\bin\php\php5.3.13\php.exe %* > php.bat
echo php "C:\wamp\bin\php\php5.3.13\composer.phar" %* > composer.bat
echo ipconfig | find "Adres IPv4" > myip.bat
echo @for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i > whereis.bat
jQuery.fn.loadSerializedData = function(data)
{
var dataObj = {},
keyValPair;
data = data.split('&');
for (var i = 0, length = data.length; i < length; i++) {
keyValPair = data[i].split('=');
dataObj[decodeURIComponent(keyValPair[0])] = decodeURIComponent(keyValPair[1]);
}
@CezaryDanielNowak
CezaryDanielNowak / findDuplicatedIDs.js
Last active December 18, 2015 09:49
Find elements with duplicated ID
(function(field, scope) {
var id,
allIds = {},
elementsWithId = scope.querySelectorAll('[' + field + ']');
Array.prototype.forEach.call(elementsWithId, function(elem) {
if(field.substr(0,5) === 'data-') {
id = elem.dataset[field.substr('5')];
} else {
id = elem[field];
@CezaryDanielNowak
CezaryDanielNowak / link-avability-checker.js
Created July 4, 2013 12:05
link-avability-checker.js
@CezaryDanielNowak
CezaryDanielNowak / script-performance-test.js
Last active December 19, 2015 09:49
Tool for testing script performance from console. It includes jquery
var testReplies = 10000,
use$ = false,
testCode = function() {
/* code to test */
//when use$ is enabled, $(this) is #actionBox, use it as your container
//#actionBox will be removed after test
},
actionBoxConfigure = function(){
/* put elements into actionBox here */
(function() {
var makeWebsiteCreazy = function() {
var toanim = document.querySelectorAll('h1,h2,h3,h4,h5,img,input'); //,div:last-child
window.onscroll = function() {
[].forEach.call(toanim, function(el) {
var pickOne = parseInt( Math.random() * 6 ) + 1;
el.style.transition = 'all 2000ms ease-in-out';
el.style.transform = "scale(" + (pickOne==1 ? Math.random()*1.5 : 1) + ') rotate('+( pickOne==2 ? Math.random()*90 : 0 )+'deg) translateX('+( pickOne==3 ? Math.random()*20 : 0 )+'px) translateY('+( pickOne==4 ? Math.random()*20 : 0 )+'px) skewX('+( pickOne==5 ? Math.random()*90 : 0 )+'deg) skewY('+( pickOne==6 ? Math.random()*90 : 0 )+'deg)';
});
@CezaryDanielNowak
CezaryDanielNowak / jquery.google-webfonts-switcher.js
Last active December 20, 2015 04:59
You can paste it on any page (in console or body) and check, how it will look with different font.
@moved to: https://github.com/korpirkor/live-google-webfont-switcher/
// Make it safe to do console.log() always.
(function (c) {
var method,
d = function() {},
m = 'assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,\
groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn'
.split(',');
while (method = m.pop()) {
c[method] || (c[method] = d);
}
@CezaryDanielNowak
CezaryDanielNowak / javascript-is-funny.js
Last active May 31, 2017 20:13
Javascript is funny
// run test in you javascript console.
var info = console.log, test = (function() {
var result = function(code) {
return result.codePad(code, eval(code));
},
strPad = function(str, pad) {
var len = str.length;
return len >= pad ? str : Array(pad - len + 1).join(' ') + str;
}