Skip to content

Instantly share code, notes, and snippets.

@ceceprawiro
ceceprawiro / Session.php
Created September 6, 2014 20:23
Session library for CodeIgniter
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Code Igniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author Dariusz Debowczyk
* @copyright Copyright (c) 2006, D.Debowczyk
@cuibonobo
cuibonobo / github-to-gitlab.md
Created July 15, 2014 21:23
Moving from GitHub to GitLab with DigitalOcean. (Taken from http://tyler.io/2014/03/switching-from-github-to-gitlab/)

Source

Switching from GitHub to GitLab

I've been a happy paying customer of [GitHub][1] since early 2009. But yesterday, for a few different reasons, I deleted all of my private repositories and moved them over to a self-hosted installation of [GitLab][2]. I didn't make that decision lightly, as I've been very happy with GitHub for the last five years, but here's why…

First, I've started working on a new Mac app. Every time I start a new project, unless it's open source, I create a new private repo for it on GitHub. This project happened to be my 21st private repository on GitHub. If you're familiar with their pricing structure, you'll know they charge based on how many private projects you have. $22 a month will get you twenty repos. But as soon as you create that twenty-first one, you graduate onto the $50 a month plan. Maybe if I were actually hosting 50 repositories with GitHub I'd be willing

@hopsoft
hopsoft / db.rake
Last active May 4, 2025 19:48
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@igorcosta
igorcosta / cpf_cnpj_validator
Created June 26, 2014 19:13
Regex para validar CPF e CNPJ
Para CPF
/^\d{3}\.\d{3}\.\d{3}\-\d{2}$/
Para CNPJ
/^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/
Para ambos ao mesmo tempo
@ravibhure
ravibhure / docker_centos
Last active December 7, 2018 17:57
Docker for CentOS
# Disable selinux as it interferes with functionality of LXC
$ setenforce 0
$ echo 'SELINUX=disabled' > /etc/selinux/config
# Download and setup Fedora EPEL Repository
$ yum -y install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
# Setup hop5.in repository
$ wget http://www.hop5.in/yum/el6/hop5.repo -O /etc/yum.repos.d/hop5.repo
@halkeye
halkeye / production.rb
Created June 7, 2014 05:05
For production Capistrano deploys, we can't use our own internal git server because the one off amazon box doesn't have access to the internal network. Hacked in a solution to create a port forward to talk back to our network. Works in this case so sharing.
require 'net/ssh'
#set :ssh_options, :verbose => :debug
set :user, 'labuser'
set :repo_url, "ssh://eti@localhost:9000/#{fetch(:application)}.git"
$gateway_ssh = {}
namespace :ssh do
task :git_start do
on roles(:all) do
hostname = host.hostname.to_s
@richp10
richp10 / gist:1c367d3c67aec762788e
Created May 10, 2014 10:19
Secure iptables configuration for coreos ??
// This systemd runs iptables-restore on boot:
[Unit]
Description=Packet Filtering Framework
DefaultDependencies=no
After=systemd-sysctl.service
Before=sysinit.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/iptables-restore /opt/docker/scripts/iptables/iptables.rules
@QueuingKoala
QueuingKoala / setup.sh
Last active January 28, 2025 04:40
Sub-CA example
# Assumptions: easyrsa3 available in current dir, and functional openssl.
# This basic example puts the "offline" and "sub" PKI dirs on the same system.
# A real-world setup would use different systems and transport the public components.
# Build root CA:
EASYRSA_PKI=offline ./easyrsa init-pki
EASYRSA_PKI=offline ./easyrsa build-ca nopass
# Build sub-CA request:
EASYRSA_PKI=sub ./easyrsa init-pki
@eddmann
eddmann / SecureSessionHandler.php
Created April 9, 2014 12:18
Secure session handler implementation.
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;
@chadwithuhc
chadwithuhc / hooks.php
Created April 9, 2014 00:25
Rocketeer PHP Hook Sample
<?php
/**
* Used to run any after deploy tasks:
* - Migrate DB
* - Clear expired password reminder tokens
* - Clear caches
* - Remove any unwanted files from the server
*/
$deploy_cleanup = function ($task) {