Skip to content

Instantly share code, notes, and snippets.

View MahdiMajidzadeh's full-sized avatar
:bowtie:
not coding

Mahdi Majidzadeh MahdiMajidzadeh

:bowtie:
not coding
View GitHub Profile
@MahdiMajidzadeh
MahdiMajidzadeh / confog.php
Created February 29, 2016 10:41
Best Codeigniter session setting
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = BASEPATH . 'cache/session/';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 0;
$config['sess_regenerate_destroy'] = FALSE;
@MahdiMajidzadeh
MahdiMajidzadeh / JSON.php
Last active May 5, 2021 11:09
Fix JSON Persian character in php
// in php >= 5.4
echo json_encode($myarr,JSON_UNESCAPED_UNICODE);
// in php <= 5.3
header('Content-Type: application/json; charset=utf-8');
function jsonRemoveUnicodeSequences($array) {
return preg_replace("/\\\\\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode($array));
}
@MahdiMajidzadeh
MahdiMajidzadeh / config.php
Last active September 7, 2016 18:16
Custom base controller in CI3
// put this code in first of config.php file in application/config
function __autoload($classname) {
if (strpos($classname, 'CI_') !== 0) {
$file = APPPATH . 'core/' . $classname . '.php';
@include_once($file);
}
}
@MahdiMajidzadeh
MahdiMajidzadeh / pagination.php
Created December 22, 2016 12:14
Codeigniter-Bootstrap-pagination
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$config['num_links'] = 2;
$config['use_page_numbers'] = TRUE;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
@MahdiMajidzadeh
MahdiMajidzadeh / Cors.php
Created February 21, 2017 09:06
fix Access-Control-Allow-Origin in laravel
public function handle($request, Closure $next)
{
$domains = ['http://localhost:8080'];
if(isset($request->server()['HTTP_ORIGIN'])){
$origin = $request->server()['HTTP_ORIGIN'];
if(in_array($origin, $domains)){
header('Access-Control-Allow-Origin: '. $origin);
header('Access-Control-Allow-Headers: Origin, Content-type, Authorization');
}
@MahdiMajidzadeh
MahdiMajidzadeh / file.yml
Created February 21, 2020 10:17
some github action
name: MkDocs Build
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
@MahdiMajidzadeh
MahdiMajidzadeh / helpers.php
Last active August 6, 2022 20:35
remove query params from url
<?php
function clean_url($url, $params)
{
$pieces = parse_url($url);
if (!$pieces['query']) {
return $url;
}
$query = [];
@MahdiMajidzadeh
MahdiMajidzadeh / urls.txt
Created April 30, 2023 11:30
urls of substack
https://www.lennysnewsletter.com/p/what-jury-duty-taught-me-about-product
https://huryn.substack.com/p/are-you-tracking-the-right-metrics
https://huryn.substack.com/p/3-ways-to-create-10x-better-product
https://huryn.substack.com/p/business-outcomes-vs-product-outcomes
https://huryn.substack.com/p/what-exactly-is-product-discovery
https://huryn.substack.com/p/how-to-become-a-technology-literate
https://huryn.substack.com/p/5-knowledge-areas-you-have-to-master
https://huryn.substack.com/p/i-spent-over-16000-hours-working
https://huryn.substack.com/p/pm-is-not-the-ceo-of-the-product
https://huryn.substack.com/p/time-to-value-how-do-product-led