Skip to content

Instantly share code, notes, and snippets.

@jesusgoku
jesusgoku / ObjectIterators.js
Created August 12, 2019 16:13
Implement Symbol.Iterator for objects
/**
* Apply to Symbol.iterator on object to enable iteration
*
* @param field values, keys, entries
*
* @return {Function}
*/
function ObjectIteraror(field) {
if (!['keys', 'values', 'entries'].includes(field)) {
throw new Error('Incorrect field value, available values: keys, values, entries');
@jesusgoku
jesusgoku / install-dependencies.sh
Created March 27, 2019 17:07
Use php-build on Ubuntu 18.04
#!/usr/bin/env sh
sudo apt install \
libxslt1-dev \
libtidy-dev \
libpng-dev \
libcurl4-gnutls-dev \
libmcrypt-dev \
libjpeg-dev \
libbz2-dev \
@jesusgoku
jesusgoku / organize.py
Created March 17, 2019 01:13
Organize movies on folders by year
#!/usr/bin/env python
from __future__ import print_function
import os
import re
import sys
import shutil
import subprocess
def main():
@jesusgoku
jesusgoku / create-html5-videos.sh
Created February 6, 2019 13:13
Shell script for create HTML5 video formats
#!/usr/bin/env bash
SOURCE="$1"
# x264
ffmpeg -i "$SOURCE" -y -c:a aac -c:v libx264 -ac 2 -ar 44100 -b:a 96k -b:v 768k "${SOURCE/%.*/-html5-x264.mp4}" > /dev/null 2>&1 &
# x265
ffmpeg -i "$SOURCE" -y -c:a aac -c:v libx265 -ac 2 -ar 44100 -b:a 96k -b:v 768k "${SOURCE/%.*/-html5-x265.mp4}" > /dev/null 2>&1 &
@jesusgoku
jesusgoku / geojson.json
Created February 6, 2019 13:11
AndesHandbook Places
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jesusgoku
jesusgoku / distance.js
Created February 6, 2019 13:08
MongoDB Geolocation Queries and Data
// Santa Elena: [-70.053958306885, -32.838484653423]
var lc = db.Places.findOne({ name: "Cerro La Cruz" }, { _id: false, location: true });
db.Places.aggregate([
{ "$geoNear": {
"near": {
"type": "Point",
"coordinates": lc.location.coordinates,
},
@jesusgoku
jesusgoku / snake.html
Created September 4, 2018 04:39
Snake
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Snake</title>
</head>
<body>
<canvas id="snake" width="400" height="400"></canvas>
<script type="text/javascript">
(function (window, document) {
@jesusgoku
jesusgoku / InfiniteScroll.vue
Created August 24, 2018 13:33
InfiniteScroll component
<script>
export default {
name: 'InfiniteScroll',
template: '<div ref="el" style="height: 0;">&nbsp;</div>',
props: {
offset: {
type: Number,
default: 300,
@jesusgoku
jesusgoku / harvest-registry.sh
Created August 21, 2018 19:06
Detect last project working on your projects folder and create time entry on Harvest
#!/usr/bin/env bash
# @author: Jesús Urrutia <[email protected]>
# @description: Detect last project working on projects folder and create time entry in harvest
# Require create .harvestrc file on your home folder with:
# HARVEST_ACCOUNT_ID=234234234
# HARVEST_ACCESS_TOKEN=2tbetetnseys4563w525j98356tyoiwurkisgknswnervhmia8j4v56uo8werybwu
# Require create .harvest file on root folder project with:
@jesusgoku
jesusgoku / example.sql
Last active July 30, 2018 04:15
MySQL - Query for selected related entries by tags scoring - Inspired on: https://stackoverflow.com/a/2153211/1236791 - http://en.wikipedia.org/wiki/Jaccard_index
CREATE TABLE IF NOT EXISTS layers (
id INT unsigned NOT NULL auto_increment,
name VARCHAR(255) NOT NULL,
PRIMARY KEY(id)
);
CREATE TABLE IF NOT EXISTS tags (
id INT unsigned NOT NULL auto_increment,
name VARCHAR(255) NOT NULL,
PRIMARY KEY(id)