Skip to content

Instantly share code, notes, and snippets.

View nkbt's full-sized avatar
💚

Nikita Butenko nkbt

💚
View GitHub Profile
@nkbt
nkbt / .eslintrc.js
Last active April 23, 2024 03:19
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@nkbt
nkbt / loader.js
Last active December 7, 2023 12:19
Old fashioned loader
var loading = "\\|/—",
tick = 0,
loadingElement = document.createElement('div');
loadingElement.id = 'loading';
loadingElement.style.fontFamily = 'Consolas, "Liberation Mono", Courier, monospace';
document.body.innerHTML = '';
document.body.appendChild(loadingElement);
(function animate() {
tick = (tick + 1) % loading.length;
@nkbt
nkbt / .jshintrc
Last active January 10, 2023 04:04
.jshintrc - Browser
{
// -----------------
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
@nkbt
nkbt / passport-routes.js
Created February 28, 2014 13:39
Passport.js Routes
"use strict";
var passport = require('./passport');
var config = {
redirectBack: redirectBack
}
function redirectBack(req, res) {
res.redirect(req.param('__back') && decodeURIComponent(req.param('__back')) || '/');
}
@nkbt
nkbt / passport.js
Created February 28, 2014 13:38
Passport.js usage example
ar TwitterStrategy = require('passport-twitter').Strategy;
var FacebookStrategy = require('passport-facebook').Strategy;
var LinkedinStrategy = require('passport-linkedin').Strategy;
var passport = require('passport');
var _ = require('underscore');
var configurable = require('configurable-module');
function configure(options) {
@nkbt
nkbt / node-require-url.js
Last active January 3, 2023 22:48
Async require library from URL for Node
const https = require('https');
const vm = require('vm');
const requireCache = {};
const requireUrl = url => new Promise((resolve, reject) => url in requireCache ?
resolve(requireCache[url]) :
https.get(url, res => {
const result = [];
res.on('data', chunk => result.push(chunk.toString('utf-8')));
[push]
default = current
[user]
email = nik@butenko.me
name = Nik Butenko
[core]
autocrlf = input
excludesfile = /Users/nkbt/.gitignore
ignorecase = true
[alias]
@nkbt
nkbt / .jshintrc
Last active May 20, 2021 07:02
.jshintrc - NodeJS
{
// -----------------
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
@nkbt
nkbt / empty_bucket.sh
Created February 3, 2020 00:03 — forked from wknapik/empty_bucket.sh
Empty an s3 bucket of all object versions and delete markers in batches of 1000
#!/usr/bin/env bash
set -eEo pipefail
shopt -s inherit_errexit >/dev/null 2>&1 || true
if [[ ! "$#" -eq 2 || "$1" != --bucket ]]; then
echo -e "USAGE: $(basename "$0") --bucket <bucket>"
exit 2
fi
@nkbt
nkbt / instagram.js
Created December 4, 2019 02:53
Instagram No-API Public posts access
content = await(await fetch('https://www.instagram.com/nkbtnk/')).text()
doc = new DOMParser().parseFromString(content, 'text/html')
dataEl = Array.from(doc.querySelectorAll('script:not([src])')).find(s => s.innerText.includes('window._sharedData = '))
match = dataEl.innerText.match(/\{.+}/)
data = JSON.parse(match[0])
last12posts = data.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges