Skip to content

Instantly share code, notes, and snippets.

View faridv's full-sized avatar
😐
‌Dealing with challenges like this -> :|

Farid Rn faridv

😐
‌Dealing with challenges like this -> :|
View GitHub Profile
@faridv
faridv / ticker.plugin.js
Created November 11, 2018 15:21
Titles ticker plugin for jQuery
// Ticker Plugin
$.fn.fTicker = function (options) {
var $ticker = $(this);
var settings = $.extend({
// defaults.
timeout: 5000
}, options);
$.each($ticker, function () {
var $el = $(this).find("ul:first");
if ($el.find("li").length < 2)
(function takeOverConsole() {
var console = window.console;
function intercept(method) {
var original = console[method];
console[method] = function () {
var message = Array.prototype.slice.apply(arguments).join(' ');
original.call(console, arguments);
var xhr = new XMLHttpRequest();
// xhr.open('get', '/log.php?error=' + message);
@faridv
faridv / getmax.ts
Created January 27, 2020 16:40
To find the maximum y value of the objects in array:
// https://stackoverflow.com/a/4020842/893111
Math.max.apply(Math, array.map(o => o.y))
@faridv
faridv / gist:4dfa45ad5b5c9ff86af7b7fb233c0eb4
Created July 19, 2026 11:16
Create rows based on chunks of data
const chunk = (arr: any[], size: number): any[][] =>
arr.reduce((rows: any[][], item: any, index: number) => {
if (index % size === 0) rows.push([]);
rows[rows.length - 1].push(item);
return rows;
}, []);
{chunk(items, 2).map((row: any[], rowIndex: number) => (
<div className='row' key={rowIndex}>
{row.map((items: any) => (