Skip to content

Instantly share code, notes, and snippets.

View danielshir's full-sized avatar

Daniel Shir danielshir

View GitHub Profile
@danielshir
danielshir / example.sql
Created October 11, 2021 07:19 — forked from wolever/example.sql
A simple Postgres aggregate function for calculating a trimmed mean, excluding values outside N standard deviations from the mean: `tmean(v, standard_deviations)` (for example: `tmean(rating, 1.75)`).
DROP TABLE IF EXISTS foo;
CREATE TEMPORARY TABLE foo (x FLOAT);
INSERT INTO foo VALUES (1);
INSERT INTO foo VALUES (2);
INSERT INTO foo VALUES (3);
INSERT INTO foo VALUES (4);
INSERT INTO foo VALUES (100);
SELECT avg(x), tmean(x, 2.0), tmean(x, 1.5) FROM foo;
@danielshir
danielshir / read-access.sql
Last active February 24, 2020 11:19 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@danielshir
danielshir / ca.md
Created January 16, 2020 19:22 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@danielshir
danielshir / table.txt
Created April 2, 2018 13:56
The Team Asymmetry Fallacy Table
+------------------------------+-------------------------+----------------------------------------------------------------+
| Category | Strong Team | Weak Team |
+------------------------------+-------------------------+----------------------------------------------------------------+
| Division of labor | Efficient | Inefficient |
| Scheduling | Tight, precise | Lacking organization |
| Handling of arising problems | Effective | Ineffective, throws team into mayhem |
| Work rate | Productive | Mediocre |
| Scope changes | Adept at making changes | Changes require a lot of synchronization from all team members |
| Supervision |
@danielshir
danielshir / git-deployment.md
Created November 19, 2017 13:54 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

Daniels test1 [master]$ git var -l | grep -e "^alias"
alias.lg=log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
alias.co=checkout
alias.st=status
alias.ci=commit
alias.df=!f() { git diff -C --color $1 | diff-so-fancy | less --tabs=1,5 -R; }; f
@danielshir
danielshir / useful.bash
Created November 1, 2015 13:21
Useful bash and shell commands
# Useful command to delete remote branches that are merged to currently checked out HEAD
git branch -a --merged | grep BAK | grep -v <CURRENT_BRANCH_NAMEHERE> | sed 's/[ ]*remotes\/origin\///' | xargs -I name git push origin :name