Skip to content

Instantly share code, notes, and snippets.

View dharma017's full-sized avatar

Dharma R. Thapa dharma017

  • Melbourne, Australia
View GitHub Profile
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /usr/local/etc/nginx/ssl/{{host}}.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/{{host}}.key;
ssl_ciphers HIGH:!aNULL:!MD5;
# listen 80;
server_name {{host}};
@dharma017
dharma017 / ovveride-path-of-php-with-mamp-path.md
Created June 16, 2017 08:50
Use MAMP php instead of native MAC php

Bash Shell

Use MAMP version of PHP

PHP_VERSION=ls /Applications/MAMP/bin/php/ | sort -n | tail -1 export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH

Fish Shell

set PHP_VERSION (ls /Applications/MAMP/bin/php/ | sort -n | tail -1) set -x PATH /Applications/MAMP/bin/php/$PHP_VERSION/bin $PATH set -x PATH /Applications/MAMP/Library/bin/ $PATH

@dharma017
dharma017 / copy-csv-file-to-postgres-table.md
Created June 13, 2017 05:08
Copy from CSV file to PostgreSQL table with headers in CSV file.

Copy from CSV file to PostgreSQL table with headers in CSV file.

COPY wheat FROM 'wheat_crop_data.csv' DELIMITER ';' CSV HEADER

The only way to express relative path with client permissions is using STDIN,

When STDIN or STDOUT is specified, data is transmitted via the connection between the client and the server.

Feed the file via STDIN

@dharma017
dharma017 / save-all-images.sh
Created January 20, 2017 05:16 — forked from lalyos/save-all-images.sh
script to save all docker image, and load them back
reload() {
source ${BASH_SOURCE[0]}
}
alias r=reload
get-image-field() {
local imageId=$1
local field=$2
: ${imageId:? reuired}
hub:
image: selenium/hub
ports:
- "4444:4444"
container_name: hub
node:
image: selenium/node-firefox
links:
- hub
environment:
@dharma017
dharma017 / README-Template.md
Created January 5, 2017 06:19 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@dharma017
dharma017 / sync-prod.sh
Created December 30, 2016 04:42 — forked from retlehs/sync-prod.sh
WP-CLI aliases sync example
read -r -p "Would you really like to reset your development database and pull the latest from production? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
wp @development db reset --yes
wp @production db export - > sql-dump-production.sql
wp @development db import sql-dump-production.sql
wp @development search-replace https://example.com https://example.dev
else
exit 0
fi
@dharma017
dharma017 / menu.twig
Created December 12, 2016 07:06 — forked from peksi/menu.twig
Bootstrap dropdown navbar implementation for Wordpress Timber plugin.
{# Bootstrap dropdown navbar for Wordpress #}
<ul class="nav navbar-nav">
{% for item in menu %}
{% if (item.get_children) %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{item.title}} <span class="caret"></span></a>
<ul class="dropdown-menu">
{% for subitem in item.get_children %}
@dharma017
dharma017 / vhost.py
Created November 4, 2016 09:08 — forked from fideloper/vhost.py
Create vHost Ubuntu Lamp-Server (bash and python)
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
from os import system
import getopt
#
@dharma017
dharma017 / admin-filter-by-custom-fields-example.php
Last active October 22, 2016 06:36
Wordpress Admin Filter BY Custom Fields
<?php
/*
Plugin Name: Room Filter BY Resort Custom Fields
Plugin URI: http://en.bainternet.info
Description: answer to http://wordpress.stackexchange.com/q/45436/2487
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info
*/