Skip to content

Instantly share code, notes, and snippets.

View iliran11's full-sized avatar
🎯
Focusing

Liran Cohen iliran11

🎯
Focusing
View GitHub Profile
@iliran11
iliran11 / create-file.js
Created June 25, 2017 07:04
calculating files and folders size
const fs = require('fs');
const file = fs.createWriteStream('./big.txt');
for(let i=0; i<= 1e6; i++) {
file.write('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n');
}
file.end();
// http://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
@iliran11
iliran11 / gist:0878236c195059a605602951a05a76e7
Created September 16, 2017 07:38
array of anonymous object, to object with accessors
const array = [
{
id:"1",
name: "john"
},
{
id:"2",
name:"danny"
}
]
@iliran11
iliran11 / gist:1434383b0b774fe5c5c4a16b5f1b4ead
Created September 16, 2017 14:27
waiting for multiple promises before next THEN
var initial = new Promise((resolve, reject) => {
setTimeout(resolve, 3000, 'first time!');
});
var p1 = Promise.resolve(3);
var p2 = 1337;
var p3 = new Promise((resolve, reject) => {
setTimeout(resolve, 100, 'foo');
});
initial
// Current Persons Data Structure in Client
const clientData = [{
id: 1,
employed: true
},
{
id: 2,
employed: false
},
@iliran11
iliran11 / gist:807bb4b434853680213818d598e7c5ac
Created October 20, 2018 14:50
Check which prop has changed that caused re-render
componentDidUpdate(prevProps) {
for (const index in prevProps) {
if (prevProps[index] !== this.props[index]) {
console.log(index, this.props[index], '-->', prevProps[index]);
}
}
}
const { ApolloServer, gql } = require('apollo-server');
import typeDefs from './schema';
import resolvers from './resolvers';
import { makeExecutableSchema } from "graphql-tools";
const { RedisCache } = require('apollo-server-cache-redis');
import responseCachePlugin from 'apollo-server-plugin-response-cache';
import postsApi from './datsource'
export const schema = makeExecutableSchema({
typeDefs,
const refresh = () => {
// refresh
};
class LiranRedis extends RedisCache {
consutrctor() {
super();
this.refresh = refresh;
}
document.querySelectorAll('.match-results-card').forEach((node)=>{
const hrefAttr = node.getAttribute('href');
const window = window.open(hrefAttr);
console.log(window)
})
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<circle style="fill: #32cbd6;" cx="256" cy="267" r="245"/>
<path style="fill:#D9EAFC;" d="M61.914,416.511C106.715,474.582,176.982,512,256,512c47.739,0,92.279-13.668,129.948-37.284V134.345 H61.914V416.511z"/>
<path style="fill:#C3DDF4;" d="M81.756,134.345H61.914v282.166c6.144,7.964,12.783,15.524,19.842,22.668V134.345z"/>
<rect x="61.914" y="35.902" style="fill:#02AF8E;" width="324.03" height="99.44"/>
<rect x="61.914" y="35.902" style="fill:#0F9390;" width="19.842" height="99.44"/>
<path style="fill:#1A2B63;" d="M376.391,0H71.472c-5.257,0-9.558,4.301-9.558,9.558v27.344h324.034V9.558 C385.948,4.301,381.647,0,376.391,0z"/>
<path style="fill:#52BBEF;" d="M347.98,295.832c0,1.965-1.608,3.573-3.572,3.573H201.505c-1.965,0-3.572-1.608-3.572-3.573v-95.744 c0-1.965,1.607-3.573,3.572-3.573h142.903c1.965,0,3.57