Skip to content

Instantly share code, notes, and snippets.

View vivek0460's full-sized avatar
🎯
Focusing

Vivek Pandey vivek0460

🎯
Focusing
View GitHub Profile
@vivek0460
vivek0460 / postgres_queries_and_commands.sql
Created October 12, 2023 06:19 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
/*
Cell compete:
Eight houses, represented as a cells, are arranged as a straight line.
Each days every cells competes with adjacent cells. An integer value 1
represents an active cell and a value of 0 represent an inactive cell.
if the neigbour on both the sides of the cell are both active or inactive,
the cell become inactive in the next day, otherwise the become active.
The two cells on each or have a single adjacent cell, so asume that
the onoccupied space in the opposite side is an inactive cell. even after
updating the cell state, consider its previus state when updating the state
date,New York_1,San Francisco_1,Austin_1,New York_2,San Francisco_2,Austin_2
20120101,46,53,55,8,12,13
20120102,43,53,48,6,12,9
20120103,30,49,41,-1,9,5
20120104,19,52,48,-7,11,9
20120105,32,52,54,0,11,12
20120106,41,49,61,5,9,16
20120107,47,51,59,8,11,15
20120108,46,56,52,8,13,11
20120109,34,52,54,1,11,12
@vivek0460
vivek0460 / .block
Created December 9, 2019 04:51
Heatmap template
license: gpl-3.0
@vivek0460
vivek0460 / .block
Created December 6, 2019 06:10
D3.js: Animating Stacked-to-Grouped Bars
license: mit
@vivek0460
vivek0460 / .block
Last active December 6, 2019 06:09
D3.js: Animating Stacked-to-Grouped Bars
license: mit
@vivek0460
vivek0460 / wp-config.php
Created September 11, 2018 11:22
Set WordPress site URL in the config file instead of the database
<?php
// WordPress stores the site URL in the database by default (which I have never
// understood), and it's a pain to have to type out the UPDATE SQL or search in
// phpMyAdmin to change it. This is a simple way to put the URL into
// wp-config.php instead.
// Note that you will still need to update any URLs that appear in the content,
// especially when you copy a database from a development site to production:
// https://gist.github.com/davejamesmiller/a8733a3fbb17e0ff0fb5
@vivek0460
vivek0460 / QueueRetryAllCommand.php
Created August 29, 2018 06:07 — forked from JacobBennett/QueueRetryAllCommand.php
Laravel Queue:Retry-Multiple and Queue:Retry-All
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class RetryAllCommand extends Command
{
/**
* The name and signature of the console command.
@vivek0460
vivek0460 / image-src-regexpr.php
Created August 23, 2018 13:46 — forked from vyspiansky/image-src-regexpr.php
PHP: get image src attribute (regular expression)
<?php
// Source: http://goo.gl/qyLFbg
$html = '<img border="0" src="/images/image.jpg" alt="Image" width="100" height="100" />';
preg_match( '@src="([^"]+)"@' , $html, $match );
$src = array_pop($match);
// will return /images/image.jpg
@vivek0460
vivek0460 / Strong Password RegEx
Created July 23, 2018 11:02 — forked from ravibharathii/Strong Password RegEx
A Regular Expression for a Strong Password
Description of this regular expression is as below:
Passwords will contain at least 1 upper case letter
Passwords will contain at least 1 lower case letter
Passwords will contain at least 1 number or special character
Passwords will contain at least 8 characters in length
Password maximum length should not be arbitrarily limited
(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$