Skip to content

Instantly share code, notes, and snippets.

[user]
name = Gonçalo Silva
email = goncalossilva@gmail.com
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
@goncalossilva
goncalossilva / pre-commit
Created August 25, 2011 15:34
Default pre-commit hook in git
#!/bin/sh
echo "Peter Van Rooijen, explaining the Law of Demeter:
• You can play with yourself
• You can play with your own toys (but you can’t take them apart)
• You can play with toys that were given to you
• And you can play with toys you’ve made yourself\n"
class Ability
include CanCan::Ability
def initialize(user)
can :create, Comment, :post => { :published => true }
end
end
@goncalossilva
goncalossilva / .githookspre-commit
Created May 1, 2012 16:08
Don't commit conflicts
#!/usr/bin/env ruby
`git diff-index --name-status HEAD`.split("\n").each do
|status_with_filename|
status, filename = status_with_filename.split(/\s+/)
next if status == 'D'
File.open(filename) do |file|
while line = file.gets
if line.include?("<<<<<<<") || line.include?(">>>>>>>")
puts "ERROR: #{filename} has unresolved conflicts"
!!\s*([^!][^!]*)\s*!!
!!\s*(.+)\s*!!
%(\d*\$|<)?((?:,|\+| |\(|-\d+|0\d+\#)*)?(\d*)?(\.\d*)?([a-zA-Z%\s])
curl --header "User-Agent: Todoist 43 (Android 4.2.2)" "https://android.todoist.com/TodoistSync/v2/syncAndGetUpdated" -- data-ascii 'client_id=android:APA91bFDt_EplQXjy7pdT1W5ePRyNB3Xvth7BikIWydUEWZqypOCDVp69prgOuQ4esiXLRrLP9UHRtyWFbZZJgy70mC8RbIyaaDWqwofF9pOU2lE9UI8NvzOVrzUsKGQOuFuBN7Rtz0VZe4Mt4yyPIy9WGdapVbbpw&project_timestamps={"102278254":"1370191597.14","99949946":"1370539607.95","108256199":"1370533717.63","100030395":"1370539577.4","100034513":"1369760135.84","102183937":"1369760135.84","99990400":"1369760135.84","107194585":"1369760135.84","102106782":"1369760135.84","108334364":"1370263687.65"}&labels_timestamp=1369760021.22&filters_timestamp=1368029514.05&day_orders_timestamp=1370539826.63&api_token=1465d018df51881e70191a8f62ac71e7cc00547a'
class MyDrawerLayout extends DrawerLayout {
// ...
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if(child instanceof ViewGroup) {
ViewGroup childVG = (ViewGroup)child;
if(childVG.getBackground() == null && childVG.getChildCount() == 1) {
View realChild = childVG.getChildAt(0);
@goncalossilva
goncalossilva / actionbarsherlock.build.gradle
Last active December 22, 2015 07:09
Dependencies project and libraries. Imaginary snippets based on the actual code, but greatly simplified
// ActionBarSherlock:actionbarsherlock's build.gradle snippet
dependencies {
compile 'com.android.support:support-v4:18.0.+'
}