Skip to content

Instantly share code, notes, and snippets.

@LuizZak
LuizZak / retry.swift
Last active February 12, 2018 10:27
PromiseKit retrying functions using encapsulated blocks that return promises
/// Retries the given throwing `block` as a promise `tries` times,
/// re-calling `block` another time until exhausting the tries.
func retry<T>(tries count: Int, block: () throws -> T) -> Promise<T> {
return Promise().thenRetry(tries: count, block: block)
}
/// Retries the given promise-returning `block` as a promise `tries` times,
/// re-calling `block` another time until exhausting the tries.
func retry<T>(tries count: Int, block: () -> Promise<T>) -> Promise<T> {
return Promise().thenRetry(tries: count, block: block)
@blalor
blalor / gist:c325d500818361e28daf
Created May 2, 2014 04:37
redhat init script for consul
#!/bin/bash
#
# consul Manage the consul agent
#
# chkconfig: 2345 95 95
# description: Consul is a tool for service discovery and configuration
# processname: consul
# config: /etc/consul.conf
# pidfile: /var/run/consul.pid
@johanneswuerbach
johanneswuerbach / .travis.yml
Last active April 14, 2023 20:31
Deploy an iOS app to testflight using Travis CI
---
language: objective-c
before_script:
- ./scripts/travis/add-key.sh
after_script:
- ./scripts/travis/remove-key.sh
after_success:
- ./scripts/travis/testflight.sh
env:
global:
@jzempel
jzempel / application:__init__.py
Created July 29, 2012 20:37
Flask with Celery 3.0
from blueprint import example
from extensions import mail
from flask import Flask
import settings
def create_app(settings=settings):
ret_val = Flask(__name__)
ret_val.config.from_object(settings)
# initialize extensions...
@dillera
dillera / graphite-centos6-install.txt
Created January 18, 2012 17:59
Install Graphite 0.9.9 and Statsd on Centos 6
# FOR CENTOS 6
# Andrew Diller Jan 2012
# Get EPEL Repo installed
rpm --httpproxy proxy --httpport 3128 --import https://fedoraproject.org/static/0608B895.txt
rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm
vi /etc/yum.repos.d/epel.repo
@ianchesal
ianchesal / simpledesktops_download.py
Created July 8, 2011 15:37 — forked from compbrain/simpledesktops_download.py
Download simpledesktops.com wallpaper images
#!/usr/bin/python
__doc__ = """
simpledesktops_download.py
A quick script that fetches desktop images from the http://simpledesktops.com/ site.
It will start at the most current list of images and keep moving backwards, downloading
desktop images in to a directory on your local machine, until it finds an image that
already exists on disk. At that point it will stop.
@derek-watson
derek-watson / tumblr.rb
Created March 12, 2011 18:47
Tumblr to Jekyll migration
#!/usr/bin/env ruby
# Script to import tumblr posts into local markdown posts ready to be consumed by Jekyll.
# Inspired by New Bamboo's post http://blog.new-bamboo.co.uk/2009/2/20/migrating-from-mephisto-to-jekyll
# Supports post types: regular, quote, link, photo, video and audio
# Saves local copies of images
require 'rubygems'
require 'open-uri'
require 'nokogiri'
@jeffmccune
jeffmccune / puppet_master_seed_prod_8140.conf
Created January 21, 2011 17:17
Puppet Master Front End Load Balancer configuration
## Apache Load Balancer Front End ##
# Puppet Apache::Config[010_frontend_puppet_prod.conf]
# This file managed by Puppet from a template.
# source: puppet_frontend_XXXX.conf
# All CA requests should be directed to specific workers
<Proxy balancer://puppet_prod_ca>
# Only one member
BalancerMember http://puppetca.puppetlabs.vm:18140
@jordansissel
jordansissel / output
Created October 29, 2010 18:09
puppetless puppet (package management of remote hosts)
Usage: puppet-package-over-ssh.rb HOST PACKAGE ACTION
% ruby puppet-package-over-ssh.rb snack sl uninstall
Package[sl] uninstall status: {:status=>"not-installed", :error=>"ok", :desired=>"unknown", :ensure=>:purged, :name=>"sl", :provider=>:apt}
% ruby puppet-package-over-ssh.rb snack sl install
Package[sl] install status: {:status=>"installed", :error=>"ok", :desired=>"install", :ensure=>"3.03-16", :name=>"sl", :provider=>:apt}
% ruby puppet-package-over-ssh.rb snack fancypants install
Could not install package Package[fancypants]: Execution of 'ssh snack sudo "/usr/bin/apt-get" "-q" "-y" "-o" "DPkg::Options::=--force-confold" "install" "fancypants"' returned 100: Reading package lists...
Building dependency tree...