Skip to content

Instantly share code, notes, and snippets.

View mort3za's full-sized avatar
🕸️

Morteza Ziyaeimehr mort3za

🕸️
View GitHub Profile
// fix for showing images in dabr.co.uk
var linkembeds = $('.embed a');
for(var i = 0; i < linkembeds.length; i++){
var link = $(linkembeds[i]);
var linkToImage = link.attr('href').replace('large', 'small');
var imgInLink = link.find('img');
imgInLink.attr('src', linkToImage);
}
@mort3za
mort3za / ui-router-optional-parameters.js
Last active December 8, 2015 08:47
Optional parameters in Angular UI Router
// needs ui router 0.2.12+
// ...
var Product: {
url: '^/p/:productId/{productAlias}',
params: {
productAlias: {value: null, squash: true}
}
}
.state('product', Product);
// ...
@mort3za
mort3za / closure.js
Created March 23, 2016 20:55
Closure in JavaScript
const makeNumbers = () => {
let n = 0
return {next: () => {
n += 1
return n
}
}
numbers = makeNumbers()
numbers.next() // 1
numbers.next() // 2
@mort3za
mort3za / map-with-multiple-markers.html
Created April 12, 2016 10:51
Google map with multiple markers
<html>
<head>
<title>Google Maps Multiple Markers</title>
<meta charset="utf-8">
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
@mort3za
mort3za / enable-php-errors.php
Created April 14, 2016 12:28
Enable php errors
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
@mort3za
mort3za / form-with-file-in-angularjs.js
Created May 1, 2016 15:16
Send file along with other fields in Angularjs
// inside directive
function linkFunc(scope, element, attrs, ctrl) {
element.on('change', '.file-logo', function(event) {
ctrl.onFileSelect(event.target.files);
});
}
function Controller() {
var vm = this;
# Set permission of all files and folders. 755 and 644.
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
find ./app/cache -type d -exec chmod 777 {} \;
find ./app/logs -type d -exec chmod 777 {} \;
find ./web/upload -type d -exec chmod 777 {} \;
#find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
#find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
@mort3za
mort3za / git-command-n-tips.sh
Last active April 22, 2019 06:46
Some git commands and tips
# Add a ssh key to list of ssh keys of git
# first ensure that ~/.ssh/ folder is writable by current user. (if you are logged in as root can't solves this, change user by `su anotheruser` and then `chown anotheruser:anotheruser /home/anotheruser/.ssh/`)
# add a new key to .ssh/ folder of current user home.
ssh-keygen
# enter full address. `/home/anotheruser/.ssh/your_ssh_key_name`
# enter a passphrase
# if you used id_rsa as the name of key no need this step.
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/path/to/project/folder
ServerName mynewhost.com
ServerAlias *.mynewhost.com
</VirtualHost>
# Also add: 127.0.0.1 mynewhost.com to hosts file.
@mort3za
mort3za / under-construction-template.html
Last active April 14, 2019 05:11
Site under construction, Very simple [persian] template
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>در حال بروزرسانی</title>
<meta name="viewport" content="width=device-width">
<style>
body {
text-align: center;