Skip to content

Instantly share code, notes, and snippets.

View anacampesan's full-sized avatar
🏡
WFH

Ana Campesan anacampesan

🏡
WFH
View GitHub Profile
name: root
states:
greetings:
component: meya.input_string
properties:
text: Hi, what can I help you with?
output: intent
wit_request:
component: wit_request
transitions:
# -*- coding: utf-8 -*-
import requests
from meya import Component
class WitRequest(Component):
def start(self):
API_KEY = 'XXX'
url = 'https://api.wit.ai/message'
headers = {'Authorization': 'Bearer ' + API_KEY}
function getQueryParam(param) {
// returns the query parameters portion from the url and gets rid of the ? at position [0]
var query = window.location.search.substring(1);
var startPos = query.indexOf(param);
if (startPos == -1) {
return false;
}
query = query.substring(startPos);
// checks if the desired param is the last one in the query
@anacampesan
anacampesan / Print.js
Created September 12, 2017 16:41
Bind functions to events in React
import React from 'react';
export default class Print extends React.Component {
constructor() {
super()
this.printStuff = this.printStuff.bind(this);
}
printStuff() {
<script>
document.addEventListener('DOMContentLoaded', function() {
var notificationBtn = document.getElementById('notificationBtn');
var notificationBox = document.getElementById('notificationBox');
document.body.addEventListener('click', function(ev) {
notificationBox.style.display = 'none';
});
notificationBtn.addEventListener('click', function(ev) {
@anacampesan
anacampesan / hostname.js
Last active August 11, 2017 13:58
Builtin hostname feature in JS
$(document).ready(function() {
$linkField = $('[name="form-link"]');
$sourceField = $('[name="form-source"]');
$linkField.keypress(function() {
$tempA = document.createElement('a');
$tempA.href = $linkField.val();
$sourceField.val($tempA.hostname);
$tempA.remove();
});
});
@anacampesan
anacampesan / add_constraint_mytable.php
Last active October 5, 2017 13:34
Add unique - Migration
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddConstraintMyTable extends Migration
{
/**
* Run the migrations.
*
@anacampesan
anacampesan / copyToClipboard.html
Last active May 20, 2021 10:41
Copy to clipboard without input
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="secretInfo" style="display: none;">secret info</div>
<button type="button" id="btnCopy">Copy hidden info</button>