Skip to content

Instantly share code, notes, and snippets.

View carlesso's full-sized avatar

Enrico Carlesso carlesso

View GitHub Profile
#!/usr/bin/env python
import sys
import i3
def get_workspace(position = None):
mon = next(el for el in i3.get_workspaces() if el["focused"])
current_output = next(output for output in i3.get_outputs() if (output["active"] and (output["name"] == mon["output"])))
if position is None:
position = "current"
#!/usr/bin/env python
# Properly cycle through named workspaces on i3, preventing bugs related to "3: foo" names
# And in your .i3/config
#
# bindsym Mod4+h exec /home/carlesso/bin/i3_output prev
# bindsym Mod4+l exec /home/carlesso/bin/i3_output next
import sys
import i3
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.005 000.005: --- VIM STARTING ---
000.058 000.053: Allocated generic buffers
000.111 000.053: locale set
000.123 000.012: GUI prepared
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.009 000.009: --- VIM STARTING ---
000.110 000.101: Allocated generic buffers
000.202 000.092: locale set
000.220 000.018: GUI prepared
@carlesso
carlesso / .pryrc
Last active August 29, 2015 14:12
Pry::Commands.create_command 'echo' do
description 'Echo the input'
banner <<-BANNER
Usage: echo [ -j <joiner> ] <words>
BANNER
def setup
@joiner = ' '
end
@carlesso
carlesso / db.yml
Created January 15, 2015 13:44
db.yml
- name: Create PostgreSQL Users for rails applications
sudo: yes
sudo_user: postgres
when: item.db == 'postgresql'
postgresql_user: db={{ item.postgresql.database }} name={{ item.postgresql.username }} password={{ item.postgresql.password }} priv=ALL
with_items: rails_applications
@carlesso
carlesso / test.rb
Last active August 29, 2015 14:14
Ruby "somethingIdon'tknowhowtoname"?
class Something
key :foo
def do_foo_check
# I'd like to access key somehow here
put "I'm doing #{what}"
# Expecting I'm doing foo
end
key :foo
@carlesso
carlesso / gist:e27b362e5b9bd8d69b3b
Created February 21, 2015 23:45
Pry show-method applied to .=~
[16] pry(main)> show-method 'string'.=~
From: string.c (C Method):
Owner: String
Visibility: public
Number of lines: 14
static VALUE
rb_str_match(VALUE x, VALUE y)
{
%w{git bash-completion htop multitail sudo vim wget autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev}.each do |pkg|
package pkg do
action :install
end
end
execute 'apt-get update' do
action :nothing
end.run_action(:run)
%w{git bash-completion htop multitail sudo vim wget autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev}.each do |pkg|
puts "HERE: #{pkg}"
apt_package pkg
end
execute 'apt-get update' do
action :nothing
end.run_action(:run)
include_recipe 'basic::users'