Skip to content

Instantly share code, notes, and snippets.

View psycalc's full-sized avatar
💭
DevOps Learning

Raziel psycalc

💭
DevOps Learning
View GitHub Profile
buttonClickEventHandler(); //если нужно при первом запуске получить json чик
$("#quote-button").on("click",buttonClickEventHandler)
function buttonClickEventHandler(e) {
$.ajax({
url: 'https://andruxnet-random-famous-quotes.p.mashape.com/?cat=movies', // указываем URL и
dataType: "json", // тип загружаемых данных
headers: {
"X-Mashape-Key": "", //здесь должен быть ключ по котромую даеться доступ выдаеться провайдером REST API
"Accept": "application/json"
},
//<div id="floating-panel" data-toggle="hello i am data-toggle value">
//...
//</div>
var dataToggleStr=document.getElementById("floating-panel").dataset.toggle;
console.log(dataToggleStr); //"hello i am data-toggle value"
@psycalc
psycalc / googleLatitudeLongtitudeConvert.js
Last active June 23, 2016 10:04
Thanks to google api convert latitiude and longtitude to string of street, number of house, state (region),city, country
// in html <script src="https://maps.googleapis.com/maps/api/js?key=GOOGLE_API_FOR_GEOCODER&signed_in=true&callback=initGeocoder" defer></script>
var currentLat;
var currentLng;
//callback is success
function success(pos) {
var crd = pos.coords;
currentLat = crd.latitude;
currentLng = crd.longitude;
};
//callback if error
@psycalc
psycalc / googleUri.html
Created June 23, 2016 10:40
Kind version to send people to google
//+ it is space
//&hl=ru languge for search in google
https://www.google.com/search?q=javascript+tutorials&hl=ru
@psycalc
psycalc / ExampleUsingWeatherApi.js
Last active June 30, 2016 06:04
Example weather of using api by javascript
$.ajax({
url: 'https://simple-weather.p.mashape.com/weatherdata?lat=' + coords[0] + '&lng=' + coords[1],
type: 'GET',
dataType: 'json',
success: function(data) {
console.log(data.query.results.channel.item.condition.temp);
var unit = data.query.results.channel.units.temperature;
$(".country").html(data.query.results.channel.location.country);
$(".city").html(data.query.results.channel.location.city);
@psycalc
psycalc / urlImageSize.js
Last active June 30, 2016 10:29
Get image size from url
function getMeta(url){
var img = new Image();
img.addEventListener("load", function(){
alert( this.naturalWidth +' '+ this.naturalHeight );
});
img.src = url;
}
getMeta("http://.../... .png");
@psycalc
psycalc / dynamicDivResizer.js
Last active June 30, 2016 11:16
Resize div by background image size
var url = "http://.../...png";
var img = new Image();
img.addEventListener("load", function() {
var foundElement = document.getElementsByClassName("MyClassNameForDivWithBackgroundImage")[0];
foundElement.style.width = this.naturalWidth+"px";
foundElement.style.height = this.naturalHeight+"px";
});
img.src = url;
@psycalc
psycalc / consoleBrowser.ps1
Created July 1, 2016 17:16
PowerShell Console Browser
NAME
Invoke-RestMethod
SYNTAX
Invoke-RestMethod [-Uri] <uri> [-Method <WebRequestMethod> {Default | Get | Head | Post | Put | Delete | Trace | Options | Merge | Patch}] [-UseBasicParsing] [-WebSession <WebRequestSession>]
[-SessionVariable <string>] [-Credential <pscredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>] [-Certificate <X509Certificate>] [-UserAgent <string>] [-DisableKeepAlive]
[-TimeoutSec <int>] [-Headers <IDictionary>] [-MaximumRedirection <int>] [-Proxy <uri>] [-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] [-ContentType <string>]
[-TransferEncoding <string> {chunked | compress | deflate | gzip | identity}] [-InFile <string>] [-OutFile <string>] [-PassThru] [<CommonParameters>]
@psycalc
psycalc / WikiSearchSuggestion
Created July 1, 2016 18:09 — forked from camelcc/WikiSearchSuggestion
A search suggestion using jQueryUI autocomplete + Wikipedia API.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery demo - wikipedia suggestion</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
</head>
<body>
@psycalc
psycalc / index.html
Last active July 2, 2016 10:56
Covert string to code that can be performed (invoked, run, call and so on)
<!-- need bootstrap.css for quick start -->
<div class="container">
<h2>Form control: textarea</h2>
<p>The form below contains a textarea for comments:</p>
<form role="form">
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="5" id="comment"></textarea>
<button type="button" class="btn btn-default">Default</button>
</div>