I hereby claim:
- I am m5r on github.
- I am mokhtar (https://keybase.io/mokhtar) on keybase.
- I have a public key whose fingerprint is BED9 087A 5805 6E8B 0B7D 4F94 FE60 7C32 6598 010A
To claim this, I am signing this object:
function loadData(url){ | |
return new Promise((resolve, reject) => { | |
let xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function(){ | |
if(xmlhttp.readyState === XMLHttpRequest.DONE){ | |
if(xmlhttp.status === 200){ | |
resolve(xmlhttp.responseText); | |
}else{ | |
reject(xmlhttp.status); | |
} |
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env bash | |
set -e # Exit on errors | |
# A configurable, strict IPTables firewall | |
# Save this to /usr/local/bin and modify to your needs | |
# Config - edit this! | |
ETH_INTERFACE="eth0" | |
ALLOW_PORTS="22 80 443" |
react + redux + RR
It uses https://gist.github.com/iNikNik/3c1b870f63dc0de67c38 for stores and actions.
1) create redux
const redux = createRedux(state);
2) get requireAccess func => bindCheckAuth to redux
/** | |
* Converts an RGB color value to HSL. Conversion formula | |
* adapted from http://en.wikipedia.org/wiki/HSL_color_space. | |
* Assumes r, g, and b are contained in the set [0, 255] and | |
* returns h, s, and l in the set [0, 1]. | |
* | |
* @param Number r The red color value | |
* @param Number g The green color value | |
* @param Number b The blue color value | |
* @return Array The HSL representation |
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "Error: No argument passed" >&2; exit 1 | |
fi | |
if ! [[ $1 =~ ^[0-9]+$ ]] ; then | |
echo "Error: Argument is not a number" >&2; exit 1 | |
fi | |
PIDToKill=$(lsof -i:$1 | grep LISTEN | awk '{print $2}' | uniq) |
export function serializeServerDataToJsonString(data: Object): string { | |
const jsonString = JSON.stringify(data); | |
return jsonString | |
.replace(/<\/script/gim, '</_escaped_script') | |
.replace(new RegExp('\u2028', 'g'), '\\u2028') | |
.replace(new RegExp('\u2029', 'g'), '\\u2029') | |
.replace(/\\/g, '\\\\') | |
.replace(/\n/g, '\\n') | |
.replace(/\r/g, '\\r') |
declare global { | |
interface Window { Paddle: any; } | |
} | |
const VENDOR_ID = 111; | |
const PRODUCT_ID = 222; | |
type BuyParams = { | |
coupon?: string | null; | |
meta?: Record<string, string>; |
import jwt from "jsonwebtoken"; | |
import { User } from "./entities/user"; | |
export function generateSignInUrl(user: User) { | |
const token = generateSignInToken(user); | |
return `${process.env.APP_URL}/auth/verify?token=${token}`; | |
} |
import type { FunctionComponent } from "react"; | |
export const combineProviders = (providers: FunctionComponent[]) => providers.reduce( | |
(Combined, Provider) => ({ children }) => ( | |
<Combined> | |
<Provider>{children}</Provider> | |
</Combined> | |
), | |
); |