Skip to content

Instantly share code, notes, and snippets.

View mazhar266's full-sized avatar
💭
I may be slow to respond.

Mazhar Ahmed mazhar266

💭
I may be slow to respond.
View GitHub Profile
@mazhar266
mazhar266 / db.php
Created March 6, 2019 04:33 — forked from seiichi/db.php
getting sqlite to work with fuelphp
// works with FuelPHP 1.4
return array(
'default' => array(
'type' => 'pdo',
'connection' => array(
'dsn' => 'sqlite:/PATH/TO/DATABASE_FILE',
'username' => '',
'password' => '',
),
'charset' => NULL, /* http://stackoverflow.com/questions/263056/how-to-change-character-encoding-of-a-pdo-sqlite-connection-in-php */
@mazhar266
mazhar266 / ScalaTutorial.scala
Created December 3, 2018 19:46
Scala Cheat Sheet
// Install Scala on Mac : Install Java VM, Install Homebrew,
// In terminal type: brew install scala
// Scala is the perfect choice if you want to explore functional
// programming without disregarding OOP
// Scala runs on the JVM which provides a ton of libraries
// File ends with the scala extension
// How to import library functions
@mazhar266
mazhar266 / default.conf
Last active November 24, 2018 12:15
HTTPS, HTTP2 & SPDY on NginX
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl on;
ssl_certificate your-bundle.cert;
ssl_certificate_key your-key.key;
@mazhar266
mazhar266 / fire.py
Created November 6, 2018 12:46
Fire animation in console using Python
import curses, random
screen = curses.initscr()
width = screen.getmaxyx()[1]
height = screen.getmaxyx()[0]
size = width*height
char = [" ", ".", ":", "^", "*", "x", "s", "S", "#", "$"]
b = []
curses.curs_set(0)
curses.start_color()
@mazhar266
mazhar266 / loves.py
Created October 18, 2018 15:30
A Simple Love Calculator in Python
import sys
# take the names from argv
first_name = sys.argv[1]
second_name = sys.argv[2]
sentence = '{} loves {}'.format(first_name, second_name)
# first remove the space and lower the sentence
sentence = sentence.replace(' ', '').lower()
# variable to store numbers
@mazhar266
mazhar266 / airlines.json
Created September 20, 2018 06:42
Airlines
[
{
"name": "9G Rail Ltd",
"iata": "9G"
},
{
"name": "Buryat Airlines",
"iata": "БЮ"
},
{
@mazhar266
mazhar266 / golang.service
Created August 14, 2018 07:07
golang.service
[Unit]
Description= instance to serve jobs api
After=network.target
[Service]
User=root
Group=www-data
ExecStart=/home/path/to/binary/you/uploaded(which in my case is/var/www/go/jobs)
@mazhar266
mazhar266 / filter_dict.py
Last active August 9, 2018 12:41 — forked from 89465127/filter_dict.py
python 2 & 3 filter a dictionary by keys or values
d = {1:11, 2:22, 3:33}
# filter by key
d2 = {k: v for k, v in filter(lambda t: t[0] in [1, 3], d.items())}
# filter by value
d3 = {k: v for k, v in d.items() if v in [2,3]}
@mazhar266
mazhar266 / gunicorn.service
Created August 6, 2018 08:10
Manage Gunicorn with systemd on Ubuntu 16.04 and venv
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/sammy/myproject/myproject.sock myproject.wsgi:application
@mazhar266
mazhar266 / puma.service
Created August 4, 2018 07:46 — forked from arteezy/puma.service
Manage Puma with systemd on Ubuntu 16.04 and rbenv
[Unit]
Description=Puma Rails Server
After=network.target
[Service]
Type=simple
User=deploy
WorkingDirectory=/home/deploy/app/current
ExecStart=/home/deploy/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/app/shared/config/puma.rb
ExecStop=/home/deploy/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/deploy/app/shared/tmp/pids/puma.state stop