Skip to content

Instantly share code, notes, and snippets.

View psycalc's full-sized avatar
💭
DevOps Learning

Raziel psycalc

💭
DevOps Learning
View GitHub Profile
@psycalc
psycalc / glueToWidnows.js
Created July 2, 2016 12:30
All open function glued to window object
function myFunction (myArg1) {
return myArg1;
}
window.myFunction(1);
@psycalc
psycalc / realJavaScriptFunction.js
Created July 4, 2016 12:11
Covert Object to Function or like real function looks like in JavaScript (Oh my God!)
var firstObject = {
name: "firstFunction",
length: 0,
prototype: parentSecondObject
};
var parentSecondObject = {
constructor: console.log("hello world")
}
firstFunction();
@psycalc
psycalc / gist:43fc16275625f952bd04fed78f356bcc
Created July 5, 2016 06:57
null, undefined, NaN, empty String (""), 0 , false defined as false
will evaluate to true if value is not:
null
undefined
NaN
empty string ("")
0
false
@psycalc
psycalc / urlAudio.js
Created July 8, 2016 06:34
Get mp3 by url
// http://www.soundjay.com/rain-sound-effect.html
var audio = new Audio("http://www.soundjay.com/nature/rain-01.mp3");
audio.play();
@psycalc
psycalc / wikipediaApiExample.ps1
Created July 10, 2016 16:06
Example of using wikipedia api by powershell
irm -Uri "https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json" -Method Get
@psycalc
psycalc / wikipediaApi.js
Last active November 21, 2016 20:59
Working wikipedia api by javascript example
var remoteUrlWithOrigin = "https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json";
// Using jQuery
jQuery.ajax( {
url: remoteUrlWithOrigin,
//because of cross-orginig error that is why jsonp
dataType: 'jsonp',
type: 'GET',
//which function to call when all is succeseed
success: function(data) {
// do something with data
@psycalc
psycalc / deleteChildNodes.js
Last active July 16, 2016 07:12
clear (remove,delete) all child elements (for example clear old search results in global div container) plain javascript (ecma script) analog of jQuery function "empty"
//jQuery: $("#foo").empty();
var myNode = document.getElementById("foo");
while (myNode.firstChild) {
myNode.removeChild(myNode.firstChild);
}
@psycalc
psycalc / cancelSearchButtonHandler.js
Last active July 13, 2016 07:01
Handle (trigger) cancel search button
//plain javascript getElementById("search").addEventListener("oninput",function (e) {...});
$('#search').on('input', function(e) {
if('' == this.value) {
//here push your code
}
});
@psycalc
psycalc / cyclePagination.js
Last active July 14, 2016 07:21
cycle pagination through huge amount of pages
//try to find 7923
for (var i=Number(window.location.href.toString().replace(/\D/ig,""));i<=7923;i++) {
window.location.href = window.location.href.replace(/\d/ig,"") + i;
}
@psycalc
psycalc / gist:97adba2795e368a2826fbca514c30102
Last active July 17, 2016 07:49
prototype it is middle varibale tha save value for "new ConcturtorOBject("blabla"); that use it for __proto__ = [[ValueFromPrototypeProperty]]
var animal = {
eats: true
};
function Rabbit(name) {
this.name = name;
//this.__proto__ = animal;
}
Rabbit.prototype = animal;// what save to __proto__ after calling new Rabbit("string"); this line does not do anything, it require new operator