Skip to content

Instantly share code, notes, and snippets.

View LeonardoGentile's full-sized avatar

LeonardoGentile

  • Jellysmack
  • Nice, France
View GitHub Profile
@SixQuant
SixQuant / plot_table.py
Created October 29, 2020 15:29
[Matplotlib plot table]plot table(auto adjust column width by text length) #Matplotlib #table
import time
import matplotlib.pyplot as plt
import numpy as np
import six
from PIL import ImageFont
from numpy.random import randn
# noinspection PyPep8Naming
@gfguthrie
gfguthrie / .zshrc
Created September 27, 2019 22:02
Lazy Load Homebrew NVM but still have default aliased Node in PATH
# normal brew nvm shell config lines minus the 2nd one
# lazy loading the bash completions does not save us meaningful shell startup time, so we won't do it
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion" # This loads nvm bash_completion
# add our default nvm node (`nvm alias default 10.16.0`) to path without loading nvm
export PATH="$NVM_DIR/versions/node/v$(<$NVM_DIR/alias/default)/bin:$PATH"
# alias `nvm` to this one liner lazy load of the normal nvm script
alias nvm="unalias nvm; [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"; nvm $@"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Font
:set guifont=Source\ Code\ Pro:h14
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Hide pointless junk at the bottom, doesn't work in .vimrc for some reason?
:set laststatus=0
:set noshowmode "don't show --INSERT--
:set noruler "don't show line numbers/column/% junk
import React from 'react';
import { render } from 'react-dom';
import { connect, Provider as ReduxProvider } from "react-redux";
import { BaseLink, RouterProvider } from 'react-router5';
import { applyMiddleware, combineReducers, createStore } from 'redux';
import { routeNodeSelector, router5Middleware, router5Reducer } from 'redux-router5';
import createRouter from 'router5';
import browserPlugin from 'router5/plugins/browser';
const App = ({ route }) => {
@tibotiber
tibotiber / tooltips-example.js
Last active March 10, 2018 12:24
RD3 medium post content
class Chart extends React.Component {
// ...
componentDidUpdate (prevProps, prevState) {
const stripState = p => _.omit(p, ['hover'])
if (!shallowEqual(stripState(this.state), stripState(prevState))) {
this.renderD3()
}
}
// ...
setHover (hX) {
@zbyte64
zbyte64 / async_app.py
Created May 26, 2016 20:47
Asyncio Views With Django
import asyncio
from django import http
from django.core.urlresolvers import set_script_prefix
from django.utils.encoding import force_str
from django.core.handlers.wsgi import get_script_name
from django_wsgi.handler import DjangoApplication
import logging
import logging
import sys
@nasitra
nasitra / Flatland Dark.tmTheme
Last active June 28, 2016 13:22
Insert color scheme settings to Flatland theme for Sublime Text 3 (build 3103)
...
<dict>
<key>name</key>
<string>Entity.name.label</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F8F8F8</string>
@Restuta
Restuta / the-bind-problem.jsx
Last active March 16, 2024 00:22
React, removeEventListener and bind(this) gotcha
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
}
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));
@ar45
ar45 / custom_serializers.py
Last active August 31, 2022 14:23
Dynamic QuerySet serializer
from rest_framework import serializers
from django.db.models.manager import Manager
from django.db.models.query import QuerySet
class LimitQuerySetSerializerFieldMixin:
"""
Serializer mixin with a special `get_queryset()` method that lets you pass
@whatnickcodes
whatnickcodes / chrome-cache-recovery.js
Last active November 23, 2016 05:32
Quick and dirty script to recover images from chrome cache. Just paste this into your console to automatically download all Scotch.io cached images
// Open chrome://cache/ and paste the following script in the console. Feel free to edit the filter variable
var filter = /cask\.scotch\.io(.)*\.(jpg|jpeg|png|gif)/g;
/*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);retu