Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Wern Ancheta anchetaWern

🏠
Working from home
View GitHub Profile
View php-webscraping.md

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

{% blockquote %} Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox. {% endblockquote %}

View devnews
-- phpMyAdmin SQL Dump
-- version 4.0.10deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 28, 2015 at 01:44 AM
-- Server version: 5.5.41-0ubuntu0.14.04.1
-- PHP Version: 5.5.9-1ubuntu4.6
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
View responsive-voice.js
//Look for other responsivevoice instances
/*if (window.parent != null) {
var iframes = window.parent.document.getElementsByTagName('iframe');
for (var i = 0; i < iframes.length; i++) {
//iframes[i].style.width = "300px"
}
}*/
if (typeof responsiveVoice != 'undefined') {
console.log('ResponsiveVoice already loaded');
@anchetaWern
anchetaWern / laravel-ums.markdown
Created Dec 6, 2012
Building a User Management System in Laravel
View laravel-ums.markdown

There's no shortage of good resources for learning laravel. So instead of the usual introductory tutorial were just gonna learn Laravel by building a project from scratch and that's gonna be a User Management System.

I don't know if my definition of a User Management System is correct but here's my idea of what's it's capable of doing:

  • Register Roles
  • Register Users
  • Update Users
View Getting Started With Wordpress Plugin Development.markdown

In this article I'm going to walk you through process of creating Wordpress plugins. First I'm going to talk about some of the basic concepts in Wordpress plugin development like the actions, hooks, and API's that makes up Wordpress. Then were going to build a plugin where we apply some of the concepts and best practices in developing Wordpress plugins.

###Prerequisites

In order to fully benefit from this tutorial you should have a basic knowledge on PHP. As Wordpress is running on PHP and most of the code that we will be writing will be on PHP. A little bit of knowledge on HTML, CSS and JavaScript is also helpful but not required for this tutorial.

@anchetaWern
anchetaWern / aspect.js
Created Jul 24, 2019
get image aspect ratio
View aspect.js
function getRandomInt(min, max) {
let sign = Math.random() < 0.5 ? -1 : 1;
min = Math.ceil(min);
max = Math.floor(max);
return (Math.floor(Math.random() * (max - min + 1)) + min) * sign;
}
function getNewHeight(oldWidth, oldHeight, newWidth) {
const aspectRatio = (oldWidth / oldHeight);
const newHeight = (newWidth / aspectRatio);
@anchetaWern
anchetaWern / basic_data_intent_sample.json
Created Jul 13, 2019
Pokedex Bot: sample Dialogflow response
View basic_data_intent_sample.json
{
"responseId":"xxxxx-xxx-xx-xxx-xxxxx-xxxxxxx",
"queryResult":{
"queryText":"Image of pikachu",
"parameters":{
"specs":"photo",
"pokemon":"Pikachu"
},
"allRequiredParamsPresent":true,
"fulfillmentText":"pikachu",
@anchetaWern
anchetaWern / get_type_effectiveness_intent_sample_request.json
Created Jul 13, 2019
Pokedex Bot: sample fulfillment server request body from Dialogflow
View get_type_effectiveness_intent_sample_request.json
{
"responseId":"xxxx-xxx-xxx-xx-xxxxxx-xxxxx",
"queryResult":{
"queryText":"What is super effective against ice type?",
"parameters":{
"pokemon_types":"ice",
"type_effectiveness":"double_damage_from"
},
"allRequiredParamsPresent":true,
"fulfillmentMessages":[
@anchetaWern
anchetaWern / extract Dialogflow parameters in server.js
Last active Jul 13, 2019
Pokedex Bot: extract Dialogflow parameters in server.js
View extract Dialogflow parameters in server.js
const { intent, parameters, outputContexts, queryText } = req.body.queryResult;
const pokemon = (parameters.pokemon) ? parameters.pokemon.toLowerCase().replace('.', '-').replace(' ', '').replace("'", "") : '';
const specs = parameters.specs;
const get_type_effectiveness = (parameters.type_effectiveness) ? true : false;
let response_obj = {};
@anchetaWern
anchetaWern / add Dialogflow webhook handler in server.js
Last active Jul 13, 2019
Pokedex Bot: Add Dialogflow webhook handler in server.js
View add Dialogflow webhook handler in server.js
const pokemon_endpoint = ['abilities', 'moves', 'photo'];
const pokemon_species_endpoint = ['description', 'evolution'];
app.post("/pokedex", async (req, res) => {
try {
const { intent, parameters, outputContexts, queryText } = req.body.queryResult;
const pokemon = (parameters.pokemon) ? parameters.pokemon.toLowerCase().replace('.', '-').replace(' ', '').replace("'", "") : '';
const specs = parameters.specs;