Skip to content

Instantly share code, notes, and snippets.

View punnie's full-sized avatar

Pedro Coelho punnie

View GitHub Profile
@vy-let
vy-let / configuration.nix
Created July 4, 2020 04:16
Setting up NixOS for typical home SMB file sharing
...
{
services.samba = {
enable = true;
syncPasswordsByPam = true;
# You will still need to set up the user accounts to begin with:
# $ sudo smbpasswd -a yourusername
@CMCDragonkai
CMCDragonkai / nix_ca_certificate_handling.md
Created October 16, 2018 07:02
Nix CA Certificate Handling #nix

Nix CA Certificate Handling

Some applications requires contacting HTTPS endpoints. In those cases you need to supply the CA certificates.

Most Nix applications won't package in the CA certificates, this is because they can make use of the OS provided CA certificate store.

The NixOS location for this is at: /etc/ssl/certs.

The OpenSSL library in Nixpkgs is compiled to use that path if there is no environment variables such as SSL_CERT_FILE.

@clems4ever
clems4ever / ansible-docker-network.yml
Last active December 1, 2022 23:58
Deploy a docker service using Ansible within Docker Swarm 1.12
---
- name: Check if network {{ name }} exists
delegate_to: "{{ groups['docker_swarm_issuer'][0] }}"
run_once: true
command: docker network ls -q --filter name=^{{ name }}$
register: network_exists
changed_when: false
- name: Create network {{ name }}
command: docker network create --driver {{ driver }} {{ name }}
# The following are suggested values
# They should be set in all configs,
# so that if a secondary needs to be promoted
# it will be generating the correct WAL level
wal_level = hot_standby
archive_mode = on # allows archiving to be done
# (change requires restart)
archive_command = 'cp -f %p /data/pgsql/archive/%f </dev/null' # command to use to archive a logfile segment
max_wal_senders = 5 # max number of walsender processes
# (change requires restart)
@deniszh
deniszh / whisper-cyanite.py
Last active February 16, 2023 03:39
Quick and dirty script to migrate Graphite from whisper to cyanite
#!/usr/bin/env python
import os
import mmap
import struct
import signal
import optparse
import cql
try:
@rubypanther
rubypanther / application.rb
Created February 25, 2011 10:31
Monkey patch to make postgres views work with rails 3.x
class ApplicationController < ActionController::Base
require 'postgresql_view_monkey'
end
@ctrochalakis
ctrochalakis / dalton.rb
Created June 11, 2010 12:17
facebook, google, twitter, yahoo warden strategies
require 'dalton/strategies/skroutz'
require 'dalton/strategies/facebook'
require 'dalton/strategies/openid' # yahoo, #google
require 'dalton/strategies/twitter'
# Setup OpenId file storage, don't change the storage engine!
require 'openid/store/filesystem'
Rails.configuration.middleware.use(Rack::OpenID,
OpenID::Store::Filesystem.new(Rails.root + 'tmp/openid'))
@serek
serek / application_helper.rb
Created April 8, 2010 08:26
Polymorphic file upload with paperclip, delayed_job, has_many_polymorphs, swfupload, formtastic and haml. Make same for any other types like Image, Audio, Document and so on.
module ApplicationHelper
# Access Levels
ACCESS_LEVELS = { :private => 0, :friends => 1, :public => 2 }
# Access levels i18n translation
def access_levels
ACCESS_LEVELS.collect{|k,v| [I18n.t("access." + k.to_s), v]}
end
end
#! /usr/bin/env ruby
class Puppetca
# removes old certificate if it exists and removes autosign entry
# parameter is the fqdn to use
def self.clean fqdn
command = "/usr/bin/sudo -S /usr/sbin/puppetca --clean #{fqdn}< /dev/null"
system "#{command} >> /tmp/puppetca.log 2>&1"
#remove fqdn from autosign if exists