Skip to content

Instantly share code, notes, and snippets.

View sany2k8's full-sized avatar
:octocat:
Focusing

Md. Sany Ahmed sany2k8

:octocat:
Focusing
  • Khulna, Bangladesh
View GitHub Profile
@sany2k8
sany2k8 / 2dto1d.php
Created February 8, 2017 06:49
Convert a 2-D array to 1-D array
<?php
/**
* Created by PhpStorm.
* User: Computer Source
* Date: 12/12/14
* Time: 3:56 PM
*/
$array = array(
array(554 => "a"),
@sany2k8
sany2k8 / vim_imp_cheats.html
Last active March 25, 2017 08:16
Vim important cheat sheet
General
w - jump by start of words (punctuation considered words)
W - jump by words (spaces separate words)
e - jump to end of words (punctuation considered words)
E - jump to end of words (no punctuation)
b - jump backward by words (punctuation considered words)
B - jump backward by words (no punctuation)
0 - (zero) start of line
@sany2k8
sany2k8 / menu.sh
Created February 9, 2017 05:43
Menu in Bash
#!/bin/bash
# A menu driven shell script sample template
## ----------------------------------
# Step #1: Define variables
# ----------------------------------
EDITOR=vim
PASSWD=/etc/passwd
RED='\033[0;41;30m'
STD='\033[0;0;39m'
@sany2k8
sany2k8 / array_filter.php
Created February 14, 2017 05:05
array filtering between two different json object
<?php
$array1 = json_decode(file_get_contents('country_list.json'),1);
$array2 = json_decode(file_get_contents('country_list_en.json'),1);
$arrayDiff = array_filter($array2, function ($element) use ($array1) {
return !in_array($element, $array1);
});
@sany2k8
sany2k8 / postgres cheatsheet.md
Last active March 8, 2017 07:43 — forked from apolloclark/postgres cheatsheet.md
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

CREATE SEQUENCE tbl_name_id_seq;
ALTER TABLE tbl_name ALTER COLUMN id SET DEFAULT nextval('tbl_name_id_seq');
select setval('tbl_name_id_seq', (select max(id)+1 from tbl_name), false);
@sany2k8
sany2k8 / postgresql_weird_issue
Created March 14, 2017 16:53
Postgresql is the server running locally and accepting connection on Unix domain
sudo apt-get --purge remove postgresql-*
sudo rm -Rf /etc/postgresql /var/lib/postgresql
sudo apt-get install postgresql
@sany2k8
sany2k8 / php5.6-pgsql.Dockerfile
Created March 14, 2017 18:12 — forked from ben-albon/php5.6-pgsql.Dockerfile
Docker PHP Image with PostgreSQL Driver
FROM php:5.6-apache
RUN apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pdo_pgsql
COPY src/ /var/www/html
@sany2k8
sany2k8 / regex.md
Last active August 1, 2017 22:07 — forked from vitorbritto/regex.md
Regex Cheat Sheet

Regular Expressions

Basic Syntax

  • /.../: Start and end regex delimiters
  • |: Alternation
  • (): Grouping