Skip to content

Instantly share code, notes, and snippets.

View stecb's full-sized avatar
🤓
Ciao!

Stefano Ceschi Berrini stecb

🤓
Ciao!
View GitHub Profile
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
module.exports = {
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin({})
]
},
plugins: [
new MiniCssExtractPlugin({
@stecb
stecb / getorderstotalfromamazon.js
Created November 30, 2015 21:32
get total of orders page on amazon.it
[].slice.call(document.querySelectorAll(".a-span2 .value")).map(function(e){return parseFloat(e.textContent.trim().split("EUR")[1].trim().replace(",","."))}).reduce(function(e,t){return e+t});
import { DEFAULT_ADAPTER } from './constants';
/*
Creates the subscription object
@param component function the React component
@param autoUnmount boolean defaults to true, if it has to remove all subscriptions on cwunmount
@param adapter object the pubsub adapter
@return the subscription object
(function(window){
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,
_eventStack,
_findByName,
stackEvent,
removeEvent,
eventListener,

Keybase proof

I hereby claim:

  • I am stecb on github.
  • I am stecb (https://keybase.io/stecb) on keybase.
  • I have a public key whose fingerprint is C21B 942B F5B8 1026 5597 C395 7494 041B EB13 95C9

To claim this, I am signing this object:

setInterval(function(){var e=["255,238,74","255,197,1","254,150,0","3,0,28"],t=e.length,n=".day";[].forEach.call(document.querySelectorAll(n),function(n){n.style.fill="rgb("+e[~~(Math.random()*t-1)]+")"})},200)
@stecb
stecb / github_rockstar_faker.js
Last active August 29, 2015 14:04
Github Rockstar faker
// go to your github.com/xxx page, copy and paste this inside your favorite web dev tools console, make a screenshot, and boom: You're the new github rockstar
!function(){
var contribsRgbSets=["214,230,133","140,198,101","68,163,64","30,104,35"],
l=contribsRgbSets.length,
selector = '.day';
[].forEach.call(document.querySelectorAll(selector), function(el) {
el.style.fill="rgb(" + contribsRgbSets[~~(Math.random()*l-1)] + ")";
});
}();
@stecb
stecb / throttle
Last active August 29, 2015 14:03
Throttling function
function throttle(e,t){var n,r;return null==t&&(t=100),r=null,n=null,function(){var i,s,o;return s=+(new Date),o=this,i=arguments,n&&n+t>s?(clearTimeout(r),r=setTimeout(function(){return n=s,e.apply(o,i)},t)):(n=s,e.apply(this,i))}}
function doubleInteger(i) {
// i will be an integer. Double it and return it.
return i*2;
}
function isNumberEven(i) {
// i will be an integer. Return true if it's even, and false if it isn't.
return i%2 === 0;
}
@stecb
stecb / gist:3958943
Created October 26, 2012 13:51
drop from url (for carrierwave)
- content_for :javascript_page do
:javascript
$(document).bind('drop', function(e) {
var url
, target = $(e.target)
, remote_avatar = $('#user_remote_avatar_url')
;
if (target.hasClass('dropzone')) {
url = $(e.originalEvent.dataTransfer.getData('text/html')).filter('img').attr('src');
if (target.hasClass('attachments-drop"')) {