Skip to content

Instantly share code, notes, and snippets.

View georgybu's full-sized avatar
:octocat:
Focusing

Georgy Bunin georgybu

:octocat:
Focusing
View GitHub Profile
@georgybu
georgybu / es6.js
Created October 14, 2022 21:04 — forked from green3g/es6.js
codemod for replacing commonjs with es6 import/export
const requireRegex = new RegExp(/(?:var|let|const)?\s*([^\s]+)?(\s*=\s*)?require\s*\(['"](.+)['"]\)[;,]?/, 'g');
const importReplace = "import $1 from '$3';";
const exportsRegex = new RegExp(/module.exports\s*=\s*/, 'g');
const exportReplace = "export default ";
const importMissingVariable = new RegExp(/import\s*from\s*'/, 'g');
const replaceMissingVariable = "import '";
@georgybu
georgybu / source.js
Created April 5, 2020 13:59 — forked from limitedeternity/source.js
Decrypt m3u8 files from play.boomstream.com/player.html
// FileSaver.min.js
(function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Depricated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(b,c,d){var e=new XMLHttpRequest;e.open("GET",b),e.responseType="blob",e.onload=function(){a(e.response,c,d)},e.onerror=function(){console.error("could not download file")},e.send()}function d(a){var b=new XMLHttpRequest;return b.open("HEAD",a,!1),b.send(),200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof
@georgybu
georgybu / unlimited_trials_babeledit.txt
Created December 28, 2019 13:20 — forked from Fusseldieb/unlimited_trials_babeledit.txt
Activate BabelEdit temporarily / Unlimited trial
Obviously for educative purposes only.
Furthermore, this DOESN'T activate BabelEdit permanently.
If you like the software, buy it, the devs deserve it.
Since I have no money to buy it, I discovered a workaround for unlimited trials.
It's quite a annoying workaround, but ... it works!
Firstly go to "c:\windows\system32\drivers\etc\" and open the "hosts" file in Notepad/Notepad++/VSCode/Sublime/Atom/whatever as admin (if you don't open it as admin, it won't let you save it).
Add this line at the end of the file:
@georgybu
georgybu / unlimited_trials_babeledit.txt
Created December 28, 2019 13:20 — forked from Fusseldieb/unlimited_trials_babeledit.txt
Activate BabelEdit temporarily / Unlimited trial
Obviously for educative purposes only.
Furthermore, this DOESN'T activate BabelEdit permanently.
If you like the software, buy it, the devs deserve it.
Since I have no money to buy it, I discovered a workaround for unlimited trials.
It's quite a annoying workaround, but ... it works!
Firstly go to "c:\windows\system32\drivers\etc\" and open the "hosts" file in Notepad/Notepad++/VSCode/Sublime/Atom/whatever as admin (if you don't open it as admin, it won't let you save it).
Add this line at the end of the file:
@georgybu
georgybu / solution.js
Last active August 21, 2017 17:03
jsninja-BC1-2017-1
function drawNestedSetsTree(data, node) {
if (Array.isArray(data) && node && data.length > 0) {
data.sort((a, b) => a.left - b.left);
let minLeft = 0;
const buildElement = (data, node, parent = null) => {
if (Array.isArray(data)) {
data.forEach((item, index) => {
if ((!parent && index === 0) || (parent && item.left > minLeft && item.left > parent.left && item.right < parent.right)) {
const li = document.createElement('li');
@georgybu
georgybu / c.md
Last active August 29, 2015 14:19 — forked from SerafimArts/tips.md
  • На iOS устройствах числовые значения подчёркиваются синим. Эта проблема возникает из-за того, что iOS устройства по умолчанию считают все числа похожие на телефонные номера - телефонными номерами. Решается добавлением <meta name="format-detection" content="telephone=no" /> Тоже самое касается адреса: <meta name="format-detection" content="address=no" />

  • Пользователь может уменьшать и увеличивать приложение. Решается добавляением тега <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />

  • Ссылки нажимаются с задержкой (примерно 300ms). Решается подпиской на событие touchstart и принудительной инициализацией события click после него. Если проблема всё равно возникает - ничего не поделать, надо облегчать dom.

  • В android появляется синяя обводка вокруг ссылок с характерным звуком. Решение:

console.log("got here");
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("http://facebook.com", function(status) {
if ( status === "success" ) {
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>
/*
Cross-browser hasOwnProperty solution, based on answers from:
http://stackoverflow.com/questions/135448/how-do-i-check-to-see-if-an-object-has-an-attribute-in-javascript
*/
if ( !Object.prototype.hasOwnProperty ) {
Object.prototype.hasOwnProperty = function(prop) {
var proto = obj.__proto__ || obj.constructor.prototype;
return (prop in this) && (!(prop in proto) || proto[prop] !== this[prop]);
};
}