Skip to content

Instantly share code, notes, and snippets.

@marcocitus
marcocitus / example.sql
Last active February 24, 2024 13:17
Safe incremental rollups on Postgres and Citus
-- Create the raw events table
CREATE TABLE page_views (
site_id int,
path text,
client_ip inet,
view_time timestamptz default now(),
view_id bigserial
);
-- Allow fast lookups of ranges of sequence IDs
@mholt
mholt / stringscontext.go
Last active December 15, 2021 08:48
Functions from the 'strings' package as template actions. Feel free to copy+paste into your project as a starting point.
// Functions from Go's strings package usable as template actions
// with text/template.
//
// This approach assumes you have some context type as a receiver,
// but if you just need the functions check out the FuncMap variant
// below.
//
// Commented functions are not deemed useful in template actions.
// Haven't actually used this, but this is one possible way of doing it.
// Another option is to fill a FuncMap with most of the strings package.
@NickCraver
NickCraver / Windows10-Setup.ps1
Last active April 1, 2024 10:52
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
@cmtoomey
cmtoomey / Tableau.xml
Last active December 28, 2023 21:46
Fully Documented Tableau Workbook as XML
<?xml version='1.0' encoding='utf-8' ?>
<!--This is the basics - platform (windows or mac)and version number-->
<workbook source-platform='mac' version='9.0' xmlns:user='http://www.tableausoftware.com/xml/user'>
<!-- build 9000.15.0318.1720 -->
<!--No idea what this for -->
<preferences>
<preference name='ui.encoding.shelf.height' value='250' />
<preference name='ui.shelf.height' value='250' />
</preferences>
<!--This is everything you need to know about datasources -->
@artdrozdov
artdrozdov / dev-env-install
Last active August 29, 2015 14:19
DevEnv install using Chocolatey
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
Break
}
Write-Host "Hi Art! I will install your working environment."
$answer = Read-Host "Continue? (y/n)"
if($answer -eq "y"){
Write-Host "Processing..."
func LoadArticle(res http.ResponseWriter, req *http.Request) {
if article, err := FindArticleById(...)
if err != nil {
handleError(res, err)
return
}
if article == nil {
handleNotFound(res, err)
}
}
@nathansmith
nathansmith / this-is-madness.css
Last active October 6, 2015 10:36
Examples of CSS selector strength.
* {}
tag {}
[attribute] {}
[attribute="value"] {}
.class {}
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 3, 2024 20:51
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@tristanwietsma
tristanwietsma / auth.go
Created May 15, 2014 04:15
Golang web server example
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
@jpoehls
jpoehls / GadgetController.cs
Last active December 26, 2015 18:58
Basic ASP.NET MVC controller / data layer interaction architecture example.
class GadgetController : Controller {
// Each MVC controller has a complementing '*ControllerContext' class.
private readonly IGadgetControllerContext _context;
GadgetController()
: this(new GadgetControllerContext()) { }
// Unit testing ctor. Allows passing in mock repositories.
GadgetController(IGadgetControllerContext context) {
_context = context;