Skip to content

Instantly share code, notes, and snippets.

@momer
momer / sql_resources.md
Last active April 22, 2024 18:07
SQL learning Resources for Beginners

There are a number of good introductory SQL resources available for free and online. There are also some paid resources which I recommend for beginners, that are very effective, and well worth expensing in my opinion.

A couple of notes:

  • I haven’t used all of these resources, but they come with strong recommendations around the web or myself/my peers.
  • You absolutely don’t need to use every single resource. Find a couple that work for you, and go to town.
  • You can always reach out to me if you have questions. I always paste this online when people are new to asking very technical questions – it’s not meant to be snarky – it's a gentle guide on how to compose your questions and gather necessary resources in order to best give technical people the information needed to get a quick/effective response: http://www.mikeash.com/getting_answers.html

Video/Class/Mini-course based:

  1. Stanford Self-paced ‘Database’ course
  • The original Coursera
@momer
momer / grpc_with_reconnect.go
Last active February 7, 2024 00:44
A pattern I created to maintain connections to an RPC server in Go. Since net/rpc does not provide any methods for automatically reconnecting to an RPC server, I needed a work-around. Additionally, rpc.Client does not export any state variables (rpc.Client.shutdown and rpc.Client.closing) nor does it export the Client's Mutex. So, we wrap the rp…
package main
import (
"myapp/webserver/app/common"
"github.com/golang/glog"
"github.com/gorilla/mux"
"encoding/json"
"strconv"
"flag"
"fmt"

Privacy Policy

Last revised on [DATE]

The Gist

[COMPANY] will collect certain non-personally identify information about you as you use our sites. We may use this data to better understand our users. We can also publish this data, but the data will be about a large group of users, not individuals.

We will also ask you to provide personal information, but you'll always be able to opt out. If you give us personal information, we won't do anything evil with it.

@momer
momer / terms_of_service.markdown
Created March 12, 2023 18:02 — forked from devver/terms_of_service.markdown
A general Terms of Service under the Creative Commons License

Terms of Service

Last revised on [DATE]

The Gist

[COMPANY] operates the [SERVICE] service, which we hope you use. If you use it, please use it responsibly. If you don't, we'll have to terminate your account.

For paid accounts, you'll be charged on a monthly basis. You can cancel anytime, but there are no refunds.

@momer
momer / metadata
Last active February 22, 2023 22:39
{
"name": {
"title": "Full Name",
"type": "string",
"githubKey": "name"
},
"email": {
"title": "E-Mail",
"type": "string",
"githubKey": "email",
@momer
momer / example-hash.go
Created May 8, 2014 13:17
Golang example of creating a timestamped key for an immutable key/value store like Groupcache.
package main
import "fmt"
import "time"
import "encoding/hex"
import "hash/fnv"
func main() {
h := fnv.New64a()
@momer
momer / model_method.rb
Created December 18, 2013 20:53
Large custom query in postgreSQL for a Rails app
def moderate_plus_vigorous_durations_adjusted(start_date=(1.week.ago.beginning_of_day), end_date=(DateTime.now))
query_args = [{value: self.id}, {value: start_date}, {value: end_date}]
sql = %Q[
WITH my_vars(intensity_2_duration, intensity_3_duration) AS (VALUES
(
(SELECT SUM(duration) as intensity_2_duration
FROM users
INNER JOIN workouts
ON workouts.user_id = users.id
WHERE
@momer
momer / final_query.sql
Last active December 31, 2015 18:29
Thank you to davidfetter_disq for helping me reach this conclusion. Thank you as well to johto and ASnyder for offering their help :)
WITH my_vars(intensity_2_duration, intensity_3_duration) AS (VALUES
(
(SELECT (SUM(duration)*2) FROM users INNER JOIN workouts ON workouts.user_id = users.id
WHERE intensity = 3 AND workouts.deleted_at IS NULL),
(SELECT SUM(duration) FROM users INNER JOIN workouts ON workouts.user_id = users.id
WHERE intensity = 2 AND workouts.deleted_at IS NULL)
)
)
SELECT MAX(date), (SELECT (intensity_2_duration + intensity_3_duration) FROM my_vars) as total_duration, SUM(duration)
FROM workouts
@momer
momer / nginx.conf
Last active December 22, 2015 17:59
Example nginx config with unicorn and SSL redirection. - I think a lot of it was inspired/copy pasta'd from other gists/examples.
upstream unicorn {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/unicorn.examplesitehere.sock fail_timeout=0;
}
server {
listen 80;