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
View data.json
{
"hits": 400,
"page": 15,
"pagePrev": 1,
"pageNext": 3,
"pageCount": 17
}
@zanonnicola
zanonnicola / index.js
Last active April 25, 2017 14:57
Pagination Issue
View index.js
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}`);
View fakeJSON.json
{"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 / 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:
View PerformanceNavigationTiming.js
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 -
@zanonnicola
zanonnicola / pipe.js
Created February 6, 2017 10:53
Functions piping
View pipe.js
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 / fakeRes.json
Last active January 24, 2017 18:55
Fake API response
View fakeRes.json
{
"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 / botdata.json
Created January 12, 2017 14:59
Test data for Facebook Chatbot
View botdata.json
{
"messages": [
{
"attachment": {
"type": "image",
"payload": {
"url": "https://petersapparel.parseapp.com/img/item101-thumb.png"
}
}
}
@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 …
View fixed.scss
.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 / mq_ga.js
Created February 6, 2015 10:19
Measuring Your Site's Responsive Breakpoint Usage with GA
View mq_ga.js
var timeout;
var breakpoints = {
xs: '(max-width: 419px)',
sm: '(min-width: 420px) and (max-width: 569px)',
md: '(min-width: 570px) and (max-width: 799px)',
lg: '(min-width: 800px) and (max-width: 999px)',
xl: '(min-width: 1000px)'
};
Object.keys(breakpoints).forEach(function(breakpoint) {
@zanonnicola
zanonnicola / mixin.scss
Created January 9, 2015 10:53
Helpful mixins: - REM
View mixin.scss
@function countRem($value) {
$remValue: $value / 16px;
@return $remValue * 1rem;
}
@mixin font-size($value) {
font-size: $value;
font-size: calculateRem($value);
}