Skip to content

Instantly share code, notes, and snippets.

View nleush's full-sized avatar

Nazar Leush nleush

  • http://itteco.com
View GitHub Profile
@nleush
nleush / iterm2-python-open-multiple-sessions.py
Last active April 14, 2022 20:44
iTerm2: open multiple sessions and run commands, allow many tabs and 2 to 4 panes splits in one tab
#!/usr/bin/env python3.7
import iterm2
# Each top level item is new tab.
# Each second level item is new split pane session inside the tab.
windowsConfig = [
# Max 4 sessions in one tab.
['echo 41', 'echo 42', 'echo 43', 'echo 44'],
['echo 31', 'echo 32', 'echo 33'],
@nleush
nleush / logging.js
Last active February 22, 2022 19:48
Here’s the sample proxy/echo service for `Iframely` to use with `@adobe/helix-fetch`. Put `CONFIG.PROXY_URL="http://<adress>:8089/proxy?url="` in your `Iframely` config to use this proxy.
const moment = require('moment');
module.exports = function log() {
var args = Array.prototype.slice.apply(arguments);
args = args.filter(i => typeof i !== 'undefined' && i !== null);
args.splice(0, 0, "--", "[" + moment().utc().format("YY-MM-DD HH:mm:ss") + "]");
console.log.apply(console, args);
};
@nleush
nleush / HTML-to-AMP-script.js
Last active February 11, 2022 17:48
Generate required AMP script based on the component HTML
const AMP_SCRIPTS = {
"apester-media": "https://cdn.ampproject.org/v0/amp-apester-media-0.1.js",
"iframely": "https://cdn.ampproject.org/v0/amp-iframely-0.1.js",
"iframe": "https://cdn.ampproject.org/v0/amp-iframe-0.1.js",
"youtube": "https://cdn.ampproject.org/v0/amp-youtube-1.0.js"
};
function getScript(html) {
const m = html && html.match(/^<amp-([a-z\-]+)/);
if (m) {
// Include Iframely embed.js in your page using preferred method. E.g.:
// <script src="//cdn.iframe.ly/embed.js?api_key=[your key here]"></script>
// Add following methods to your component.
componentDidMount: function() {
// Builds widget after embed code rendered.
window.iframely && iframely.load();
},
@nleush
nleush / iframely-webview.js
Last active September 17, 2021 13:17
Rich media embeds for React Native - https://iframely.com/docs/react-native
// use as
// <EmbedWebView
// html = ".. html codes you get from Iframely .."
// />
import React, { Component } from 'react';
import { WebView, View } from 'react-native';
// will receive height data from WebView
function parseMessage(data) {
@nleush
nleush / server-part.js
Created May 10, 2012 15:50
Node.JS + MongoDB: automatic anonymous user creation
// This function implements anonymous creation logic.
function loadOrCreateAnonymousProfile(req, res, next) {
var sess = req.session,
auth = sess && sess.auth;
if (!auth || !auth.userId) {
dbCounter('anonymousUsers', function(err, counter) {
if (err) {
console.log('Error getting anonymous users counter', err);
next();
{"rules":[{
"class": "InteractiveRule",
"selector" : "figure.wp-block-embed",
"properties" : {
"interactive.iframe" : {
"type" : "children",
"selector" : "div.wp-block-embed__wrapper"
}
}
}]
@nleush
nleush / get-amp-scripts.js
Last active February 10, 2020 20:44
Iframely get amp script
var AMP_COMPONENTS_ON_DEMAND = {
"apester-media": "v0/amp-apester-media-0.1.js",
"brightcove": "v0/amp-brightcove-0.1.js",
"dailymotion": "v0/amp-dailymotion-0.1.js",
"facebook-page": "v0/amp-facebook-page-0.1.js",
"facebook": "v0/amp-facebook-0.1.js",
"gfycat": "v0/amp-gfycat-0.1.js",
"gist": "v0/amp-gist-0.1.js",
"iframe": "v0/amp-iframe-0.1.js",
@nleush
nleush / app.js
Last active July 26, 2019 05:47
CKEditor 5 script with MediaEmbed configured to use Iframely
import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed';
var IFRAME_SRC = '//cdn.iframe.ly/api/iframe';
var API_KEY = '...';
// Your API key from https://iframely.com/profile';
var editorInstance;
ClassicEditor
.create( document.querySelector( '#editor' ), {
@nleush
nleush / twitter-error-check.js
Created February 13, 2019 13:24
Twitter error check
var t = window.twttr = window.twttr || {};
t._e = t._e || [];
t.ready = function(f) {
t._e.push(f);
};
twttr.ready(function (twttr) {
twttr.events.bind(
'loaded',
function (event) {