Skip to content

Instantly share code, notes, and snippets.

View jordinebot's full-sized avatar
👋
Hi! I'm Jordi.

Jordi Nebot jordinebot

👋
Hi! I'm Jordi.
View GitHub Profile
@jordinebot
jordinebot / cassidoo-1-august-2022.js
Created August 3, 2022 08:50
Cassidoo's Interview question of the week
/*
* Given an integer n, count the total number of 1 digits appearing in all non-negative integers less than or equal to n.
*
* > numberOfOnes(14)
* > 7 // 1, 10, 11, 12, 13, 14
*
*/
function numberOfOnes(n) {
return [...Array(n + 1).keys()].reduce(
@jordinebot
jordinebot / ajax.class.js
Created May 9, 2017 10:04
ES6 Ajax Class
/* https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState */
const UNSENT = 0,
OPENED = 1,
HEADERS_RECEIVED = 2,
LOADING = 3,
DONE = 4;
/* https://developer.mozilla.org/en-US/docs/Web/HTTP/Status */
const OK = 200;
@jordinebot
jordinebot / fan-set
Created December 15, 2016 07:51
iMac Fan speed controller
#!/bin/bash
# Set fan 1 to forced mode
smc -k "FS! " -w 0002
# Set fan 1 to required RPM (Use rpm2hex to get the value)
RPM="$(rpm2hex $1)"
smc -k F1Tg -w ${RPM:2:4}
echo "Fan 1 set to $RPM RPM"
@jordinebot
jordinebot / keybase.md
Created November 11, 2016 15:21
Keybase's Github identity proof

Keybase proof

I hereby claim:

  • I am jordinebot on github.
  • I am jordinebot (https://keybase.io/jordinebot) on keybase.
  • I have a public key ASC3vgRoWagImYv9afncwCePx4SkcAnbzU-miwtNcQaZfgo

To claim this, I am signing this object:

@jordinebot
jordinebot / me.js
Last active November 28, 2016 14:32
let jordiNebot = {
type: 'Full Stack Web Developer',
employer: 'Self-employed',
from: {
city: 'Barcelona',
coordinates: {
lat: 41.3891006,
lng: 2.1333274999999503
}
},
@jordinebot
jordinebot / .htaccess
Last active November 16, 2023 12:32
Optimized .htaccess for Google PageSpeed Insights
# ########################
# Leverage browser caching
# ########################
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
@jordinebot
jordinebot / api.coffee
Created March 22, 2016 10:10
API Caller
class API
constructor: (url) ->
@url ?= apiURL
@status =
OK: 200,
DONE: 4
@cache = {}
@cacheExpiration = 0 #seconds
@jordinebot
jordinebot / patterns.coffee
Last active March 11, 2016 12:14
Regular Expressions object for form validation
patterns =
name:
/// ^
[a-z|A-Z|àáèéíòóúÀÁÈÉÍÒÓÚïÏüÜçÇñÑ\-ºª\s]{2,}
$ ///i
email:
/// ^
([\w-\.]+@([\w-]+\.)+[\w-]{2,4})
$ ///i
date:
@jordinebot
jordinebot / load-wordpress.php
Created January 25, 2016 16:59
Load Wordpress
/* Load Wordpress in any file inside wp-content/ */
defined('ABSPATH') or define('ABSPATH', preg_replace('/\/wp-content\/.*/', '', __DIR__) . '/');
require_once ABSPATH . 'wp-load.php';
@jordinebot
jordinebot / grid.scss
Last active January 11, 2016 17:55
So Simple SCSS Grid
/* Clearfix */
@mixin clearfix {
&:after {
content: "";
display: table;
clear: both;
}
}
/* Media Queries */