Skip to content

Instantly share code, notes, and snippets.

View mort3za's full-sized avatar
🕸️

Morteza Ziyaeimehr mort3za

🕸️
View GitHub Profile
@mort3za
mort3za / ui-router-sample.js
Created July 27, 2015 14:47
UI-Router sample, With a root template and child views. Note that URL of homepage is `/` and root has no URL.
/* Setup Rounting For All Pages */
SApp.config(['$stateProvider', '$locationProvider', '$httpProvider', '$urlRouterProvider', function($stateProvider, $locationProvider, $httpProvider, $urlRouterProvider) {
$httpProvider.defaults.withCredentials = false;
$locationProvider.html5Mode(true);
// Redirect any unmatched url
$urlRouterProvider.when('', '/');
$urlRouterProvider.otherwise("/");
@mort3za
mort3za / safe-path-generator.js
Last active September 18, 2015 07:57
A safe path generator from a string (item title) that wont break your router, using regex. In Javascript.
var pathGen = function(title){
// replaces all special characters and white spaces with DASH.
var path = title.replace( /([\s`~!@#$%^&*()_|+=?;:'",.<>\{\}\[\]\\\/])/gi, "-");
path = path.replace(/([-]{2,})/gi, '-');
return path;
};
// source: http://stackoverflow.com/a/11090301/
# http://askubuntu.com/questions/78613/how-do-i-enable-the-universe-repository-from-the-command-line
@mort3za
mort3za / Persian keyboard for lubuntu.txt
Last active October 31, 2015 11:47
کیبورد فارسی برای لوبونتو
روی پنل راست کلیک
Add /Remove Panel Items >> ADD>>Keyboard Layout Handler
چک باکس Keep System Layout غیر فعال کنید سمت چپ قسمت Keyboard Layout زبان مورد نظر وارد کنید
[source: http://forum.ubuntu.ir/index.php?topic=90607.0]
another option is:
sudo dpkg-reconfigure keyboard-configuration
// 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;