Skip to content

Instantly share code, notes, and snippets.

@abondis
abondis / chef-websites.rb
Created July 13, 2011 22:52
cookbook/recipes/websites
include_recipe "mysql::client"
node[:websites].each do |website|
db_website = search(:websites, "id:#{website} AND status:enabled").first
puts "apptype: #{db_website}"
case db_website["apptype"]
when "php", "dp", "wp"
document_root="/var/www/#{db_website["client"]}/#{db_website["id"]}"
package "php"
include_recipe "apache2::mod_php5"
@abondis
abondis / base.rb
Created July 15, 2011 15:05
base role
{
"name": "base",
"description": "Basic role for any client",
"json_class": "Chef::Role",
"default_attributes": {
"authorization": {
"sudo": {
"groups": [
"sysadmin"
],
user c["username"] do
comment c["username"]
system true
shell "/usr/bin/git-shell"
home "/srv/datas/#{c['username']}"
action :create
end
c_home = File.expand_path("~#{c['username']}")
@abondis
abondis / gist:3267637
Created August 5, 2012 22:48
semantic.gs menu
topmenu {
@include column(12);
float: right;
ul{
@include column(9);
float: right;
padding:0;
li {
@include column(1);
display: inline;
@abondis
abondis / responsive.css
Created August 5, 2012 23:10
html + css
body {
width: 100%;
*zoom: 1; }
body:before, body:after {
content: "";
display: table; }
body:after {
clear: both; }
header#top {
@abondis
abondis / gist:4962393
Last active December 13, 2015 19:28
dulwich: move a file in a repo
from dulwich.repo import Repo
r = Repo('/tmp/bunchofrepos/montestgit/')
t = r['HEAD'].tree
T = r.tree(t)
truc_entry = T.lookup_path(r.get_object, 'blah/truc')
truc_tree = r.tree(truc_entry[1])
truc_tree.entries()
truc_tree['new_filename.txt'] = truc_tree['bidule.text']
truc_tree.entries()
del truc_tree['bidule.text']
@abondis
abondis / .git_config
Created December 30, 2013 21:08
checkout non bare repo
[receive]
denyCurrentBranch = warn

Keybase proof

I hereby claim:

  • I am abondis on github.
  • I am abondis (https://keybase.io/abondis) on keybase.
  • I have a public key whose fingerprint is F2D7 CE32 60DD 76AD EE38 49E3 5D23 DB88 4881 E759

To claim this, I am signing this object:

@abondis
abondis / mock Resource.py
Created December 4, 2014 23:14
mock flask.ext.restul.Resource heritance
from mock import MagicMock, patch
import sys
restful = MagicMock(autospec=True)
attrs = {'__init__': lambda *args, **kwargs: None}
bases = (object,)
Res = type('Resource', bases, attrs)
restful.Resource = Res
with patch.dict(
@abondis
abondis / sh.py
Last active August 29, 2015 14:26
from subprocess import check_output, CalledProcessError
def call_me(cmd, *args, **kwargs):
cmd_list = [cmd]
def wrap(*args, **kwargs):
cmd_list.extend(args)
try:
return 0, check_output(cmd_list, **kwargs)