Skip to content

Instantly share code, notes, and snippets.

View andrewpetrochenkov's full-sized avatar
πŸ”

Andrew P andrewpetrochenkov

πŸ”
View GitHub Profile
@andrewpetrochenkov
andrewpetrochenkov / docker-stop-all-containers.sh
Last active October 12, 2021 19:45
Docker stop all containers #docker
sudo docker ps -q | xargs -r sudo docker stop
@mmillar-bolis
mmillar-bolis / Launchctl_Unload-10.14.sh
Created November 23, 2020 07:46
A Quick Little Script to Force Disable Certain LaunchDaemons in macOS
#!/bin/bash
# I have managed to map out some undesirable daemons and agents. Most of these
# can be disabled without too much consequence.
## Daemons
# com.apple.analyticsd - Anonymized application analytics daemon
# com.apple.appleseed.fbahelperd - Feedback Assistant Helper Daemon
# com.apple.awacsd - Apple Wide Area Connectivity Service Daemon
# com.apple.backupd - Apple TimeMachine service
@spacelatte
spacelatte / gists.graphql
Last active August 28, 2023 11:48
github api v4 gists query graphql
query gistquery($name: String = "pvtmert", $count: Int = 100, $field: GistOrderField = UPDATED_AT, $sort: OrderDirection = DESC, $privacy: GistPrivacy = ALL) {
user(login: $name) {
gists(first: $count, orderBy: {field: $field, direction: $sort}, privacy: $privacy) {
nodes {
name
owner {
id
login
url
resourcePath
@andrewpetrochenkov
andrewpetrochenkov / mac-wifi.sh
Last active August 3, 2024 20:06
macOS Wi-Fi #macos
/usr/sbin/networksetup -getairportpower en1
# /usr/sbin/networksetup -setairportpower en0 on
# /usr/sbin/networksetup -setairportpower en0 off
@jamesluberda
jamesluberda / graphql-for-gists.md
Created June 20, 2018 01:07
Simple User Gists Query Using GitHub GraphQL API (v4 API)

I couldn't find any examples of gists queries using GraphQL--most GraphQL examples seem to focus on traditional repositories--so here is one. As a preface, I cannot recommend strongly enough, at least when getting started, developing queries using the GitHub GraphQL Explorer. I initially started by issuing queries via curl, constructing them using the docs available on the site and a downloaded copy of the schema. Unfortunately, I ended up with errors that I couldn't quite parse. I knew, for example, from the schema, the possible field values for ordering gists. However, whenever I tried to use one of those values, the API returned that it was invalid, like so:

{"data":null,"errors":[{"message":"Argument 'orderBy' on Field 'gists' has an invalid value. Expected type 'GistOrder'.","locations":[{"line":1,"column":48}]}]}"

When I finally turned to the Explorer, I discovered that not only was the value I was using correct (field: CREATED_AT), thanks to its auto

query{
__type(name:"Repository") {
fields {
name
description
type {
kind
name
description
}
@MauricioMoraes
MauricioMoraes / access_postgresql_with_docker.md
Last active August 30, 2024 05:21
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@santisbon
santisbon / Search my gists.md
Last active May 5, 2025 21:07
How to search gists.

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@benjaminoakes
benjaminoakes / table_size.psql
Created April 21, 2016 20:38
Calculate size of PostgreSQL tables
dbname=# SELECT
dbname-#    relname as "Table",
dbname-#    pg_size_pretty(pg_total_relation_size(relid)) As "Size",
dbname-#    pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size"
dbname-#    FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
                      Table                       |    Size    | External Size
--------------------------------------------------+------------+---------------
table1                           | 19 GB      | 1665 MB
table2                           | 12 GB      | 9720 MB
table3                           | 10 GB      | 5903 MB
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.94 Chrome/37.0.2062.94 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/600.8.9 (KHTML, like Gecko) Version/8.0.8 Safari/600.8.9
Mozilla/5.0 (iPad; CPU OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H321 Safari/600.1.4
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0)