Skip to content

Instantly share code, notes, and snippets.

View barinbritva's full-sized avatar
🏴‍☠️
Karibu!

barinbritva

🏴‍☠️
Karibu!
View GitHub Profile
@josdejong
josdejong / npm.js
Last active March 14, 2024 22:28
Helper function to load ESM packages from NPM in your browser dev tools console
/**
* Load an ESM package from npm in your JavaScript environment.
*
* Loads packages from https://www.npmjs.com/ via the CDN https://www.jsdelivr.com/
*
* Usage:
*
* const lodash = await npm('lodash-es')
* const lodash = await npm('lodash-es@4')
* const lodash = await npm('[email protected]')
@konstantin24121
konstantin24121 / verifyTelegramWebAppData.tsx
Last active February 24, 2025 04:05
Telegram Bot 6.0 Validating data received via the Web App node implementation
const TELEGRAM_BOT_TOKEN = '110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw'; // https://core.telegram.org/bots#creating-a-new-bot
export const verifyTelegramWebAppData = async (telegramInitData: string): boolean => {
// The data is a query string, which is composed of a series of field-value pairs.
const encoded = decodeURIComponent(telegramInitData);
// HMAC-SHA-256 signature of the bot's token with the constant string WebAppData used as a key.
const secret = crypto
@noamtamim
noamtamim / README.md
Last active February 25, 2025 10:11
Markdown with PlantUML

How to use PlantUML with Markdown

PlantUML is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

Here's how I combine the two, to create docs with embedded diagrams.

Step 0: Setup

Get the command-line PlantUML from the download page or your relevant package manager.

@SteveL-MSFT
SteveL-MSFT / profile.ps1
Last active December 9, 2024 02:29
PowerShell Prompt
#Requires -Version 7
# Version 1.2.13
# check if newer version
$gistUrl = "https://api.github.com/gists/a208d2bd924691bae7ec7904cab0bd8e"
$latestVersionFile = [System.IO.Path]::Combine("$HOME",'.latest_profile_version')
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
if ([System.IO.File]::Exists($latestVersionFile)) {
@zkat
zkat / index.js
Last active September 26, 2024 10:33
npx is cool
#!/usr/bin/env node
console.log('yay gist')
@ethaizone
ethaizone / server_time_sync.js
Last active December 21, 2024 11:43
Sync server time to client browser with JS. Implement follow Network Time Protocol.
// Original from http://stackoverflow.com/questions/1638337/the-best-way-to-synchronize-client-side-javascript-clock-with-server-date
// Improved by community and @jskowron
// Synchronize client-side clock with server time using an approximation of NTP
let serverTimeOffset = null;
function getServerTime(callback) {
if (serverTimeOffset === null) {
const scripts = document.getElementsByTagName("script");
const currentScriptURL = scripts[scripts.length - 1].src;
@JArmando
JArmando / ReactAnimations.md
Last active August 31, 2017 15:36
React Animations using animate.css

ReactAnimations with animate.css:

Say you want to animate a list of items. Wrap these children components in a <ReactCssTransitionGroup> and set the animation settings (duh) similar to this:

//… the rest of the component declaration
// … this goes in the render function
render: function(){
	var ReactCssTransitionGroup = React.addons.cssTransitionGroup;
/*
Do not modify this version of the file. It will be copied over when any of the project's targets are built.
If you wish to modify mraid.js, modify the version located at mopub-sdk-common/mraid/mraid.js.
*/
(function() {
var isIOS = (/iphone|ipad|ipod/i).test(window.navigator.userAgent.toLowerCase());
if (isIOS) {
console = {};
console.log = function(log) {
var iframe = document.createElement('iframe');
@jaxbot
jaxbot / gist:5748513
Created June 10, 2013 12:58
Block nginx from serving .git directories
location ~ /\.git {
deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
location ~ /\. {
deny all;
}
@mbijon
mbijon / xss_clean.php
Last active November 1, 2022 03:23
XSS filtering in PHP (cleans various UTF encodings & nested exploits)
<?php
/*
* XSS filter, recursively handles HTML tags & UTF encoding
* Optionally handles base64 encoding
*
* ***DEPRECATION RECOMMENDED*** Not updated or maintained since 2011
* A MAINTAINED & BETTER ALTERNATIVE => kses
* https://github.com/RichardVasquez/kses/
*
* This was built from numerous sources