Skip to content

Instantly share code, notes, and snippets.

View BumbuKhan's full-sized avatar

Gurban Gurbanov BumbuKhan

  • @Develolper
  • Azerbaijan, Baku
View GitHub Profile
@BumbuKhan
BumbuKhan / Yii2
Created January 21, 2017 12:02
Problem with file uploading: finfo_file(C:\...): failed to open stream: No such file or directory
Do
$model->save();
before
$model->file->saveAs()
@BumbuKhan
BumbuKhan / Yii2
Created January 31, 2018 09:29
Yii2 turn off asset caching
'assetManager' => [
'class' => 'yii\web\AssetManager',
'forceCopy' => YII_DEBUG,
'appendTimestamp' => YII_DEBUG,
]
@BumbuKhan
BumbuKhan / linux-bash
Created November 29, 2017 08:48
How to create tar.gz archive in linux command line
tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
Here’s what those switches actually mean:
-c: Create an archive.
-z: Compress the archive with gzip.
-v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
-f: Allows you to specify the filename of the archive.
@BumbuKhan
BumbuKhan / .htaccess
Created November 17, 2017 12:23
.htaccess - redirect HTTP to HTTPS
# BEGIN Force SSL
# This should be the first rule before other rules
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
# END Force SSL
@BumbuKhan
BumbuKhan / distance_between.sql
Created September 19, 2017 13:28 — forked from esaounkine/distance_between.sql
Calculate distance between two points with MySQL
CREATE FUNCTION distance_between (from_lat DECIMAL(6, 3), from_lng DECIMAL(6, 3), to_lat DECIMAL(6, 3), to_lng DECIMAL(6, 3)) RETURNS DECIMAL(11, 3)
RETURN 6371 * 2 * ATAN2(SQRT(POW(SIN(RADIANS(to_lat - from_lat)/2), 2) + POW(SIN(RADIANS(to_lng - from_lng)/2), 2) * COS(RADIANS(from_lat)) * COS(RADIANS(to_lat))), SQRT(1 - POW(SIN(RADIANS(to_lat - from_lat)/2), 2) + POW(SIN(RADIANS(to_lng - from_lng)/2), 2) * COS(RADIANS(from_lat)) * COS(RADIANS(to_lat))));
@BumbuKhan
BumbuKhan / flash-app.js
Created August 8, 2017 13:16 — forked from brianmacarthur/flash-app.js
Flash messaging in Express 4: express-flash vs. custom middleware in ejs, handlebars, or jade
var express = require('express');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var flash = require('express-flash');
var handlebars = require('express-handlebars')
var app = express();
var sessionStore = new session.MemoryStore;
// View Engines
@BumbuKhan
BumbuKhan / ExpressJS
Created July 26, 2017 14:30
ExpressJS file upload
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads/')
},
filename: function (req, file, cb) {
crypto.pseudoRandomBytes(16, function (err, raw) {
cb(null, raw.toString('hex') + Date.now() + '.' + mime.extension(file.mimetype));
});
}
});
@BumbuKhan
BumbuKhan / Cordova
Created July 9, 2017 08:15
config.xml keyboard issue solved
<?xml version="1.0" encoding="UTF-8"?>
<!-- config.xml reference: https://build.phonegap.com/docs/config-xml -->
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.phonegap.helloworld"
version = "2.5.0">
<name>UNDP</name>
@BumbuKhan
BumbuKhan / Cordova
Created June 27, 2017 15:08
Angular-cordova routing cure
<script>
var baseHref = window.location.href.split('/');
baseHref.pop();
document.write('<base href="' + baseHref.join('/') + '/" />');
</script>
@BumbuKhan
BumbuKhan / PosgreSQL
Created April 21, 2017 07:42
How to create extension for table
CREATE EXTENSION citext; -- to create
ALTER TABLE <table name>
ALTER COLUMN <column_name> TYPE citext; -- to apply