Skip to content

Instantly share code, notes, and snippets.

@egorvinogradov
egorvinogradov / svg-outer-html.js
Created May 6, 2017 08:50
Get SVG element's outerHTML
// Usage:
// getSVGOuterHTML('.icon-preview__svg svg');
function getSVGOuterHTML(selector){
var icon = document.querySelector(selector);
var attrs = Array.prototype.map.call(icon.attributes, function(attr){
return attr.name + '="' + attr.value + '"';
}).join(' ');
return '<svg ' + attrs + '>' + icon.innerHTML + '</svg>';
}
var names = [
'Catherine',
'Brenda',
'Cecilia',
'Grazy',
'Artem',
'Sage',
'Vanessa',
@egorvinogradov
egorvinogradov / switch-dev-prod.js
Created September 8, 2016 03:45
Bookmark for dev/prod quick switch
javascript:(function(){ location.href = (location.hostname === 'localhost' ? 'https://paulcamper.com' : 'http://localhost:3000') + location.pathname; }()); void(0);
Текст вводится НА АНГЛ. ЯЗЫКЕ в формате:
H; ; 1=450; 2=355; 3=290
R; The Monroe Apts; 1=432; 2=370; 3=310
R; Columbus Residence; 1=432;
Каждый вариант жилья на новой строке.
Фичи жилья разделены точками с запятой, где:
1) Буква H или R — тип (Homestay или Residence)
<?php
/**
* @package Resonar
* @since Resonar 1.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
if ( has_post_thumbnail() && ! post_password_required() ) :
@egorvinogradov
egorvinogradov / content-single.php
Last active January 21, 2016 04:45
Available Courses
<?php
// Inside <div class="entry-content">
// docs/wp-content/themes/resonar/content-single.php
$locale_data = localize_school_page(get_post_custom($ID), ICL_LANGUAGE_CODE);
echo "<h3>" . $locale_data['labels']['select_program_and_dates'] . '</h3>';
foreach ($locale_data['programs'] as $program) {
javascript: (function (){ var scripts = document.getElementsByTagName('script'); var friendsList; for (var i = 0; i < scripts.length; i++) { var script = scripts[i]; if (script.innerHTML.indexOf('InitialChatFriendsList') > -1) { var friendsListString = script.innerHTML.split('"InitialChatFriendsList",[],{"list":')[1].split(',"groups"')[0]; friendsList = JSON.parse(friendsListString); console.log('friendsList:', friendsList); break; } } var html = friendsList.map(function(id, i){ id = id = id.split('-')[0]; var url = 'http://graph.facebook.com/' + id + '/picture?type=normal'; return '<a target="_blank" href="https://www.facebook.com/' + id + '"><img src="' + url + '"></a>'; }).join('\n'); var css = '<style> a { display: inline-block; margin: 7px; } img { max-width: 70px; max-height: 70px; vertical-align: top; } </style>'; open('data:text/html, <html>' + css + html + '</html>'); }());
function req(data){
$.ajax({
url: 'https://',
method: 'POST',
data: JSON.stringify(data),
contentType: 'application/json',
headers: {
'x-csrftoken': 'xpUoEKTvASGAYOhaFoPy3Boj4aGM4zsF'
},
success: function(data){
{
/*
* ENVIRONMENTS
* =================
*/
"es3": true,
// Define globals exposed by modern browsers.
"browser": true,
REQUIRED_KEYS = [
"API_SERVER_URL"
]
ENVIRONMENT = {}
for key in REQUIRED_KEYS
unless key of process.env
console.error "MISSING REQUIRED KEY: " + key
process.exit 1