Skip to content

Instantly share code, notes, and snippets.

View WarHatch's full-sized avatar

Karolis Staskevičius WarHatch

  • Vilnius, Lithuania
View GitHub Profile
@WarHatch
WarHatch / sentenceConstructorGameTypeJSON
Created May 27, 2020 21:20
sentenceConstructorGameTypeJSONExample
{
"_createdAt":"2020-04-20T14:35:48Z",
"_id":"1a56c1cc-e4f9-48aa-8390-705960b901c3",
"_rev":"wURAydDDZMl5Zun2fzvrdA",
"_type":"sentenceConstructor",
"_updatedAt":"2020-04-20T14:36:43Z",
"answers":[
{
"_key":"48ce5634a43b",
"_type":"wordPicture",
@WarHatch
WarHatch / sentenceConstructorGameTypeJSONSchema
Last active May 27, 2020 21:09
JSON schema edukaciniam "sentenceConstructor" tipo žaidimui
{
"type": "object",
"properties": {
"_createdAt": {
"type": "string"
},
"_id": {
"type": "string"
},
@WarHatch
WarHatch / axios-catch-error.js
Created February 25, 2020 21:34 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@WarHatch
WarHatch / text-patch-html.ts
Last active December 11, 2019 13:16
[TypeScript] text-patched html element function on an existing element
type IHtmlFunctionCallBuilder<T extends (...args: any) => void> = (func: T, funcArgs: Parameters<T>) => string
const htmlFunctionCallBuilder: IHtmlFunctionCallBuilder<(...args: any) => void> = (func, funcArgs) => {
let parsedArgs = JSON.stringify(funcArgs);
return `${func.name}(${parsedArgs});`
}
const renderToHTMLWithFunctions = (props: IButtonData) => {
// Create HTML element
const html = ReactDOMServer.renderToString(Button(props));