Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am spicydonuts on github.
  • I am spicydonuts (https://keybase.io/spicydonuts) on keybase.
  • I have a public key whose fingerprint is 3EE8 3AA8 260B 3635 DEE0 7AD4 A8F1 123A 51F0 0A9B

To claim this, I am signing this object:

@megamaddu
megamaddu / git-tutorial.md
Last active March 14, 2018 13:33
Git Tutorial

And now an intro to Git!

It's completely possible to use git without knowing these things (especially with some of the guis), but a glimpse into the internals will actually make it a lot easier to use and remember why things are the way they are, even if it looks confusing at first. It's actually not that bad!

In TFS there is one server. When you check out the code, you copy the latest version of each file's contents down to your working directory. The change log is linear, meaning you can view history and see commits 1 through 48561 all in a row. When you want to check in changes you need to contact that server. If you want to see an old version of the file you have to contact that server. If you want a "branch" you have to copy all the code to a new folder and maintain the changes between the two. A TFS server is a web service where all "intelligent" operations are carried out by that single server. If you can't get online or the server is down, you're out of luck.

Git is a

@megamaddu
megamaddu / .eslintrc
Last active September 15, 2015 13:52
gulp + browserify + iojs + es6 + isomorphic
---
parser: babel-eslint
env:
node: true
browser: true
globals:
fetch: true
noop: true
React: true
rules:

================

If your language works like this by default..

var x = {a: 5};
var y = {a: 5};
x === y; // => false
@megamaddu
megamaddu / rAF.js
Last active August 29, 2015 14:20 — forked from paulirish/rAF.js
rAF.js for node+browserify+babel
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
if (process.browser) {
let window = global.window;
let lastTime = 0;
@megamaddu
megamaddu / vim.md
Last active August 29, 2015 14:26
import 'isomorphic-fetch';
const getOkAndJsonBody = res => {
return res.text().then(text => {
try {
return {ok:res.ok,body: text && JSON.parse(text) || {}};
} catch (err) {
return {ok:res.ok,body:{}};
}
});

Nodejs!

What's node?

Node is a program (usually run from the command line) which executes JavaScript, and comes with a built-in library for writing network and filesystem code. Node is built on V8, the same JavaScript VM used in the Chrome browser. Instead of being wrapped with a GUI and web browser features like the DOM, node wraps V8 to expose lower-level operating system APIs. Some modules that come with node include: http, fs (filesystem), crypto (cryptography), and lots more.

What's a module?

Modules are chunks of code you can 'require' and then use. Today we'll use the http module, like so:

var http = require('http')
@megamaddu
megamaddu / input.js
Created November 10, 2015 18:02
PureScript + uglifyjs issues
// Generated by psc-bundle 0.7.5.3
var PS = { };
(function(exports) {
/* global exports */
"use strict";
// module Prelude
//- Functor --------------------------------------------------------------------
What is it?
  • Compiles to JavaScript
  • Haskell-inspired type system (with some improvements!)
  • No runtime (unlike Elm, GHCJS, etc)
  • A focus on readable and debuggable JavaScript