Skip to content

Instantly share code, notes, and snippets.

View ivorpad's full-sized avatar
🇪🇸
Working from Spain

Ivor ivorpad

🇪🇸
Working from Spain
View GitHub Profile
" Specify a directory for plugins
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
"Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
@ivorpad
ivorpad / .sh
Created November 7, 2019 22:58
Open mongod process
## foreground
mongod --config /usr/local/etc/mongod.conf
## background
mongod --config /usr/local/etc/mongod.conf --fork
## check if is running
ps -ef | grep mongod
<?php
function theme_prefix_kses_allowed_html($tags, $context) {
switch($context) {
case 'social':
$tags = array(
'a' => array('href' => array()),
'b' => array()
);
return $tags;
default:
@ivorpad
ivorpad / jsbin.qotehog.js
Last active July 25, 2019 14:58
JS Binhello there// source https://jsbin.com/qotehog
var str = 'Travellyte - Travel Travel Travel hotwheels PSD Template WordPress';
var r = /[^\w_]+/g
arr = str.replace(r, ' ').toLowerCase().split(" ");
var t = arr.reduce((acc, current, idx) => {
acc.push({ terms: current });
return acc;
}, [])
@ivorpad
ivorpad / find_title.js
Last active July 24, 2019 08:22
Find in API matching titles
async function findItemTitle(
searchTerm,
category,
fuzzy = false
) {
let { total_hits } = await fetch(
`url`
)
.then(r => r.json())
.then(r => r);
@ivorpad
ivorpad / pubsub-class.js
Last active July 10, 2019 08:58
Basic PubSub pattern
class PubSub {
constructor() {
this.events = {};
}
subscribe(event, callback) {
let index;
if (!this.events[event]) {
this.events[event] = [];
}
@ivorpad
ivorpad / App.svelte
Last active July 4, 2019 18:15
Just playing around with Svelte
<script>
import Form from './Form.svelte';
let users = [
{id: 0, name: 'ivor'},
{id: 1, name: 'pad'}
];
</script>
<Form users={users}/>
@ivorpad
ivorpad / .sql
Created June 28, 2019 13:46
An example of how to set a variable from a query in SQL
SET
@meta_id :=(
SELECT
meta_value
FROM
wp_posts,
wp_postmeta
WHERE
wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.post_id = 146 AND meta_key = '_audio_file_id'
);
@ivorpad
ivorpad / .sql
Created June 25, 2019 22:13
Example of GROUP_CONCAT to order movies by country count and display countries as comma separated values in `countries`
-- imdb dataset
SELECT
title,
year,
GROUP_CONCAT(country) as 'countries',
COUNT(country) as 'country_count'
FROM `movies`
INNER JOIN `countries`
ON movies.`movieid` = countries.`movieid`
GROUP BY title
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.