Skip to content

Instantly share code, notes, and snippets.

Gulshan Sharma gulshanzealous

Block or report user

Report or block gulshanzealous

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:4a1479aff065ecd05594f3999cd27908
MongoDB is not magically faster. If you store the same data, organised in basically the same fashion, and access it exactly the same way, then you really shouldn't expect your results to be wildly different. After all, MySQL and MongoDB are both GPL, so if Mongo had some magically better IO code in it, then the MySQL team could just incorporate it into their codebase.
People are seeing real world MongoDB performance largely because MongoDB allows you to query in a different manner that is more sensible to your workload.
For example, consider a design that persisted a lot of information about a complicated entity in a normalised fashion. This could easily use dozens of tables in MySQL (or any relational db) to store the data in normal form, with many indexes needed to ensure relational integrity between tables.
Now consider the same design with a document store. If all of those related tables are subordinate to the main table (and they often are), then you might be able to model the data such that the entir
View odd thing about set in JS
const x = new Set()
let p = x.add(4) // x equals Set{ 4 }
p = x.add('nine') // x equals { 4, 'nine' }
p = x.delete(4) // p equals true ---- WTF -----
x.delete(4)
p = x // p equals Set{ 'nine' } --- this is desired ---
View string capitalize
capitalize(str=''){
return str.trim().split('')
.map((char,i) => i === 0 ? char.toUpperCase() : char )
.reduce((final,char)=> final += char, '' )
}
View moment JS time manipulation
// let now = '2017-10-07 16:00:00'
// // let now = Date.now()
// const timed = moment(now).format('dddd, MMMM DD YYYY HH mm ss A')
// const timeStamp = moment(now).valueOf()
// console.log(timed)
// console.log(timeStamp)
View gist:22bc2eae464d4533107bcc5ad0a50ac8
Redux is verbose but gives more freedom and the app is able to maintain the component level state.
Relay on the other hand maps data to components from the GraphQL server and doesn't involve intermediate local data stores
Redux is loosely coupled with React components
Relay acts as a container for components and handles all data interactions to the server with built-in data fetching and caching.
View FirstGist.txt
This gist is a start of the collection of little discovery moments I'll find working on my projects.
You can’t perform that action at this time.