Skip to content

Instantly share code, notes, and snippets.

View goffreder's full-sized avatar

Emanuele Biancardi goffreder

View GitHub Profile
Cookiematic = class {
constructor(interval, debug = false) {
this.status = 'inactive';
this.interval = interval;
this.debug = debug;
this.overrideMaxBuildings = false;
this.maxBuildings = [
600,
-1,
var webpack = require('webpack');
var path = require('path');
module.exports = {
devtool: process.env.NODE_ENV !== 'production' ? 'eval' : null,
entry: [
'babel-polyfill',
'./app/app.jsx'
],
output: {
- Installare npmo (vedi mail su wyscout.com con istruzioni)
- Registro il client:
npm login --registry=http://arrested-developer.com:8080 --scope=wyscout
utente github (goffreder - GitHub password - goffreder@gmail.com)
- Creo pacchetto da pubblicare
{
"name": "@wyscout/test-npm",
"version": "1.0.1",
"description": "A npm test package",
@goffreder
goffreder / .eslintrc
Last active December 13, 2015 16:12
Base eslintrc file
{
"parser": "babel-eslint",
"plugins": [
"react",
"objects"
],
"env": {
"browser": true,
"node": true
},
@goffreder
goffreder / indiegogoavgcalc
Last active August 29, 2015 14:23
Average fund calculation for indiegogo
(function($) {
$('<div>').addClass('i-average-fund').insertBefore($('.i-progress-bar'));
$('<div>').addClass('i-ppl-needed').insertBefore($('.i-progress-bar'));
window.avgInterval = setInterval(function() {
var balanceTxt = $(".i-balance span span").text();
var curr = balanceTxt[0];
var balance = parseFloat($(".i-balance span span").text().replace(curr, '').replace(/,/g,''));
var people = parseInt($(".i-raised-funders").text().replace(/,/g,''));
@goffreder
goffreder / griddleBSButton.js
Created June 11, 2015 07:18
Wrapper for react-bootstrap's Button to be used in griddle-react tables
import 'bootstrap/dist/css/bootstrap.min.css';
import { Button } from 'react-bootstrap';
import Griddle from 'griddle-react';
class GriddleBSButton extends React.Component {
constructor(props) {
super(props);
}
# Rompere tasto back:
window.history.pushState(0, window.location.href);
window.onpopstate = function() {
window.history.pushState(0, window.location.href);
};
- versione minificata (61 chars):
(onpopstate=Function('history.pushState(0,location.href)'))()
# Log stack trace in un punto
@goffreder
goffreder / Note su JS
Last active August 29, 2015 14:13
Appunti vari
Immutable collections (oggetti immutabili)
Si tratta di creare oggetti che non possono essere mutati. Esiste un'implementazione standard (Object.freeze()) ma ha alcuni problemi e non fornisce helpers. Esistono varie librerie.
Permettono di fare comodamente undo/redo salvando i vari stati (soprattutto se si sa che alcune parti non cambiano, è semplice mantenere gli stati facendo diff) [https://scott.mn/2014/04/27/why_immutable_collections/]
Separazione tra identità e valori (vedere Clojure [https://scott.mn/2014/01/20/reference_types_separate_identities_and_values/])
Molto efficiente unione React + immutable (se opportunamente configurato si possono evitare alcuni re-render dell'applicazione, sapendo che a identità diverse corrispondono valori diversi) [http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/] (vedere benchmarks, Backbone [http://swannodette.github.io/todomvc/architecture-examples/backbone/index.html] vs Om (Clojure) [http://swannodette.github.io/todomvc/labs/architecture-example
@goffreder
goffreder / pokemon-list.txt
Created January 12, 2011 10:36
Pokemon Cards List
Legenda:
RO = Rara Olografica
R = Rara
NC = Non Comune
C = Comune
WOTC = Wizards of the Coast edition
JP = Giapponese
P = Promo
// ==UserScript==
// @name TFP Forum Ads Remover
// @description Removes ads from TFP Forum
// @include http://www.tfpforum.it
// ==/UserScript==
var ads = document.getElementById('ads');
if(ads) {
ads.parentNode.removeChild(ads);
}