Skip to content

Instantly share code, notes, and snippets.

View zanonnicola's full-sized avatar
💭
I like Kotlin

Nicola Zanon zanonnicola

💭
I like Kotlin
View GitHub Profile
@zanonnicola
zanonnicola / fixed.scss
Created July 30, 2015 14:14
# Fixing fixed As it turns out, Paul’s solution for JSConf’s site was exactly what we needed on our own homepage: the background image just needed its own element so it could move independently of the others. Look at the two versions of the code. It happens to be SCSS but there is nothing too special going on. You could make the same changes in …
.what-we-do-cards {
@include clearfix;
border-top: 10px solid rgba(255, 255, 255, .46);
color: $white;
padding-bottom: 4em;
overflow: hidden; // added for pseudo-element
position: relative; // added for pseudo-element
// Fixed-position background image
&::before {
@zanonnicola
zanonnicola / botdata.json
Created January 12, 2017 14:59
Test data for Facebook Chatbot
{
"messages": [
{
"attachment": {
"type": "image",
"payload": {
"url": "https://petersapparel.parseapp.com/img/item101-thumb.png"
}
}
}
@zanonnicola
zanonnicola / fakeRes.json
Last active January 24, 2017 18:55
Fake API response
{
"id": 2,
"messages": [
{
"attachment": {
"type": "image",
"payload": {
"url": "https://placeholdit.imgix.net/~text?txtsize=33&txt=500%C3%97500&w=500&h=500"
}
}
@zanonnicola
zanonnicola / pipe.js
Created February 6, 2017 10:53
Functions piping
const _pipe = (func1, func2) => (...args) => func2(func1(...args));
const pipe = (...funcs) => funcs.reduce(_pipe);
// const myFunc = pipe(add(), double(), triple());
// myFunc(2, 2);
@zanonnicola
zanonnicola / PerformanceNavigationTiming.js
Created February 24, 2017 11:07
The following script shows how a developer can use the PerformanceNavigationTiming interface to obtain accurate timing data related to the navigation of the document:
function init() {
var navigationTiming = performance.getEntriesByType("navigation")[0];
if (window.console) {
console.log("Name: " + navigationTiming.name + "\n" +
"Entry Type: " + navigationTiming.entryType + "\n" +
"Start Time: " + navigationTiming.startTime + "\n" +
"Duration: " + navigationTiming.duration + "\n" +
"Unload: " + (navigationTiming.unloadEventEnd -
navigationTiming.unloadEventStart) + "\n" +
"Redirect: " + (navigationTiming.redirectEnd -
{"data":[{"url":"https://www.ookiy.com/u-s-top-court-preserves-alabama-campaign-finance-curbs-reuters/","source":2,"created":1493042349,"user_id":124197757,"visible":1,"comments":"() ookiy.com/u-s-top-court-…\n#political #US #News #political #TaxDay #CountrySongAFilm #FirstTimeIHeard #FelizMartes #GeneralElection ...","social_feed_id":795777,"social_post_id":"856507810825330692","social_id":"twitter","phash":null,"height":630,"width":1200,"original_image":"https://www.ookiy.com/wp-content/uploads/2017/04/trump-administration-says-no-u-s-trading-partners-manipulate-currency-reuters.png","author":"{\"name\":\"ookiy_news\",\"link\":\"http://twitter.com/ookiy_news\",\"picture\":\"https://res-5.cloudinary.com/tint/image/twitter_name/c_fill,h_75,w_75/ookiy_news\",\"username\":\"ookiy_news\",\"fullname\":\"ookiy_news\"}","embed":"{\"type\":\"\"}","image":"https://res-4.cloudinary.com/tint/image/fetch/c_limit,f_auto,fl_lossy,w_300/https://www.ookiy.com/wp-content/uploads/2017/04/trump-administration-says-no-u-s-tradi
@zanonnicola
zanonnicola / index.js
Last active April 25, 2017 14:57
Pagination Issue
const promiseWhile = (url, condition) => {
let nextUrl;
let counter = 0;
if (!nextUrl) {
nextUrl = url;
}
const list = [];
const fetchData = (list) => {
console.log(`Counter: ${counter++}`);
console.log(`Next Url: ${nextUrl}`);
{
"hits": 400,
"page": 15,
"pagePrev": 1,
"pageNext": 3,
"pageCount": 17
}
@zanonnicola
zanonnicola / query.sql
Created November 24, 2017 12:00
This is way faster
/*
create index ORDER_2_PRODUCT_IDX on order_product(`order_id`);
create index ORDER_2_TOTAL_IDX on order_total(`order_id`);
create index ORDER_STATUS_IDX on order(`order_status_id`);
create index ORDER_2_STATUS_IDX on order_status(`order_status_id`);
create index ORDER_OPTION_IDX on order(`order_product_id`);
create index ORDER_2_OPTION_IDX on order_option(`order_product_id`);
*/
select count(`o`.`order_status_id`) from `order` o where o.`order_status_id` = 0;
@zanonnicola
zanonnicola / index.html
Created November 24, 2017 13:16
HTML5 Form validation. Based on https://jsfiddle.net/Loilo/jdct84x6/3/
<form>
<input
type="number"
placeholder="Enter 42"
min="42"
max="42"
required>
<input
type="email"