This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App; | |
class GiftBit { | |
private $endpoint; | |
private $authorization; | |
public function init ( $endpoint, $key ) | |
{ | |
if ( empty($endpoint) || empty($key) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var promise = require('promisejs'); | |
var fs = require('fs'); | |
function readFile(file) { | |
return promise(function (resolve, reject){ | |
fs.readFile(function (err, data) { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react"; | |
const useOutsideClick = (ref, callback) => { | |
const handleClick = e => { | |
if (ref.current && !ref.current.contains(e.target)) { | |
callback(); | |
} | |
}; | |
useEffect(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef } from "react"; | |
import useOutsideClick from "./useOutsideClick"; | |
function MyComponent() { | |
const ref = useRef(); | |
useOutsideClick(ref, () => { | |
alert('You clicked outside') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
/** | |
* Usage: | |
* | |
* const ref = useRef(); | |
* | |
* useResize(ref, (data) => { | |
* console.log(data.width); | |
* }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// yarn add styled-components | |
import styled from 'styled-components'; | |
export default function() => { | |
return ( | |
<Style> | |
<div className="blue"> | |
This is blue text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt update | |
sudo apt install apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" | |
sudo apt update | |
apt-cache policy docker-ce | |
sudo apt install docker-ce | |
To check the status: | |
sudo systemctl status docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Docker | |
https://docs.docker.com/docker-for-windows/install/ | |
Git (Git Bash) | |
https://git-scm.com/downloads | |
Install tmux in bash | |
https://blog.pjsen.eu/?p=440 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This function only get attributes from the first item | |
* if not specified from the 3rd parameter | |
*/ | |
function json_array_to_sql_insert(table_name, arr, _attributes) { | |
if (!Array.isArray(arr) || arr.length === 0){ | |
throw new Error('Enter an array with atleast 1 item'); | |
} | |
const attributes = _attributes || Object.keys(arr[0]); | |
let sql = `INSERT INTO \`${table_name}\` (${attributes.map(a => `\`${a}\``).join(', ')})\nVALUES`; |