Skip to content

Instantly share code, notes, and snippets.

View mort3za's full-sized avatar
🕸️

Morteza Ziyaeimehr mort3za

🕸️
View GitHub Profile
@mort3za
mort3za / cdn-jquery-angular-with-fallback
Last active April 10, 2018 02:23
Loading jQuery and AngularJS from CDN with local fallback
<script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'></script>
<script src='//ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js' type='text/javascript'></script>
<script type="text/javascript">
// Fallbacks
window.jQuery || document.write(unescape("%3Cscript src='js/vendor/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
window.angular || document.write(unescape("%3Cscript src='js/vendor/angular.min.js' type='text/javascript'%3E%3C/script%3E"));
</script>
@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/
@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
# http://askubuntu.com/questions/78613/how-do-i-enable-the-universe-repository-from-the-command-line
@mort3za
mort3za / add-a-folder-to-system-path-in-ubuntu.txt
Last active May 21, 2016 08:26
Add folder to path in ubuntu. #linux
run this command:
sudo gedit ~/.bashrc
then add this line to the end of file:
export PATH=$PATH:/the/folder/of/your/app/bin
save file and exit gedit.
run this command:
source .bashrc
and re-open a new terminal to test your app
# just install git for windows.
ssh -v to see if ssh client is installed.
ssh-keygen
# it will generate two files (id_rsa => private key, id_rsa.pub => public key).
# add contents of id_rsa.pub to bitbucket->account->ssh-keys
# create a project in bitbucket.org
# run commands of overview page (git init, ...)
# done.
@mort3za
mort3za / install-font-in-ubuntu.txt
Last active May 21, 2016 08:28
install new fonts ubuntu. #linux
sudo cp ~/Desktop/my-new-fonts /usr/share/fonts/truetype/ -r
fc-cache -f -v
@mort3za
mort3za / install-nodejs-bower-gulp.bash
Last active September 6, 2016 07:09
Installing bower, gulp, npm, nodejs on ubuntu. #linux
# First install 'nodejs' (not node, and don't use apt install nodejs, because it's not latest version).
# https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# and then npm (if it's not installed automatically):
# https://rtcamp.com/tutorials/nodejs/node-js-npm-install-ubuntu/
# Then install bower and gulp with simple npm install command (with -g flag).
# For accessing bower in global space (or adding it to path) create a symbolic link:
@mort3za
mort3za / var_dump-better-view-snippet-for-atom.cson
Last active August 14, 2017 14:23
Better view/style for var_dump in php [Snippet for Atom editor]
# snippet for Atom editor:
'.source.php':
'Styled var_dump':
'prefix': 'vardumper'
'body': 'echo "<pre style=\'word-spacing:15px; line-height:1.5; font-size:18px;\'>";var_dump($1);echo"</pre>";'
# output is this:
# echo "<pre style='word-spacing:15px; line-height:1.5; font-size:18px;'>";var_dump($request);echo"</pre>";