Skip to content

Instantly share code, notes, and snippets.

View gitllermopalafox's full-sized avatar
🏠
127.0.0.1

Guillermo Palafox gitllermopalafox

🏠
127.0.0.1
View GitHub Profile
@M165437
M165437 / db-connect-test.php
Last active November 7, 2024 10:11 — forked from chales/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@mcaskill
mcaskill / Function.HTML-Build-Attributes.php
Last active January 8, 2024 04:14
PHP / WordPress : Generate a string of HTML attributes
<?php
if (!function_exists('html_build_attributes')) {
/**
* Generate a string of HTML attributes
*
* @param array $attr Associative array of attribute names and values.
* @param callable|null $callback Callback function to escape values for HTML attributes.
* Defaults to `htmlspecialchars()`.
* @return string Returns a string of HTML attributes.
@khoatran
khoatran / MenuBuilder.php
Last active May 11, 2016 05:13
[Laravel] MenuBuilder to build menu view-object from Laravel config
<?php
class MenuBuilder
{
public static function buildMenuViewObjectFromConfig($configKey) {
$result = [];
$menu = config($configKey);
foreach ($menu as $mainMenuItem) {
$menuViewObject = self::buildMenuViewObject($mainMenuItem);
if(!empty($menuViewObject)) {
@gitllermopalafox
gitllermopalafox / config
Last active April 23, 2016 04:36
Add more than one private key to the same ssh server / Agregar más de una llave privada a un servidor ssh
Host *.kd.io
User username
IdentityFile ~/.ssh/koding
ProxyCommand ssh -i ~/.ssh/koding %[email protected] nc %h %p
Host gitlab.com-repo1
Hostname gitlab.com
User git # Opcional
IdentityFile ~/.ssh/key_repo1
@generatepress
generatepress / template-tags.php
Created January 27, 2016 07:36
Add nofollow attribute to GeneratePress pagination
if ( ! function_exists( 'generate_paging_nav' ) ) :
function generate_paging_nav() {
// Don't print empty markup if there's only one page.
if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
return;
}
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
@mojaray2k
mojaray2k / instafeedjsaccess.md
Last active February 10, 2025 17:40
Getting Instagram Access Token for http://intafeedjs.com

#Use this URL to get your client authorized for Instafeed.JS plugin for Instagram.

  1. First login into your Instargam account
  2. Then go to https://www.instagram.com/developer/
  3. At the top click on the Button that says "Manage Clients".
  4. If you have not Register a new client.
  5. Fill out everything and where it says redirect url put this url: http://instafeedjs.com
  6. Then on the security tab make sure you uncheck "Disable implicit OAuth"
  7. Finally use this link to authoruize Instafeed. Where it says "[Client ID]" replace that including the brackets with your clientID from instagram:
  8. https://instagram.com/oauth/authorize/?client_id=[Client ID]&redirect_uri=http://instafeedjs.com&amp;response_type=token
@mrabbani
mrabbani / mailgun-config.md
Last active January 8, 2024 01:45
Laravel Mailgun Setup

Mailgun setup

  • install Guzzle HTTP library : composer require guzzlehttp/guzzle
  • [sign up to mailgun] (http://www.mailgun.com)
  • Go to Domains tab and click on domains
  • You will find the necessary data for .env setup
    • MAIL_DRIVER=mailgun
    • MAIL_HOST=smtp.mailgun.org
    • MAIL_PORT=587
    • MAIL_USERNAME=[email protected]
  • MAIL_PASSWORD=502fd951f7------------------------
@joshnuss
joshnuss / app.js
Last active February 18, 2025 15:49
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
// Common Route Patterns http://laravel-tricks.com/tricks/routing-patterns
// Patterns
Route::pattern('id', '\d+');
Route::pattern('hash', '[a-z0-9]+');
Route::pattern('hex', '[a-f0-9]+');
Route::pattern('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
Route::pattern('base', '[a-zA-Z0-9]+');
Route::pattern('slug', '[a-z0-9-]+');
Route::pattern('username', '[a-z0-9_-]{3,16}');
@CodeBrauer
CodeBrauer / GMGetCoordinates.php
Last active March 19, 2025 20:18
get coordinates from address with google maps api
<?php
function GMGetCoordinates($address) {
$address = urlencode($address);
$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false";
$ch = curl_init();
$options = array(
CURLOPT_SSL_VERIFYPEER => false,