Skip to content

Instantly share code, notes, and snippets.

View bitIO's full-sized avatar

Francisco Calle Moreno bitIO

View GitHub Profile
@bitIO
bitIO / api.ts
Last active September 10, 2020 03:40
Axios Typescript API
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
import { API_BASE_URL } from './apiConfig';
/**
* ES6 Axios Class.
*
* @class Api
* @extends {Axios}
* @example
* class UserApi extends Api {
@bitIO
bitIO / fixpackage.js
Created February 6, 2019 15:25
Update package.json with version from package-lock.json
const fs = require('fs');
const pl = require('./package-lock.json');
const p = require('./package.json');
const plDeps = Object
.entries(pl.dependencies)
.reduce((deps, [dep, { version }]) => Object.assign(deps, { [dep]: version }), {});
Object.entries(p.dependencies).forEach((dep) => {
const finalDep = plDeps[dep[0]];
@bitIO
bitIO / git-rewrite-history.sh
Last active August 13, 2022 11:41
How to rewrite history in a git repo
#!/bin/sh
## change commits
#######################################################
git filter-repo --commit-callback '
msg = commit.message.decode(\"utf-8\")
newmsg = msg.replace(\"old string\", \"new string\")
commit.message = newmsg.encode(\"utf-8\")
' --force
@bitIO
bitIO / shell-commnads.sh
Last active December 11, 2015 12:43
Git cheatsheet
# configure git log to show colored tree in one line with author and relative date
# refs: https://git-scm.com/docs/git-log
# http://git-scm.com/docs/pretty-formats
# http://willi.am/blog/2015/02/19/customize-your-git-log-format/
git config --global --add alias.lol "log --graph --decorate --abbrev-commit --all --pretty=format:'%C(auto)%h%d%Creset %s %Cgreen%ad%Creset por %Cblue%cn%Creset' --date=relative"
@bitIO
bitIO / pre-commit
Last active February 21, 2016 14:14
Git local hooks
#!/bin/bash
# Don't allow console.log() statements to be committed.
# Add to .git/hooks/pre-commit
YELLOW='\033[1;33m'
RED='\033[0;31m'
RESET='\033[0m'
# Don't allow console.log() statements to be committed.
@bitIO
bitIO / post-receive
Created November 3, 2015 15:24
Git hook used on my Digital Ocean droplet to deploy automatically my local Ghost installation (requires a local git repository in the droplet)
#!/bin/sh
git --work-tree=/var/www/ghost --git-dir=/root/repository/ checkout -f
cd /var/www/ghost
chown -R ghost:ghost *
npm install --production
cd content/data
rm ghost.db
ln -s ghost-dev.db ghost.db
@bitIO
bitIO / dimensions.js
Created October 15, 2014 06:42
Screen/Window/Viewport Width & Mouse event coordinates;
// SOURCE : http://xahlee.info/js/js_viewport_dimension.html
// CSS PIXELS: http://xahlee.info/js/web_design_screen_density.html
// user's physical screen dimension/size (Result is in physical pixels)
console.log( screen.width, screen.height );
// user's window size (Result is in CSS pixels)
console.log( window.innerWidth, window.innerHeight );
// viewport size (Result is in CSS pixels)
@bitIO
bitIO / curl-post-file.sh
Last active August 29, 2015 14:04
Linux common tasks
#!/bin/bash
# posts a file named body.json to url
curl -H "Content-Type: application/json" --data-binary @body.json http://localhost:8080/ui/webapp/conf
@bitIO
bitIO / howto.sh
Last active August 29, 2015 14:04
How to update GitHub forked repository
# Reference:
# http://stackoverflow.com/questions/7244321/how-to-update-github-forked-repository
# ==============================================================================
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
@bitIO
bitIO / index.html
Created August 16, 2013 07:10
A CodePen by leemark. Simple image crossfade slideshow - CSS animation - A simple CSS animation, with a staggered start time for each image. A nice little algorithm for calculating the animation timing percentages can be found at: http://css3.bradshawenterprises.com/cfimg/
<ul>
<li><img width="495" height="370" title="" alt="css3" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgBcgHvAwERAAIRAQMRAf/EALQAAAMBAQADAQAAAAAAAAAAAAIDBAEABQYHCAEBAQEBAQEBAQAAAAAAAAAAAAECAwQFBgcQAAICAQIEBAEHCAYEDAYDAAABAgMRIQQxQRMFUWESBnGBkdHSkxQHoSIyklQVVRax8WKCoiPB4VKU8EJywjNzo8O0NUUIQ4MkRCVlJkYXEQEBAQACAQIFAgUCBgMAAAAAARECEgMhBFGRUhMFMRRBYbHRFSIy8HGh4fFCgSMG/9oADAMBAAIRAxEAPwD8xYMvotwRW4A7AV2AmO9I0xvpCtSyRWuIMd6AO9AGqBFx3oKmO6b8CpjPR5AEoEUXoIrukFY6is4HpGowx1cjbmzpLkgY7pFTHdIg7pBWdLyBjHSVMd0AmO6L5lMd0QY7okMd0GFx3QGrjegExvQBjuh5Ax3QBjeh5BMd93BjntyauB6Go0xnSCYzpeRV6s6WoMZ0sAxnTBgXWEwPTKmMdZUwPoCM9BRnoAz0hHekDseAGYAzBUdgDmkBmAjgMA8nhnme7G4IY3AaxvpBjvSDG+gGN9HAhglDHIauO9A1cF6BpjlAJglEK30Ab6BpjvRyCY3pgaqgrVAo70II7pmmLGOo1rGO6XkDHKoGN6XkVMZ0vIqY7o+QGqkLjuiExzoKY7oAd0CDeh5