Skip to content

Instantly share code, notes, and snippets.

<script>function open_url (url) { window.open(url) } </script><div style="position:relative"><img src="/wp-content/uploads/2015/09/norma_final1.png" alt=""><svg style="position: absolute; top: 0; left: 0; width: 100%;" version="1.1" id="some" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1399.825 774.903" opacity="0"><circle style="cursor: pointer;" cx="286.293" cy="574.184" r="27.538" onclick="javascript:open_url('http://facebook.com/Sin-azúcar-por-favor-1430341217285874')"/><circle style="cursor: pointer;" cx="351.308" cy="574.184" r="27.538" onclick="javascript:open_url('http://twitter.com/SinAzucarPorFav')"/><circle style="cursor: pointer;" cx="416.57" cy="574.184" r="27.538" onclick="javascript:open_url('http://instagram.com/ferfam')"/></svg></div>
@ivanfgm
ivanfgm / fast-scroll-detection.js
Last active September 25, 2018 22:27
Scroll detection using a request animation frame for smoothness, implementation for simple parallax.
// Returns the supported property name of a style property from an array of possible names, if non is supported, returns null
function supported_property_name(properties) {
for (var i = 0; i < properties.length; i++) {
if (typeof document.body.style[properties[i]] != "undefined") return properties[i];
}
return null;
}
var transforms = ["transform", "msTransform", "webkitTransform", "mozTransform", "oTransform"];
var transform = supported_property_name(transforms);
@ivanfgm
ivanfgm / routing.php
Last active November 22, 2016 18:37
Redirect to index in php built in server. taken from http://www.lornajane.net/posts/2012/php-5-4-built-in-webserver
<?php
if (file_exists(__DIR__ . '/' . $_SERVER['REQUEST_URI']))
return false;
include_once 'index.php';
@ivanfgm
ivanfgm / .htaccess-index.php
Last active June 26, 2017 22:05
htaccess file that redirects all traffic to index.php in apache.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
@ivanfgm
ivanfgm / responses-scrapper.js
Last active October 10, 2017 15:42
Scrap responses to a tweet directly off twitter html
function paddy(n, p, c) {
var pad_char = typeof c !== 'undefined' ? c : '0';
var pad = new Array(1 + p).join(pad_char);
return (pad + n).slice(-pad.length);
}
function formatted_date () {
var formattedDate = new Date();
@ivanfgm
ivanfgm / instalar-karel-en-mac.md
Last active September 11, 2017 17:38
Instalar karel el robot en mac OS usando wine, probado en mac OS Sierra 10.12.5.

Instalar Karel el Robot en macOS

Instalar karel el robot en mac OS usando wine, probado en mac OS Sierra 10.12.5.

Consideraciones

Antes de probar algo esto, cabe mencionar que en errores de compilación del programa aparece un "Problem access violation", sólo es porque el programa no se puede compilar por un error de sintaxis, referencia, o porque hay un comentario, por alguna razón no se pueden usar comentarios. Esta forma no es perfecta, pero al menos no hay que instalar una máquina virtual.

Instrucciones

@ivanfgm
ivanfgm / evaluar-profesores-saes.js
Created June 28, 2018 18:48
Una línea para evaluar profesores desde consola en SAES del IPN
var s = document.getElementsByTagName('select'), l = s.length; while (l--) s[l].value = s[l].children.length > 3 ? 5 : 2;
@ivanfgm
ivanfgm / count-outside-links-analytics.js
Created March 15, 2019 16:50
Evento para contar links externos a través de eventos
@ivanfgm
ivanfgm / mail2telegram.js
Last active January 13, 2023 10:46
Small script to send received emails to a telegram bot, easy piece thanks to: node-telegram-bot-api and mail-listener2
const makeBot = require('node-telegram-bot-api');
const mailListener = require("mail-listener2");
const config = {
// First get your telegram bot
telegramToken: 'Obtain your token talking to BotFather on telegram',
// Send a message to the bot and paste here your chat id (the response)
// TODO: login to avoid this step and allow multiple users
chatID = 'Chat ID',
// Gmail or Gsuite settings
@ivanfgm
ivanfgm / firebaseApp.js
Created August 7, 2020 14:47
Config file to integrate firebase with next.js or react projects in general
// This assumes you have a .env.local with firebase config constants
import * as firebase from 'firebase/app' // yarn add firebase
import 'firebase/auth' // if you use them
import 'firebase/firestore' // if you use them
const config = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_APIKEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTHDOMAIN,
databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASEURL,