Skip to content

Instantly share code, notes, and snippets.

View santospatrick's full-sized avatar
👽
Javascripting

Patrick Santos Bitonti Teixeira santospatrick

👽
Javascripting
View GitHub Profile
@miguelmota
miguelmota / getDates.js
Last active February 7, 2024 23:43
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
function getDates (startDate, endDate) {
const dates = []
let currentDate = startDate
const addDays = function (days) {
const date = new Date(this.valueOf())
date.setDate(date.getDate() + days)
return date
}
while (currentDate <= endDate) {
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active July 4, 2024 23:40
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@thgaskell
thgaskell / README.md
Last active January 18, 2022 10:30
Sequelize + Express Starter Guide
@Restuta
Restuta / HOC.js
Last active May 26, 2024 20:01
React HOC (Higher Order Component) Example
/* HOC fundamentally is just a function that accepts a Component and returns a Component:
(component) => {return componentOnSteroids; } or just component => componentOnSteroids;
Let's assume we want to wrap our components in another component that is used for debugging purposes,
it just wraps them in a DIV with "debug class on it".
Below ComponentToDebug is a React component.
*/
//HOC using Class
//it's a function that accepts ComponentToDebug and implicitly returns a Class
let DebugComponent = ComponentToDebug => class extends Component {
@paulsturgess
paulsturgess / service.js
Last active February 2, 2024 17:24
An example Service class wrapper for Axios
import axios from 'axios';
class Service {
constructor() {
let service = axios.create({
headers: {csrf: 'token'}
});
service.interceptors.response.use(this.handleSuccess, this.handleError);
this.service = service;
}
@javilobo8
javilobo8 / download-file.js
Last active July 1, 2024 23:21
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@santospatrick
santospatrick / terminal-oh-my-zsh.md
Last active June 14, 2024 18:14
Terminal with oh-my-zsh (Linux/Windows/MacOSX)

Terminal with oh-my-zsh (Linux/Windows/MacOSX)

Every step in this tutorial is required for making terminal look as the image below.

ZSH & OH-MY-ZSH

sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@jaredpalmer
jaredpalmer / patch.js
Created August 26, 2017 21:06
Change the port in CRA's WebpackHotDevClient.
const fs = require('fs');
// Monkey-patch react-dev-utils to get the error overlay with SSR
const pathToDevClient = 'node_modules/react-dev-utils/webpackHotDevClient.js';
// The react-scripts default
const reactScriptsPort = 3000;
// Read the dev client out of node_modules
const HotDevClient = fs.readFileSync(pathToDevClient, 'utf8');
@guregu
guregu / fix-image-maps.js
Created October 17, 2017 14:40
Responsive image maps (vanilla JS)
function fixImageMaps(force) {
var imgs = document.querySelectorAll("img[usemap]");
[].forEach.call(imgs, function(img) {
if (!img.naturalHeight) { return; }
var h = img.height / img.naturalHeight;
var w = img.width / img.naturalWidth;
var map = document.getElementsByName(img.useMap.slice(1))[0];
if (!map) { return; }
for (var i = 0; i < map.children.length; i++) {
var area = map.children[i];