Skip to content

Instantly share code, notes, and snippets.

@LeeXun
LeeXun / postgres_queries_and_commands.sql
Created June 19, 2018 13:38 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), 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(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@LeeXun
LeeXun / 1_two_sum_leetcode.c
Last active November 13, 2018 15:33
Leetcode
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* twoSum(int* nums, int numsSize, int target) {
int i, j;
int *ans = malloc(sizeof(int)*2);
for(i=0; i<numsSize; i++) {
for(j=0; j<numsSize; j++) {
if(nums[i]+nums[j] == target && i != j) {
ans[0] = j;