Skip to content

Instantly share code, notes, and snippets.

View bezenson's full-sized avatar
💻

Vladislav Bezenson bezenson

💻
  • Warsaw
View GitHub Profile
@konstantin24121
konstantin24121 / verifyTelegramWebAppData.tsx
Last active July 22, 2024 12:15
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
@banhaclong20
banhaclong20 / Touch swipe detection in pure JavaScript
Created November 2, 2017 22:41
Touch swipe detection in pure JavaScript
<div id="swipezone">
Swipe me
</div>
// credit: http://www.javascriptkit.com/javatutors/touchevents2.shtml
function swipedetect(el, callback){
var touchsurface = el,
swipedir,
startX,
@VlooMan
VlooMan / Highlight CPT Archive and wp_nav_menu parents
Last active May 23, 2023 17:15
Highlight the CPT (Custom Post Type) Archive & its Parents ("current-menu-parent") & its Ancestors ("current-menu-ancestor") in the WordPress Navigation wp_nav_menu() when viewing the Archive itself or a single detail page of the CPT. Let's say you have CPT called "projects" and you have a WordPress menu set as "My Work (link to a page) > Projec…
/**
* Gist Name: Highlight CPT Archive and wp_nav_menu parents
* Author: VlooMan
* Author URI: http://ishyoboy.com
*
* Highlight the CPT (Custom Post Type) Archive & its Parents ("current-menu-parent")
* & its Ancestors ("current-menu-ancestor") in the WordPress Navigation wp_nav_menu() when viewing the Archive itself
* or a single detail page of the CPT.
*
* Let's say you have CPT called "projects" and you have a WordPress menu set as
@bezenson
bezenson / README.MD
Last active September 8, 2017 15:45
Move PropTypes from 'react' to 'prop-types' library fast.

If you upgraded react to latest version and got a warning Accessing PropTypes via the main React package is deprecated, and will be removed in React v16.0., but you import PropTypes from react package all over your project then check 3 simple regular expressions to find and replace in your project.

Find:

  1. (import.+)(, \{ PropTypes \})(.+'react';)$
  2. (import.+)(PropTypes, )(.+'react';)$
  3. (import.+)(, PropTypes)(.+'react';)$

Replace:

@bezenson
bezenson / _transition.scss
Created March 11, 2017 15:37
Shorten transition declaration via SASS (SCSS) function
// Default variables
$transition-duration: .2s;
$transition-timing-function: ease;
@function transition($arguments...) {
$result: null;
@each $prop in $arguments {
$result: $result, $prop $transition-duration $transition-timing-function;
}
@return $result;
IMPORTANT
Please duplicate this radar for a Safari fix!
This will clean up a 50-line workaround.
rdar://22376037 (https://openradar.appspot.com/radar?id=4965070979203072)
//////////////////////////////////////////////////////////////////////////////
(Now available as a standalone repo.)