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();
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@Kartones
Kartones / postgres-cheatsheet.md
Last active April 25, 2024 16:50
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@liquidgecka
liquidgecka / cron_helper.sh
Last active September 28, 2023 15:35
Cron helper
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]... COMMAND
Execute the given command in a way that works safely with cron. This should
typically be used inside of a cron job definition like so:
* * * * * $(which "$0") [OPTION]... COMMAND
Arguments:
@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/"
@ignasi
ignasi / resizer-xxhdpi.sh
Last active February 7, 2021 15:29
Android XXHDPI Resizer (Tested on OS X Mavericks)
#!/bin/bash
f=$(pwd)
mkdir drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi
# fake argv and argc in bash
argc=$#; argv[0]=$0 # argv[0] is a prog name
for foo in $( seq $argc )
do
@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
@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"})
@littlepea
littlepea / munin.rst
Last active April 18, 2019 06:08
Munin setup for monitoring Django on EC2 Ubuntu instance with nginx

This is a short tutorial on setting up munin to monitor your Django website on ec2.

We're gonna be using Nginx instead of apache here because it's more lightweight and popular between Django developers.

Step by step tutorial

1. Install munin ''''''''''''' :

@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)