Skip to content

Instantly share code, notes, and snippets.

View amiyasahu's full-sized avatar
🎯
Focusing

Amiya Sahu amiyasahu

🎯
Focusing
View GitHub Profile
@amiyasahu
amiyasahu / clean_code.md
Created August 16, 2019 03:29 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@amiyasahu
amiyasahu / Trie.js
Created February 17, 2019 01:55 — forked from tpae/Trie.js
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
function TrieNode(key) {
// the "key" value will be the character in sequence
this.key = key;
@amiyasahu
amiyasahu / Install WordPress Blog.md
Last active August 24, 2018 04:24 — forked from janikvonrotz/Install WordPress Blog.md
Step by Step: Install WordPress Blog#PHP#MySQL#Nginx#phpMyAdmin#WordPress#Markdown#Ubuntu

Updating this guide.... not finished

Finishing this guide you'll get:

  • A running WordPress installation
  • Nginx proxy with PHP and Fast CGI
  • MySQL server accessible with phpMyAdmin

Specification of latest running installation:

@amiyasahu
amiyasahu / async-await.js
Created July 2, 2018 14:35 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@amiyasahu
amiyasahu / GetterSetterVerifier.java
Created June 7, 2018 20:17 — forked from mjpitz/GetterSetterVerifier.java
A class that uses reflection to automate the testing of getters and setters.
import com.google.common.base.Defaults;
import com.google.common.collect.Sets;
import javax.annotation.Nonnull;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Set;
@amiyasahu
amiyasahu / sed cheatsheet
Created May 18, 2018 15:04 — forked from ssstonebraker/sed cheatsheet
Sed Cheatsheet
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@amiyasahu
amiyasahu / gist:c6129eeac6667a3e12adf99171315181
Created January 18, 2017 15:08 — forked from folkengine/gist:3781429
Spring EL Placeholder to get Host Name
<!-- Used in the Jasig/Cas uniqueIdGenerators.xml file -->
<!-- http://static.springsource.org/spring/docs/3.1.1.RELEASE/spring-framework-reference/html/expressions.html -->
<bean id="ticketGrantingTicketUniqueIdGenerator" class="org.jasig.cas.util.DefaultUniqueTicketIdGenerator">
<constructor-arg
index="0"
type="int"
value="50" />
<constructor-arg
index="1" value="#{ T(java.net.InetAddress).getLocalHost().getHostName() }" />
</bean>
@amiyasahu
amiyasahu / set-value.md
Created December 18, 2016 11:04 — forked from JeffreyWay/set-value.md
PHP: Set value if not exist

You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:

name = name || 'joe';

This is quite common and very helpful. Another option is to do:

name || (name = 'joe');
@amiyasahu
amiyasahu / gist:d78bd2c508018a32a1c675525c88fb62
Created October 4, 2016 20:25 — forked from dziobas/gist:5848891
Sample maven settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at