Skip to content

Instantly share code, notes, and snippets.

kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@thecodejack
thecodejack / System Design.md
Created November 18, 2019 17:48 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
var ajaxPromise = function(url, options){
return Ember.RSVP.Promise(function(resolve, reject) {
var options = options || {};
options.success = function(data){
resolve(data);
};
options.error = function(jqXHR, status, error){
@thecodejack
thecodejack / prototype.js
Last active December 23, 2015 10:09
My Experiments with prototype.js
//create a object
var Person = {name:'Adi'};
//create another empty object
var apk = {};
apk.__proto__ === apk.prototype
//returns false
//just FYI prototype is available for functions
@thecodejack
thecodejack / weirdness1.js
Last active December 22, 2015 00:08
Weird Javascript
parseFloat( 'Infinity' ) // returns Infinity
Number( 'Infinity' ) // returns Infinity
parseInt( 'Infinity' ) // returns NaN
//This happens even when we pass any radix.

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@thecodejack
thecodejack / ember.rc6.js
Created June 26, 2013 12:00
ember.rc6.js
// Version: v1.0.0-rc.6
// Last commit: 893bbc4 (2013-06-23 15:14:46 -0400)
(function() {
/*global __fail__*/
/**
Ember Debug
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true