Skip to content

Instantly share code, notes, and snippets.

View round's full-sized avatar
🎯
Focusing

Maxim Leyzerovich round

🎯
Focusing
View GitHub Profile
@round
round / script.js
Created September 21, 2020 19:47
Self unwrapping <script> tag
<script>
var thisScript = document.scripts[document.scripts.length - 1];
var parent = thisScript.parentElement;
const wrapper = document.createElement('div');
wrapper.innerHTML = 'Output';
parent.replaceChild(wrapper.firstChild, thisScript);
</script>
@round
round / svg2png.js
Created January 15, 2019 05:41 — forked from gustavohenke/svg2png.js
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@round
round / xpath.php
Created December 8, 2018 04:35
XPath getElementsByClassName equivalent
$xpath = new DOMXpath($dom);
$items = array();
$expression = './/div[contains(concat(" ", normalize-space(@class), " "), " class-name ")]';
foreach ($xpath->evaluate($expression) as $div) {
$items[] = $div;
}
echo $items[0]->getAttribute('otherattribute');
@round
round / index.php
Created December 3, 2018 01:16
PHP Page Proxy
<?php
//header('Content-Type: application/atom+xml');
$url='http://example.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
@round
round / night-shift.scpt
Created October 26, 2018 01:50
Toggle Night Shift
tell application "System Preferences"
activate
reveal anchor "displaysNightShiftTab" of pane id "com.apple.preference.displays"
delay 1
end tell
tell application "System Events"
tell process "System Preferences"
click checkbox 1 of tab group 1 of window 1
end tell
@round
round / mode-toggle.scpt
Created October 26, 2018 01:47
Toggle Dark/Light Mode
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
@round
round / grayscale.scpt
Created October 13, 2018 19:04
Toggle Grayscale (Mojave)
tell application "System Preferences"
reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"
end tell
tell application "System Events" to tell process "System Preferences"
repeat while not (exists of checkbox "Use grayscale" of group 1 of window "Accessibility")
delay 0.1
end repeat
set theCheckbox to checkbox "Use grayscale" of group 1 of window "Accessibility"
tell theCheckbox
@round
round / packages.json
Last active February 21, 2019 09:17
Atom Editor Custom Interface: Packages & User Styles
[
{
"name": "about",
"version": "1.10.0"
},
{
"name": "animated-page-scroll",
"version": "1.2.0"
},
{
@round
round / preferences.json
Created November 23, 2016 05:45
Emmet Config (single quote, closing comment with attribute)
{
"filter.commentAfter" : "<!--<%=attr('id', '#') %><%= attr('class', '.')%>-->"
}
@round
round / bounce.js
Last active August 29, 2015 14:27
Increment a value up and down.
var up = true;
var value = 0;
var increment = 1;
var ceiling = 100;
var floor = -100;
if (up == true && value <= ceiling) {
value += increment
if (value == ceiling)
{up = false;}