Skip to content

Instantly share code, notes, and snippets.

View dsignr's full-sized avatar

Neya dsignr

View GitHub Profile
@dsignr
dsignr / gorilla.go
Created June 3, 2018 07:43
Go language syntax example
package mux
import (
"net/http"
"strings"
)
// MiddlewareFunc is a function which receives an http.Handler and returns another http.Handler.
// Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed
// to it, and then calls the handler passed as parameter to the MiddlewareFunc.
@dsignr
dsignr / example.scala
Created June 3, 2018 07:42
Scala syntax example
/*
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package play.api.cache.caffeine
import java.util.concurrent.TimeUnit
import javax.inject.{ Inject, Provider, Singleton }
import javax.cache.CacheException
@dsignr
dsignr / express.js
Created June 3, 2018 07:36
JS syntax example
/**
* Module dependencies.
*/
var express = require('../../lib/express');
var verbose = process.env.NODE_ENV !== 'test'
var app = module.exports = express();
@dsignr
dsignr / express.js
Created June 3, 2018 07:36
JS syntax example
/**
* Module dependencies.
*/
var express = require('../../lib/express');
var verbose = process.env.NODE_ENV !== 'test'
var app = module.exports = express();
@dsignr
dsignr / wp-comments-post.php
Last active June 2, 2018 13:02
PHP syntax example - Wordpress
<?php
/**
* Handles Comment Post to WordPress and prevents duplicate comment posting.
*
* @package WordPress
*/
if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
$protocol = $_SERVER['SERVER_PROTOCOL'];
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
$protocol = 'HTTP/1.0';
<?php
if ( $_product->is_sold_individually() ) {
$product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $cart_item_key );
} else {
$product_quantity = woocommerce_quantity_input( array(
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $_product->get_max_purchase_quantity(),
'min_value' => '0',
'product_name' => $_product->get_name(),
@dsignr
dsignr / background.js
Created January 26, 2018 17:38 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@dsignr
dsignr / pictures.markdown
Created November 24, 2017 09:23 — forked from sent-hil/pictures.markdown
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature
@dsignr
dsignr / IpnController.ex
Created October 22, 2017 09:34 — forked from dereckmartin/IpnController.ex
Phoenix Framework: PayPal IPN Handshake
defmodule AppName.IpnController do
@moduledoc """
IPN Controller.
"""
use AppName.Web, :controller
def create(conn, params) do
# PayPal requires the params returned in the exact order given.
# The map needs to be a list. encode/1 keep the order of a list,

Taken from: https://github.com/mperham/sidekiq/wiki/Build-vs-Buy

Open Source software is great, why should you pay money for Sidekiq Pro or Enterprise when you can build it yourself?

Pricing

A senior developer is typically $10,000/mo or more. The price of Sidekiq Pro is roughly $80/mo and Sidekiq Enterprise is roughly $160/mo. Is your business building infrastructure or user functionality? How many days or weeks will it take your team to piece together similar functionality? How long will they spend fixing bugs in production? Paying money for good infrastructure means you have more time to focus on user-facing features.

Baremetrics has a Build vs Buy calculator. Here's some extremely optimistic projections, now let the numbers speak for themselves: