Skip to content

Instantly share code, notes, and snippets.

View pointofpresence's full-sized avatar
🏠
Working from home

ReSampled pointofpresence

🏠
Working from home
View GitHub Profile
@pointofpresence
pointofpresence / createAndUseCssVariable.css
Last active May 17, 2020 09:11
Как создать и использовать CSS-переменную?
:root {
--main-bg-color: brown;
}
.one {
background-color: var(--main-bg-color);
}
@pointofpresence
pointofpresence / cookieLib.js
Last active December 28, 2019 10:15
get / set / erase cookies
function setCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
@pointofpresence
pointofpresence / cookieLib_ES6.js
Created December 28, 2019 10:29
get / set / erase cookies (ES6)
export function setCookie(name, value, days) {
let expires = ''
if(days) {
const date = new Date()
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
expires = '; expires=' + date.toUTCString()
}
@pointofpresence
pointofpresence / geoPositionAsPromise.js
Last active January 10, 2020 07:23
getCurrentPosition promised
var getPosition = function (options) {
return new Promise(function (resolve, reject) {
navigator.geolocation.getCurrentPosition(resolve, reject, options);
});
}
getPosition()
.then((position) => {
console.log(position);
})
@pointofpresence
pointofpresence / getCurrentPosition.js
Last active May 19, 2020 18:01
Created with Copy to Gist
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('Your current position is:');

HTML Blob in <iframe>

A little hack to test isolated HTML template previewing within a <iframe> using Blob - without need for another server request.

A Pen by grimen on CodePen.

License.

@pointofpresence
pointofpresence / gulpCrashFix.txt
Last active January 19, 2020 19:15
if gulp can't run,..
npm install --unsafe-perm=true
@pointofpresence
pointofpresence / google-adsense-react-component.js
Last active January 20, 2020 18:23
Google Adsense React Component
import React from 'react';
import PropTypes from 'prop-types';
export default class Google extends React.Component {
componentDidMount() {
if(window) (window.adsbygoogle = window.adsbygoogle || []).push({});
};
render() {
return (
@pointofpresence
pointofpresence / saveJSONToFile.php
Last active May 19, 2020 17:02
Save JSON to file
<?php
$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($response, JSON_UNESCAPED_UNICODE));
fclose($fp);
// or file_put_contents('results.json', json_encode($response, JSON_UNESCAPED_UNICODE))
@pointofpresence
pointofpresence / loadJSONFIle.php
Last active May 19, 2020 17:59
Load JSON file
<?php
$json = json_decode(file_get_contents($file), true);