Skip to content

Instantly share code, notes, and snippets.

View hectorromo's full-sized avatar

Hector Romo hectorromo

View GitHub Profile
@hectorromo
hectorromo / instagram_feed.php
Last active December 19, 2020 12:00
Access instagram feed.
<?php
// Code taken from this post https://vinkla.dev/blog/fetch-instagram-data-with-php
$response = file_get_contents('https://instagram.com/wearestrom/?__a=1');
$user = json_decode($response);
$media = $user->graphql->user->edge_owner_to_timeline_media->edges;
// Displays latest post in feed.
echo '<a href="https://instagram.com/p/'. $media[0]->node->shortcode .'">';
@hectorromo
hectorromo / git_overwrite_branch
Created March 15, 2020 03:17 — forked from rgbink/git_overwrite_branch
Completely Overwrite chosen git branch
git checkout desired_branch // put in the name of the branch you wish to KEEP
git merge -s ours branch_to_be_replaced // put in the name of the branch you want to OVERWRITE
git checkout branch_to_be_replaced // put in the name of the branch you want to OVERWRITE
git merge desired_branch // put in the name of the branch you wish to KEEP
Seven different types of CSS attribute selectors
// This attribute exists on the element
[value]
// This attribute has a specific value of cool
[value='cool']
// This attribute value contains the word cool somewhere in it
[value*='cool']
@hectorromo
hectorromo / web-servers.md
Created February 3, 2020 14:05 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@hectorromo
hectorromo / pick-reject.js
Created December 3, 2019 18:13
pick and reject
function reject(obj, keys) {
return Object.keys(obj)
.filter(k => !keys.includes(k))
.map(k => Object.assign({}, {[k]: obj[k]}))
.reduce((res, o) => Object.assign(res, o), {});
}
function pick(obj, keys) {
return keys.map(k => k in obj ? {[k]: obj[k]} : {})
.reduce((res, o) => Object.assign(res, o), {});
@hectorromo
hectorromo / .htaccess
Created March 21, 2019 09:22
Brotli and gzip compression
# Rules to correctly serve gzip compressed CSS and JS files.
# Requires both mod_rewrite and mod_headers to be enabled.
<IfModule mod_headers.c>
# Serve brotli compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} br
RewriteCond %{REQUEST_FILENAME}\.br -s
RewriteRule ^(.*)\.css $1\.css\.br [QSA]
# Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
@hectorromo
hectorromo / .htaccess
Last active October 3, 2019 06:53
www & https
RewriteEngine on
### WWW & HTTPS
# Force www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Force non-www:
@hectorromo
hectorromo / config.php
Created July 5, 2018 15:27 — forked from andreasnymark/config.php
Kirby file upload
/**
* File upload
*
*
**/
array(
'pattern' => 'ajax/fileupload',
'method' => 'POST',
'action' => function () {
$site = site();
@hectorromo
hectorromo / .vimrc
Created June 6, 2018 11:27 — forked from JeffreyWay/.vimrc
My .vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
wp core download
wp core config --dbname=$1 --dbuser=root --dbpass=root --dbhost=localhost --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
PHP
wp db create
wp core install --url=http://$1.com --title=$1 --admin_user=admin --admin_password=password --admin_email=admin@$1.com