Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@deepak
deepak / fetch-wrapper.js
Last active August 9, 2016 09:40
Wrapping fetch to handle errors
var api_fetch = {
checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return Promise.resolve(response);
} else {
return Promise.reject(response);
}
},
parseJson(response) {
@deepak
deepak / notes.txt
Last active August 8, 2016 12:57
when you do not need a router
when you do not need a router
then we can escape by mounting and unmounting components manually
also can we hook `history.js` into mount and unmount to get a stupid router ?
@deepak
deepak / image-slider.jsx
Last active August 5, 2016 11:32
exploring react
var App = React.createClass({
getInitialState: function() {
return {
red: 0,
green: 0,
blue: 0
};
},
update: function() {
@deepak
deepak / babel-output.js
Created August 3, 2016 08:55
es6 spread
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var state = {
loggedIn: false
};
var newState = _extends({}, state, {
loggedIn: "test"
@deepak
deepak / start-node.sh
Last active July 8, 2016 02:39
how i start with node
## Install [node](http://nodejs.org) via [homebrew](http://brew.sh) and update [npm](https://www.npmjs.com)
# install node version with LTS (Long Term Support)
brew install node4-lts
# update npm
npm install npm -g
# check versions
node -v
@deepak
deepak / benchmark.ruby-set-and-array-unique-insert.rb
Last active June 30, 2016 06:10
ruby unique inserts using Set and Array
require 'benchmark'
require 'set'
NUMBERS = 5000.times.collect { rand(10) }
Benchmark.bmbm do |x|
x.report("set") do
set = Set.new
NUMBERS.each do |number|
set.add number
@deepak
deepak / rails-aws-app-setup-and-install.sh.txt
Last active June 3, 2016 04:40
App setup for a rails app on AWS (separate database server)
# provisioning a rails stack with
# - ngixn web server and reverse proxy
# - puma app server
# - redis
# - elasticsearch
# - Amazon RDS using etc for the SQL database
# installed on an AWS EC2 instance running Ubuntu 14.04 LTS
# fix locale.
# needed to remove login warning
@deepak
deepak / docs confused why we need `extern crate` and use both.txt
Last active May 8, 2016 09:18
extern and use in rust guessing-game doc
as a rust noob and coming from ruby
was confused why we need `extern crate` and `use` both ?
the `guessing-game` chapter has these two paragraphs:
```
The first thing we’ve done is change the first line. It now says
`extern crate rand`. Because we declared `rand` in our `[dependencies]`, we
can use `extern crate` to let Rust know we’ll be making use of it. This also
does the equivalent of a `use rand;` as well, so we can make use of anything
@deepak
deepak / debug-rails-app-written-by-other.txt
Last active April 22, 2016 13:05
useful things while debugging a rails app you have not written yourself
1. view paths ?
2. where are the layout and view file located ?
3. is the database.yml valid ?
sanity check: eyeball if it is running locally.
4. any "very" old libs and/or known security vulnerabilities ?
for (1) can delete a partial and see the stacktrace
something like
@deepak
deepak / Cargo.lock
Last active April 13, 2016 12:26
error in using rust's rand crate
[root]
name = "hello_world"
version = "0.0.1"
dependencies = [
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.10"