Skip to content

Instantly share code, notes, and snippets.

View pitersky's full-sized avatar
👾
fixed

Atomic Yurec pitersky

👾
fixed
View GitHub Profile
@dotcypress
dotcypress / telegram-login.js
Created February 24, 2018 08:34
Telegram authorization data checker
const { createHash, createHmac } = require('crypto')
function checkSignature (token, { hash, ...data }) {
const secret = createHash('sha256')
.update(token)
.digest()
const checkString = Object.keys(data)
.sort()
.map(k => `${k}=${data[k]}`)
.join('\n')
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@Pitasi
Pitasi / check_telegram_signature.js
Last active March 12, 2024 15:06
Telegram website login widget, signature check sample using Node.js
// Copied by https://gist.github.com/dotcypress/8fd12d6e886cd74bba8f1aa8dbd346aa,
// thanks for improving code style
const { createHash, createHmac } = require('crypto');
const TOKEN = "ABC:12345...";
// I prefer get the secret's hash once but check the gist linked
// on line 1 if you prefer passing the bot token as a param
const secret = createHash('sha256')
.update(TOKEN)
@cowboy
cowboy / mock-axios.js
Last active April 14, 2024 05:40
axios mocking via interceptors
import axios from 'axios'
let mockingEnabled = false
const mocks = {}
export function addMock(url, data) {
mocks[url] = data
}
@staltz
staltz / introrx.md
Last active April 24, 2024 19:47
The introduction to Reactive Programming you've been missing