Skip to content

Instantly share code, notes, and snippets.

View akash-coded's full-sized avatar
🎯
Focusing

Akash Das akash-coded

🎯
Focusing
View GitHub Profile
@akash-coded
akash-coded / __call
Last active January 23, 2020 18:18
Some Python Magic Methods
class Animal {
}
class Penguin extends Animal {
public function __construct($id) {
$this->getPenguinFromDb($id);
}
public function getPenguinFromDb($id) {
// elegant and robust database code goes here
@akash-coded
akash-coded / phpMyAdmin_Warning.md
Created January 23, 2020 18:12
Fix Bug Phpmyadmin [sql.lib.php] + Php7.2 + - Warnings

Warning in ./libraries/sql.lib.php#601 (phpMyAdmin)

count(): Parameter must be an array or an object that implements Countable

1_VXjj4lPqxoNqHqt7UOIn6A

It is because of phpmyadmin’s library try to counting some parameter but got wrong a code. So by looking at line 613, we find:

1_TCanXuY2VCA2lVoSVJlacQ

@akash-coded
akash-coded / States and UTs in India
Created January 26, 2020 16:21
This is an array containing names of all 28 states and 8 union territories in India. You can directly use it in your code, with minor modifications as per your programming language of choice.
$states = [
'Andaman and Nicobar Islands',
'Andhra Pradesh',
'Arunachal Pradesh',
'Assam',
'Bihar',
'Chandigarh',
'Chhattisgarh',
'Dadra and Nagar Haveli and Daman and Diu',
'Goa',
@akash-coded
akash-coded / php-function-overloading.php
Last active January 30, 2020 13:13
PHP function overloading with __call()
<?php
class OverloadingTest
{
public function __call($method, $params)
{
if($method === "select")
{
$this->testing1($params[0]);
} elseif($method === "insert") {
@akash-coded
akash-coded / php-varargs.php
Last active January 30, 2020 13:13
How to use varargs in PHP with token(...) symbol and func_get_args()
<?php
class Test
{
public function testing(...$args)
{
$x = func_num_args();
print_r($x);
echo "</br>";
print_r($args);
@akash-coded
akash-coded / php-multidimensional-associative-array.php
Last active January 30, 2020 13:17
Manipulating multidimensional associative arrays in PHP and using composite $_FILES[] along with foreach
<?php
$letters = ['a','b','c'];
$words = [];
$words['name'] = 'Akash';
$words['skills'] = array();
$words['vocab'] = 10;
$words['temp'] = array();
foreach($letters as $letter) {
$words['skills'][] = htmlentities($letter);
--To create a database with proper character set and collation
CREATE DATABASE IF NOT EXISTS profile_maker CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
--To see the default character set and collation for a given database, use these statements:
USE db_name;
SELECT @@character_set_database, @@collation_database;
--Alternatively, to display the values without changing the default database:
SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'db_name';
@akash-coded
akash-coded / mysql-indexing.md
Last active February 4, 2020 09:49
Description about different types of constraints and all the implicit and excpilict indexing behaviour in MySQL.

MySQL can create composite indexes (that is, indexes on multiple columns). An index may consist of up to 16 columns.

MySQL can use multiple-column indexes for queries that test all the columns in the index, or queries that test just the first column, the first two columns, the first three columns, and so on. If you specify the columns in the right order in the index definition, a single composite index can speed up several kinds of queries on the same table.

A multiple-column index can be considered a sorted array, the rows of which contain values that are created by concatenating the values of the indexed columns.

Suppose that a table has the following specification:

CREATE TABLE test (
 id INT NOT NULL,
@akash-coded
akash-coded / misusing-boolean-literals.php
Last active February 20, 2020 15:40
Redundant Boolean literals should be removed from expressions to improve readability and remove code smells.
<?php
// Noncompliant Code Example
if ($booleanVariable == true) { /* ... */ }
if ($booleanVariable != true) { /* ... */ }
if ($booleanVariable || false) { /* ... */ }
doSomething(!false);
$booleanVariable = condition ? true : exp;
$booleanVariable = condition ? false : exp;
@akash-coded
akash-coded / web-scraping-boilerpy.md
Last active April 25, 2025 13:34
Text extraction from websites, or Web Mining, is a major area of interest in today's connected world. Extract text content from web pages with Python tools. Some of the tools mentioned here have a more focussed approach on main text extraction wherea

1. Using BoilerPy3, a native Python port of Christian Kohlschütter's Boilerpipe for automatically extracting main textual content of a webpage based on shallow text features. It gives us the page title and it's contents

!pip install boilerpy3
from boilerpy3 import extractors

extractor = extractors.CanolaExtractor()

doc = extractor.get_doc_from_url('https://www.newsrain.in/petrol-diesel-prices/Odisha')
page_title = doc.title