Skip to content

Instantly share code, notes, and snippets.

@fedefernandez
fedefernandez / SignUpActivity.java
Created September 15, 2014 15:35
Abstract ActionBar with Dagger (from Architecting Android Applications with Dagger - Jake Wharton)
public class SignUpActivity extends Activity {
private final ObjectGraph childOg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState):
ExampleApp app = (ExampleApp) getApplication();
ObjectGraph og = app.getObjectGraph();
package com.andraskindler.playground.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.andraskindler.playground.Item;
import com.andraskindler.playground.R;
@ignasi
ignasi / post-commit
Last active December 27, 2015 15:19 — forked from consti/post-commit
Take a photo of you, whenever you make a commit
#!/bin/sh
#############
# This is my fork of consti/post-commit gist: https://gist.github.com/consti/3082406
# It uses a more human date naming and stores captures from same repo to same directory.
# I have also added branch name at filename.
#############
#
# Take a photo of you, whenever you make a commit
@Ashex
Ashex / accountid_boto3.py
Created October 13, 2015 16:10
Get Account ID from boto3 via IAM or Role ARN
import boto3
import argparse
def main():
argparser = argparse.ArgumentParser(description='Testing ARN stuff')
argparser.add_argument("--role", help="If running with a role provide it here", required=True)
argparser.add_argument("--profile", help="Credential profile", required=True)
argparser.add_argument('--region', help='AWS Region to work within, defaults to eu-central-1', default='eu-central-1', required=False)
args = argparser.parse_args()
role = args.role
@bohde
bohde / tags.py
Created January 30, 2012 03:25
Using django-taggit with django-tastypie
from tastypie.fields import ListField
class TaggedResource(ModelResource):
tags = ListField()
class Meta:
queryset = Model.objects.all()
def build_filters(self, filters=None):
if filters is None:
#!/bin/bash
#
# Larry Smith Jr.
# mrlesmithjr@gmail.com
# @mrlesmithjr
# http://everythingshouldbevirtual.com
#
# Variables
DD_BS="512 1024 2048 4096 8192 16384 1048576" #define blocksizes to test in Bytes [512=512b, 1024=1k, 2048=2k, 1048576=1MB]
DD_CONV_OPTIONS="fdatasync,notrunc" #define the output options to pass to dd when creating TESTFILE
@ignasi
ignasi / db_getter.sh
Created January 30, 2014 11:43
Get database from an Android app (Android 4.3+)
#!/bin/bash
# Android 4.3+ changes app's internal directory permissions and you can not just pull your
# databases to your computer, so I did this as a workaround to extract my databases.
# I only use it for debug, use it under your responsability.
package=$1
db_name=$2
path="/data/data/$package/"
@languitar
languitar / violations_trigger.groovy
Created August 26, 2013 07:59
A trigger script for the jenkins (hudson) email_ext plugin which informs users in case their commits introduce new violations or warnings. In contrast to the limit options of various other plugins for code analysis reporting this does not fail the build.A simple but insecure way to share this script between different jobs is to execute the follo…
import jenkins.model.Jenkins
build = Jenkins.instance.items[0].builds[0]
println build
println("Available actions on the build: " + build.actions)
def analysisCoreActions = []
// All static analysis actions based on static analysis core can be handled uniformly
analysisCoreActions.addAll(build.actions.findAll{it.class.name =~ "hudson.plugins.checkstyle.CheckStyle.*ResultAction"})
@krider2010
krider2010 / .profile
Last active November 29, 2017 06:13
Git Signed Commits - OSX and GUIs
# This would go into .bash_profile, .bashrc, .zshrc, etc.
# Script to start the gpg-agent - in it's own file as it is also used when the machine starts up
# Be sure to update the path to wherever you place this file!
# Note, depending on shell you may not need this line enabling, if the global daemon is already running
# OK. Some shells complain, others don't!
~/bin/startup-gpg-agent.sh
# GPG
if [ -f "${HOME}/.gpg-agent-info" ]; then
@samuraisam
samuraisam / models.py
Last active February 22, 2019 21:50
Using STS (Security Token Service) to grant access for a federated user to a s3 bucket prefix
import json
import boto
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User
class UploadToken(models.Model):
user = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True)