Skip to content

Instantly share code, notes, and snippets.

View webgodo's full-sized avatar
🏠
Working from home

Mohsen webgodo

🏠
Working from home
  • Amoozesh.it
View GitHub Profile
@webgodo
webgodo / how-to-reset-admin-password.md
Last active April 23, 2019 08:52
Reset Admin Password via MySql - Drupal 7

Login to the database (MySql) where the Drupal 7 is installed. Then run the following query on your database;

Update users set name='test@example.com', pass='$S$DD7aCRCy6iTddzIbeTPIVdwg4Ea9KgFqpSXZpGjMQtWBA8zzg24t' where uid=1;

Now login Drupal via the user with Username: test@example.com, Password: 123456

@webgodo
webgodo / small-helpers.js
Created February 9, 2019 21:25
Small Useful Helpers For JavaScript (ES6)
// turn a string into a URL friendly serie of characters concatenated via '-'
export const slugify = (str) => str && typeof str === 'string' ? str
.toLowerCase()
// replace persian/arabic digits with numbers
.replace(/([٠١٢٣٤٥٦٧٨٩])|([۰۱۲۳۴۵۶۷۸۹])/g, (m, $1) => m.charCodeAt(0) - ($1 ? 1632 : 1776))
// replace characters other than [a-z] [ا-ی], [0-9], [آ,ئ] with a dash (-)
.replace(/[^آئa-z0-9ا-ی]+/g, '-')
.replace(/^-|-$/g, '')
// limit the string to 100 characters
.slice(0, 100) : ''
@webgodo
webgodo / JS-Lib.md
Last active March 30, 2017 08:00
Useful javascript libraries' methods & events

Library name: Owl Carousel 2

Library URL: Click to open

Usage:

Can be used to access currently initialized carousel and make it stop (if is playing around).

var owl = $('.carousel-element-selector');
owl.trigger('stop.owl.autoplay');
@webgodo
webgodo / broken-image-placeholder.js
Created February 15, 2017 13:28
JS Broken Images Handler - A Simple script to
(function ($) {
// @input `containerSelector` - String: a CSS selector which targets container of `<img>` element(s) you want to be replaced in case of error (mostly 404)
// @input `imagePath` - String: Absolute/Relative path to image file which would be shown (replaced)
window.handleBrokenImage = function (containerSelector, imagePath) {
if (!containerSelector) {
return false;
}
imagePath = imagePath || 'https://placeholdit.imgix.net/~text?txtsize=33&txt=webgodo&w=350&h=150';
@webgodo
webgodo / MySQLSnippets.md
Last active October 23, 2016 13:27
I've saved some of my repetitive & useful snippets of MySQL

MySQL Snippets

Login

mysql --host=localhost --user=USERNAME_HERE --password PASSWORD_HERE

Import .sql file into a database

@webgodo
webgodo / gruntfile.js
Last active June 17, 2016 15:11
a GruntJS file with `watch` and `uglify` for `css` and `js`
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.initConfig({
uglify: {
my_target: {
files: {
'_/js/script.js': ['_/components/js/*.js']