Skip to content

Instantly share code, notes, and snippets.

View jsdaniell's full-sized avatar
💭
Good Insights!

José Daniel jsdaniell

💭
Good Insights!
View GitHub Profile
func Connect(w http.ResponseWriter, r *http.Request) {
// create new WhatsApp connection
cmd := exec.Command("./whats-cli", "connect")
stdout, _ := cmd.StdoutPipe()
err := cmd.Start()
if err != nil {
responses.ERROR(w, http.StatusInternalServerError, err)
}
package main
import (
"fmt"
"github.com/jsdaniell/whats_api/api"
"github.com/jsdaniell/whats_api/api/utils/file_utility"
"github.com/jsdaniell/whats_api/api/utils/shell_commands"
)
func main() {
func Connect(w http.ResponseWriter, r *http.Request) {
wac, err := whatsapp.NewConn(20 * time.Second)
if err != nil {
fmt.Fprintf(os.Stderr, "error creating connection: %v\n", err)
}
err = whats_utils.Login(wac)
if err != nil {
fmt.Fprintf(os.Stderr, "error logging in: %v\n", err)
}
@jsdaniell
jsdaniell / findFirstWay.js
Last active July 15, 2020 15:00
Using find(); to filter with javascript (First way)
const dataToFilter = ['Blue', 'White', 'Red', 'Yellow'];
let filteredBlueItem = dataToFilter.find(item => item === 'Blue');
console.log(filteredBlueItem)
// Blue
let filteredBlackItem = dataToFilter.find(item => item === 'Black');
@jsdaniell
jsdaniell / mui-datatable-no-toolbar.js
Created July 25, 2019 14:05
Mui-Datatable without toolbar.
import React, { Fragment } from "react";
import ReactDOM from "react-dom";
import MUIDataTable from "mui-datatables";
class Example extends React.Component {
render() {
const columns = ["Name", "Title", "Location"];
const data = [
["Gabby George", "Business Analyst", "Minneapolis"],
@jsdaniell
jsdaniell / mui-datatable-server-side.js
Created July 25, 2019 14:03
Mui-Datatable server-side options.
import React, { Fragment } from "react";
import ReactDOM from "react-dom";
import MUIDataTable from "mui-datatables";
class Example extends React.Component {
render() {
const columns = ["Name", "Title", "Location", "Age", "Salary"];
const data = [
["Gabby George", "Business Analyst", "Minneapolis", 30, 100000],
@jsdaniell
jsdaniell / mui-datatable-search.js
Created July 25, 2019 13:54
Mui-Datatable with search filter.
import React, { Fragment } from "react";
import ReactDOM from "react-dom";
import MUIDataTable from "mui-datatables";
class Example extends React.Component {
state = {
searchText: "Computer"
};
render() {
@jsdaniell
jsdaniell / CustomFooter.js
Created July 25, 2019 13:48
Mui-Datatable with custom footer.
import React from "react";
import TableFooter from "@material-ui/core/TableFooter";
import TableRow from "@material-ui/core/TableRow";
import TableCell from "@material-ui/core/TableCell";
import { withStyles } from "@material-ui/core/styles";
const defaultFooterStyles = {
};
class CustomFooter extends React.Component {
@jsdaniell
jsdaniell / mui-datatable-custom-action-by-columns.js
Created July 25, 2019 13:44
Mui-Datatable with selection on columns, and delete option.
import React from "react";
import ReactDOM from "react-dom";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import TextField from "@material-ui/core/TextField";
import Switch from "@material-ui/core/Switch";
import MUIDataTable from "mui-datatables";
import Cities from "./cities";
class Example extends React.Component {
render() {
@jsdaniell
jsdaniell / mui-datatable-crud-rows.js
Created July 25, 2019 13:41
Mui-Datatable with delete, add and edit options for rows.
import React from "react";
import ReactDOM from "react-dom";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import TextField from "@material-ui/core/TextField";
import Switch from "@material-ui/core/Switch";
import MUIDataTable from "mui-datatables";
import Cities from "./cities";
class Example extends React.Component {
constructor(props) {