This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint64 get_memory_usage() { | |
uint64 result = 0; | |
int i = 0; | |
bool seenSpace = false; | |
char statm[1024]; | |
FILE *statmFile = fopen("/proc/self/statm", "r"); | |
fread(statm, 1, 1024, statmFile); | |
fclose(statmFile); | |
for (i = 0; i < 1024; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative ((<*>), (*>), (<*)) | |
import Control.Monad (replicateM) | |
import Data.Functor ((<$>)) | |
import Data.Ix (range) | |
import Text.ParserCombinators.ReadP | |
-- Main | |
main = do | |
query_count <- read <$> getLine | |
queries <- map (parse like_query) <$> replicateM query_count getLine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Compress a table using cstore_fdw | |
CREATE OR REPLACE FUNCTION compress_table(uncomp_table regclass) RETURNS VOID AS | |
$BODY$ | |
DECLARE | |
table_name text; | |
comp_table_name text; | |
ispartitionv boolean; | |
parent text; | |
partition_expression text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* solution 1 */ | |
class Solution { | |
public: | |
int calculateNum(string &s, int &c) { | |
int result = 0; | |
while (c < s.length() && s[c] != '+' && s[c] != '-' && s[c] != '*' && s[c] != '/') { | |
if (s[c] >= '0' && s[c] <= '9') { | |
result = result * 10 + s[c] - '0'; | |
} | |
c++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
date | |
for pid in $(ps aux | grep postgres | awk '{print $2}'); do echo `sudo ls -1 /proc/$pid/fd 2>/dev/null | wc -l` pid=$pid; done | sort -k1 -n | tail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
DIRS=(data/coordinator data/worker1 data/worker2 data/worker3) | |
PORTS=(5432 5433 5434 5435) | |
ADD_AS_WORKER=(0 1 2 2) | |
COORDINATOR_PORT=${PORTS[0]} | |
COORDINATOR_DATA=${DIRS[0]} | |
for i in "${!DIRS[@]}"; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g history-limit 100000 | |
# Use Alt-arrow keys without prefix key to switch panes | |
bind -n M-Left select-pane -L | |
bind -n M-Right select-pane -R | |
bind -n M-Up select-pane -U | |
bind -n M-Down select-pane -D | |
set-option -g default-command bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of simple echo server | |
# www.solusipse.net | |
import socket | |
def listen(): | |
socket1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
socket1.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
socket1.bind(('0.0.0.0', 5555)) | |
socket1.listen(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELLSEP=❖ | |
function git_branch { | |
[ -d .git ] && echo " $SHELLSEP $(git name-rev --name-only @) ★ $(git remote get-url origin)" | |
} | |
function pg_version { | |
if command -v pg_config >/dev/null; then | |
echo " $SHELLSEP $(pg_config --version)" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require graphviz) | |
(define tables | |
`(("product" ("title" | |
"description" | |
"price")) | |
("category" ("title" | |
"description")) |
OlderNewer