Skip to content

Instantly share code, notes, and snippets.

View Amitesh's full-sized avatar

Amitesh Kumar Amitesh

View GitHub Profile
@Amitesh
Amitesh / gist:1128275
Created August 5, 2011 19:14
Undefined entity   while XML parsing error in firefox
XML parsing does not support   entity.   is XHTML entity. If we parse the html or xml or html as xml then you get "Undefined entity" error in firefox error console. To make it working use unicode of   (non-breakibg space character)   or simply put space (" " or  ).
for example :
<div> &nbsp; hello I am going to break. If you are going to use xml parser :( </div>
Corrected as :
<div> &#160; hello I am going to break. If you are going to use xml parser :( </div>
@Amitesh
Amitesh / word-wrap
Created November 26, 2011 20:24
Word wrap in Ruby
# we can change the <wbr> and <br> as per our requirement.
def wrap_long_string(text, max_width = 20)
if text.blank?
return text
end
sp = text.split(/\n/)
sp.collect!{|s|
s = (s.length < max_width) ? s : s.scan(/.{1,#{max_width}}/).join("<wbr>")
}
@Amitesh
Amitesh / sublime-text3-plugin-list
Last active May 2, 2017 11:38
My Choice of Sublime text 3 plugin list
Alignment
Terminal
DocBlocker
Emmet
trimmer
csscomb
Color Highlighter
jsFormat
plainTask
AllAutocomplete
We are following some standard to make our code same on all machine irrespective of different developers working on different machine, editors and with their different opinion for coding (smile).
Help us to make it clean and uniform code base throughout the project.
JS Standards
Variable and Function naming
All name should be CamelCase (start with small case) like `userPassword`
Boolean flag should be start with `is`, `has` etc. It will give notion that it will be true/false or yes/no.
For count or number variable good to use `no`, `count`
Use getter and setters if you are setting some value or getting some value
For a web project we can setup following environment to build our app.
a) Development/Demo - This environment/stage will be get deployed on every changes pushed on `develop` branch. (Automated Build+deploy)
b) Release/QA - This environment will be get deployed once we create a release branch in the repository. (Manually build + deploy from TC `run` button)
c) Live - This environment will be deployed mannually from TeamCity by choosing the corrrect release branch to deploy on Live server. (Mannually)
For setting up the `development` and `release` environemnt on TC is simillar except the pointing the branch name.
We have followed few convension to give name to the applications on while setting up and it is pointed with the respective step.
TC Setup
Here is a small template to fill while reporting the bug. There is possibility few fields are already present with JIRA tickets like `attachements`. Its good to fill or use those fields.
URL
https://myawesomeapp.com?id=545924
UserAgent
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
Steps to reproduce the problem
Open the website and web page on xyz browser
Click on `save` button
For more info about SCSS-Lint, please check this out -
About SCSS-Lint
SCSS-Lint default settings
# Default application configuration that all configurations inherit from.
linters:
BorderZero:
enabled: true
convention: none
{
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"forin": false,
"freeze": false,
"immed": true,
"indent": 2,
@Amitesh
Amitesh / sort-object-array.js
Created December 5, 2016 18:43
Sort Array of objects
/**
* Sort an array of object.
*/
var sample = [
{ name: 'Ram', age: 21 },
{ name: 'Shyam', age: 37 },
{ name: 'Gyan', age: 45 }
];
sample.sort(function(a,b) {
@Amitesh
Amitesh / flatten.js
Created December 5, 2016 17:38
Flatten the deep nested array
/**
* Function to flatten the deep array
*/
var sampleArray = [[1, 2],[3, 4, 5], [6, 7, 8, 9]];
// Solution for single level nested array
[].concat.apply([], sampleArray);
// If we want deep flatten then we can use recursive function strategy