Skip to content

Instantly share code, notes, and snippets.

@alexanderisora
alexanderisora / weird.js
Created July 27, 2018 10:14
Weird JS expressions
[] == ![] // -> true
Math.min() > Math.max() // -> true
a: b: c: d: e: f: g: 1, 2, 3, 4, 5; // -> 5
(1).__proto__.__proto__.__proto__ // -> null
(0.1 + 0.2) === 0.3 // -> false
//More funny code samples: https://github.com/denysdovhan/wtfjs
initPaddle(){
//Init the Paddle after it's loaded from their server.
//There is no callback or an event so we use intervals to wait until it's loaded.
//We also must load their script from their servers to get the freshest code.
let interval = setInterval(() => {
if (typeof window.Paddle !== 'undefined') {
//Credentials: https://vendors.paddle.com/account
window.Paddle.Setup({
vendor: 11111,
import firebase from "firebase/app";
import 'firebase/auth';
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
initAuth(){
var config = {
apiKey: "<key>",
authDomain: "unicorn-platform-app.firebaseapp.com",
databaseURL: "https://unicorn-platform-app.firebaseio.com",
projectId: "unicorn-platform-app",
checkIfPro(){
// Send email and PRO_PRODUCT_ID to check.php.
// check.php must get the list of all users from Paddle, then see if current user is among Pro users.
const userEmail = "[email protected]";
const PRODUCT_ID = 11111; //See this ID in the Paddle dashboard.
const URL = 'https://unicornplatform.com/api/check.php';
const data = {
email: userEmail,
productID: PRODUCT_ID
};
<?php
//Checks if user a Pro. If Pro send also his last/next payment info.
$checking_user_email = json_decode(file_get_contents('php://input'))->email;
$product_id = json_decode(file_get_contents('php://input'))->productID;
curl_init('https://vendors.paddle.com/api/2.0/subscription/users');
//https://paddle.com/docs/api-list-users/
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
[
{"english": "english", "native": "English", "flag": "🇺🇸🇬🇧", "code": "en"},
{"english": "chinese", "native": "Zhongwen", "flag": "🇨🇳", "code": "zh"},
{"english": "spanish", "native": "Espanol", "flag": "🇪🇸", "code": "es"},
{"english": "french", "native": "Francais", "flag": "🇫🇷", "code": "fr"},
{"english": "japanese", "native": "Nihongo", "flag": "🇯🇵", "code": "ja"},
{"english": "korean", "native": "Hangugeo", "flag": "🇰🇷", "code": "ko"},
{"english": "german", "native": "Deutsch", "flag": "🇩🇪", "code": "de"},
{"english": "dutch", "native": "Nederlands", "flag": "🇳🇱", "code": "nl"},
{"english": "portuguese", "native": "Portugues", "flag": "🇵🇹🇧🇷", "code": "pt"},
@alexanderisora
alexanderisora / finishJson5.ts
Created May 11, 2023 15:28
function to complete an unfinished JSON.
export const finishJson5 = (unfinishedJson5: string) => {
let stack = [];
let inDoubleQuotes = false;
let inSingleQuotes = false;
let inSingleLineComment = false;
for (let i = 0; i < unfinishedJson5.length; i++) {
const currentChar = unfinishedJson5[i];
const nextChar = unfinishedJson5[i + 1];
let prevChar;
/* Hide all notifications by default */
[data-testid="notification"] {
display: none !important;
}
/* Show only notifications containing "liked your reply" or "replied" */
[data-testid="notification"]:has(span:contains("liked your reply")),
[data-testid="notification"]:has(span:contains("replied")) {
display: block !important;
}