Skip to content

Instantly share code, notes, and snippets.

View kukiron's full-sized avatar
🚀
I do stuff.

Kafil Uddin Kiron kukiron

🚀
I do stuff.
View GitHub Profile
@kukiron
kukiron / gist:1a9c7ec9d57acf018633611101372d5f
Created January 18, 2018 15:04 — forked from rmwxiong/gist:ad6e922dcc739a599640
Fix for color components with single digit values
// get the average color of two hex colors.
function avgcolor(color1,color2){
var avg = function(a,b){ return (a+b)/2; },
t16 = function(c){ return parseInt((''+c).replace('#',''),16) },
hex = function(c){ var t = (c>>0).toString(16);
return t.length == 2 ? t : '0' + t },
hex1 = t16(color1),
hex2 = t16(color2),
r = function(hex){ return hex >> 16 & 0xFF},
g = function(hex){ return hex >> 8 & 0xFF},
@kukiron
kukiron / UPGRADE-7.0.md
Created January 13, 2018 20:51 — forked from xtuc/UPGRADE-7.0.md
Upgrade guide for Babel 7
@kukiron
kukiron / index.js Capture DOM element screenshot using Chrome headless
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1});
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'});

This describes the common mistake with using closures in JavaScript.

A function defines a new environment

Consider:

function makeCounter()
{
  var obj = {counter: 0};
@kukiron
kukiron / TestSetupExampleCRAEnzymeChaiMocka.md
Created November 2, 2017 03:51 — forked from busypeoples/TestSetupExampleCRAEnzymeChaiMocka.md
Mocha/Chai/Enyzme test setup with create-react-app

Basic setup for using Enzyme/Mocha/Chai with create-react-app

This is a temporary solution. Might change in the near future, this depends on how create-react-app will implement testing.

create-react-app quick-test-example

cd quick-test-example

npm run eject
@kukiron
kukiron / GitHub with Operator Mono font for code.md
Created October 23, 2017 04:33 — forked from tdd/GitHub with Operator Mono font for code.md
Use Operator Mono Ssm font in GitHub code views (PRs, diffs, etc.)

So you love the Operator Mono font? I don't blame you! So do we! It's a bit pricey but worth every penny.

In fact, we're so used to it in our editors that we were a bit sad with GitHub's otherwise neat code views. When we review PRs in the web UI, we want our Operator Mono!

So, assuming you have it installed on your machine, you can put the JS bit in the other code snippet of this Gist in a bookmarklet, and click it when you're on a GitHub.com page you want to have switch over to our beloved font. We used the ScreenSmart variant here, which you get in the font package and have probably installed, as it's the more legible one on screens. Feel free to adjust the font name if needed.

@kukiron
kukiron / travis-coveralls.md
Created October 15, 2017 14:12 — forked from tpai/travis-coveralls.md
Build Project with Travis-CI and Coveralls

Directory Structure

.
|-- dist/
|-- src/
|-- test/
|  `-- setup.jsx    # jsdom for renderIntoDocument()
|-- .babelrc
|-- .coveralls.yml
@kukiron
kukiron / .eslintrc.js
Created October 15, 2017 06:03 — forked from adrianhall/.eslintrc.js
A sample .eslintrc file
var OFF = 0, WARN = 1, ERROR = 2;
module.exports = exports = {
"env": {
"es6": true
},
"ecmaFeatures": {
// env=es6 doesn't include modules, which we are using
"modules": true
@kukiron
kukiron / sublime-text-3-setup.md
Created September 13, 2017 13:52 — forked from ijy/sublime-text-3-setup.md
My Sublime Text 3 setup.

Sublime Text 3 Setup

Install Package Control

Install Package Control for easy package management.

  1. Open the console with Ctrl+`
  2. Paste in the following: