Skip to content

Instantly share code, notes, and snippets.

View wsdookadr's full-sized avatar
🎯
Focusing

Stefan Corneliu Petrea wsdookadr

🎯
Focusing
  • Nobody at Nowhere
  • Nowhere
View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use Storable qw/dclone/;
use Data::Dumper;
my $a = {
'%h_outside' => {
'a' => 1,
'b' => 2
@wsdookadr
wsdookadr / Reader.pm.patch
Created October 24, 2011 21:15
Devel::NYTProf 4.06 patch that adds a switch to exclude packages/namespaces from nytprofhtml output
--- /opt/Intra/lib/CPAN/lib/perl5/x86_64-linux-thread-multi/Devel/NYTProf/Reader.pm 2011-10-24 18:49:39.000000000 +0000
+++ pnytprof_lib/Devel/NYTProf/Reader.pm 2011-10-24 19:16:36.000000000 +0000
@@ -18,7 +18,7 @@
use Carp;
use Config;
-use List::Util qw(sum max);
+use List::Util qw(sum max first);
use Data::Dumper;
@wsdookadr
wsdookadr / json_manipulator.sql
Created May 31, 2016 10:57 — forked from matheusoliveira/json_manipulator.sql
Simple PostgreSQL functions to manipulate json objects. (Note: performance is not a concern for those functions)
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
IMMUTABLE
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
@wsdookadr
wsdookadr / queue.sh
Created November 1, 2016 11:53 — forked from timtadh/queue.sh
BASH Job Queue. This is a example of how to make a job queue in GNU Bash. It may not work for other shells as it relies on the bash built in `read`. You will need to see the man pages for your shell to determine if this will work for you.
#!/usr/bin/env bash
rep() {
i=$1
data=$2
## run the replicate ....
}
# make the files
START=$(mktemp -t start-XXXX) ## signals the workers are starting
@wsdookadr
wsdookadr / statistics.sql
Created November 6, 2016 12:54 — forked from ruckus/statistics.sql
Postgres statistics queries
** Find commmonly accessed tables and their use of indexes:
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct;
Returns output like:
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct
----------------------+--------------+---------------+------------------------
schema_migrations | 817 | 0 | 0.00000000000000000000
user_device_photos | 349 | 0 | 0.00000000000000000000
https://www.amazon.com/Gildan-Platinum-Mens-5-Pack-T-Shirt/dp/B07575MXH4/ref=pd_sbs_193_1?_encoding=UTF8&pd_rd_i=B07575MXH4&pd_rd_r=NVSNRHYS4CG3X8YJR82Z&pd_rd_w=Oj6AO&pd_rd_wg=iVGLo&refRID=NVSNRHYS4CG3X8YJR82Z
https://www.amazon.com/Gildan-Platinum-Mens-5-Pack-T-Shirt/dp/B07575MXH4/ref=pd_sbs_193_1?_encoding=UTF8&pd_rd_i=B07575MXH4&pd_rd_r=NVSNRHYS4CG3X8YJR82Z&pd_rd_w=Oj6AO&pd_rd_wg=iVGLo&refRID=NVSNRHYS4CG3X8YJR82Z
https://www.amazon.com/Gildan-Mens-T-Shirts-White-Large/dp/B077ZMKWVM/ref=sr_1_2?s=apparel&ie=UTF8&qid=1526879873&sr=1-2&nodeID=1040658&psd=1&keywords=crew+neck+shirt+men
https://www.amazon.com/Gildan-Platinum-5-Pack-T-Shirt-Black/dp/B07575B6C7/ref=sr_1_8?s=apparel&ie=UTF8&qid=1526880186&sr=1-8&nodeID=7147441011&psd=1&keywords=crew+neck+t+shirt+men
https://www.amazon.com/Next-Level-NL6410-Premium-T-Shirt/dp/B0149PS4IQ/ref=sr_1_21?s=apparel&ie=UTF8&qid=1526880219&sr=1-21&nodeID=7147441011&psd=1&keywords=crew+neck+t+shirt+men
https://www.amazon.com/Next-Level-NL6410-Premium-T-Shirt/dp/B0149PU3NK/re
@wsdookadr
wsdookadr / fetch-repos.sh
Created September 30, 2018 19:22 — forked from hhutch/fetch-repos.sh
find file changes in all forks of a github repo
curl -i https://api.github.com/repos/scrooloose/nerdtree/forks |grep -e "git_url" |awk '{gsub(/,/,"");split($2,a,"/"); system("mkdir "a[4]"; cd "a[4]"; git clone " $2);}'
function scroll_to(splash, x, y)
local js = string.format(
"window.scrollTo(%s, %s);",
tonumber(x),
tonumber(y)
)
return splash:runjs(js)
end
@wsdookadr
wsdookadr / .vimrc
Created October 28, 2018 11:49
.vimrc
" general settings
set nocompatible
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set nobackup " don't keep a backup file
set noswapfile " no swap file either
set history=800 " keep lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching

init

CREATE TABLE IF NOT EXISTS `OCCUPATIONS` (
  `Name` varchar(200) NOT NULL,
  `Occupation` varchar(200) NOT NULL
);
INSERT INTO `OCCUPATIONS` (Name, Occupation) VALUES
  ('Samantha','Doctor'),
  ('Julia','Actor'),