Skip to content

Instantly share code, notes, and snippets.

View thaerlabs's full-sized avatar

Thaer Abbas thaerlabs

View GitHub Profile
@thaerlabs
thaerlabs / machine.js
Created June 28, 2021 16:10
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@thaerlabs
thaerlabs / AppSync_snippets.md
Last active March 9, 2020 07:08
Snippets and utils to be used with AWS AppSync VTL Templates

Remove empty values from object to prevent DynamoDB empty string exception

#set ($values = {})

#foreach ($entry in $ctx.args.input.entrySet())
  #if( !$util.isNullOrBlank($entry.value) )
  	$util.qr($values.put($entry.key, $entry.value))
  #end
#end
@thaerlabs
thaerlabs / permissions.sh
Created July 13, 2018 13:50
Permissions for Mautic
cd /var/www/mautic
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod -R g+w app/cache/
chmod -R g+w app/logs/
chmod -R g+w app/config/
chmod -R g+w media/files/
chmod -R g+w media/images/
chmod -R g+w translations/
chown -R $USER:www-data .
@thaerlabs
thaerlabs / AbstractModel.js
Created December 8, 2017 01:36 — forked from dsumer/AbstractModel.js
linkState for mobx-state-tree
import {types, getType} from 'mobx-state-tree';
function getValueFromPath(value, valuePath) {
if (valuePath) {
const path = valuePath.split('.');
let endValue = value;
for (const pathItem of path) {
endValue = endValue[pathItem];
}
return endValue;
@thaerlabs
thaerlabs / express-sample.js
Last active November 7, 2017 19:42
express sample
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const PORT = 3000;
app.use(bodyParser.json());
app.get('/', (req, res) => {
const name = req.query;
res.send('Login form');
const input = [[1,2,[3]],4];
function arrFlatten() {
let flat = [];
for (let i = 0; i < arguments.length; i++) {
if (arguments[i] instanceof Array) {
flat.push.apply(flat, arrFlatten.apply(this, arguments[i]));
} else {
flat.push(arguments[i]);
}
[{"created_at":"Thu Jun 02 13:57:33 +0000 2016","username":"Laura C","profile_image_url":"http://pbs.twimg.com/profile_images/660720426687967232/fWfBSQBO_normal.jpg","text":"Il David di Michelangelo 💕 #Florence #Italy @ Galleria Dell' Academia, Firenze, Italia https://t.co/HD8Z0poZAY","images":[],"geo":{"lat":43.77629,"lng":11.25864836},"content":"<div>\n <p class=\"profile_image\"><img src=\"http://pbs.twimg.com/profile_images/660720426687967232/fWfBSQBO_normal.jpg\" alt=\"Laura C\"></p>\n <p class=\"username\">@Laura C</p>\n <p class=\"content\">Il David di Michelangelo 💕 #Florence #Italy @ Galleria Dell&#39; Academia, Firenze, Italia https://t.co/HD8Z0poZAY</p>\n \n <p><small><strong>Posted at:</strong> Thu Jun 02 13:57:33 +0000 2016</small></p>\n <p><small><strong>lat:</strong> 43.77629 </small> <small><strong>lng:</strong> 11.25864836</small></p>\n</div>\n"},{"created_at":"Thu Jun 02 13:57:19 +0000 2016","username":"Panna & Pomodoro","profile_image_url":"http://pbs.twimg.com/profile_ima
@thaerlabs
thaerlabs / .babelrc
Last active November 16, 2016 17:36
React hello world is not hard
{
"presets": ["es2015", "react"]
}
@thaerlabs
thaerlabs / v2p.html
Last active August 29, 2015 14:21 — forked from elclanrs/v2p.html
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="v2p.js"></script>
<style type="text/css" media="all">
body { margin: 0; }
div {
background: #fa7098;
}