Skip to content

Instantly share code, notes, and snippets.

@Ashkanph
Ashkanph / image-not-found.js
Last active April 19, 2017 13:42
Javascript and HTML code to handle the situations when the image can not be found
/*
* How to use it in html:
* <img src='http://www.example.com/images/hi.jpg' onerror='imageNotFound(this);'>
*/
function imageNotFound(image) {
image.onerror = "";
image.src = "../images/no-image.png";
return true;
}
@Ashkanph
Ashkanph / pretty-print-json.js
Last active April 19, 2017 13:40
Pretty-print of an object or json in console.log
console.log(JSON.stringify(obj, null, 2));
@Ashkanph
Ashkanph / fieldset-legend.scss
Created April 19, 2017 13:34
Classes of Legend and fieldset for css
/*
* Use it in pug
*
* .fieldset
* h1.legend(translate="html") sync-title
*
*/
.fieldset{
// height: 100px;
@Ashkanph
Ashkanph / combined-icons.scss
Created April 19, 2017 13:38
Combining two font awesome icons
/*
* Use it in pug:
*
* span.fa-stack.combined-icons
* i.fa.fa-map.fa-stack-2x.awesomeEntity
* i.fa.fa-heartbeat.fa-stack-1x.awesomeAction
*/
.combined-icons{
display: block;
@Ashkanph
Ashkanph / current-datetime.js
Created April 19, 2017 13:54
Get the current datetime with javascript
/*
* Add this for jalali calendar:
* <script src="http://rawgithub.com/babakhani/PersianDate/master/dist/0.1.8/persian-date-0.1.8.min.js">
*
*/
var dateSeperatorCharacter = '-';
function currentDateTime(){
var cdt = {};
# Aliases added by Ashkan -------------------------------
#
# Must install jcal
alias acal="echo '';echo '';jcal -3 -e; cal -3;echo '';echo '';date '+%A %Y/%B/%d %H:%M:%S%n';jdate '+%A %Y/%B/%d %H:%M:%S%n';"
# End of aliases added by Ashkan ------------------------
@Ashkanph
Ashkanph / replaceAt.js
Created April 30, 2017 07:51
A prototype javascript function to change (replace) a character in a string
String.prototype.replaceAt=function(index, character) {
return this.substr(0, index) + character + this.substr(index+character.length);
};
@Ashkanph
Ashkanph / About Linux.sh
Last active May 6, 2017 13:37
Useful tips about Linux Ubuntu برخی از نکات کوچک و مفید برای لینوکس اوبونتو
# در ترمینال -------------------------------
# Ctrl + a یا Home رفتن به اول سطر
# Ctrl + k پاک کردن از جای فعلی تا آخر سطر
# Ctrl + u پاک کردن از جای فعلی تا اول سطر
# Ctrl+a Ctrl+k پاک کردن تمام سطر
# Ctrl + e یا End رفتن به آخر سطر
# Ctrl + Alt + Delete رستارت سیستم
# Ctrl + l پاک کردن کل ترمینال به غیر از خطی که در آن هستیم
@Ashkanph
Ashkanph / css-problems.css
Created May 13, 2017 07:18
Solution of common css problems
/* ---- when bootstrap modal pushes body to the left ------- */
body {
margin: 0 !important;
padding: 0 !important;
}
/* unset bs3 setting */
.modal-open {
@Ashkanph
Ashkanph / pulse.css
Last active September 26, 2018 09:19
Pulse effect css style for html elements. just add the class to your element.
.pulse {
// margin:100px;
display: block;
width: 2px;
height: 2px;
border-radius: 50%;
background: transparent;
cursor: pointer;