Skip to content

Instantly share code, notes, and snippets.

View pboos's full-sized avatar

Patrick Boos pboos

View GitHub Profile
@pboos
pboos / gist:2951782
Created June 19, 2012 01:21
selectable adapter
private Set<String> mSelectedContactNumbers = new HashSet<String>();
@Override
public void bindView(View view, Context context, final Cursor cursor)
{
final String contactNumber = cursor.getString(cursor.getColumnIndex("contact_number"));
view.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
@pboos
pboos / FlowLayout.java
Created July 6, 2012 00:12
FlowLayout
package jp.cyberagent.android.base.ui.widget;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
@pboos
pboos / gist:4034959
Created November 7, 2012 22:31
SleepTimer: Stop Services attempt without root [failed]
Class c = Class.forName("android.app.ActivityManagerNative");
Method getDefaultMethod = c.getMethod("getDefault");
getDefaultMethod.setAccessible(true);
Object nativeManager = getDefaultMethod.invoke(null);
c = nativeManager.getClass();
Method forceStopPackageMethod = c.getMethod("forceStopPackage", String.class);
forceStopPackageMethod.setAccessible(true);
forceStopPackageMethod.invoke(nativeManager, pkgName);
@pboos
pboos / compileall.php
Created November 7, 2012 22:36
PHP: gettext
$loc->compileAll();
@pboos
pboos / check_paypal.java
Created November 8, 2012 12:37
Android: Make your Android apps unlockable through payment
if (isPackageAvailable("ch.pboos.android.SleepTimerPayPal")) {
Intent intent = new Intent(
"ch.pboos.android.SleepTimerPayPal.CHECK");
startActivityForResult(intent, CHECK_PAYMENT);
}
@pboos
pboos / LiftProject.scala
Created November 8, 2012 13:05
Lift Tutorial 1: Development Environment Setup
import sbt._
import de.element34.sbteclipsify._
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) with Eclipsify {
@pboos
pboos / deploy
Created November 8, 2012 13:14
Lift Tutorial 2: Nice Server with Jetty and MongoDB
#!/usr/bin/env scala
!#
import java.io._
import scala.runtime.RichChar
import scala.io.Source
import scala.util.matching.Regex
import scala.collection.immutable.Stream
// SETTINGS
val FILE_NAME_ON_SERVER = "1.war"
val SCP_SERVER_NAME = "ec2.my_server.ch"
@pboos
pboos / dnsupdate.sh
Last active December 10, 2015 13:49
Script to update dns on Route 53. Original script by Johan Lindh with some changes to allow root A record update with "" for hostname.
#!/bin/sh
# This script will perform a DynDNS-like function for Amazon's Route 53
#
# Author: Johan Lindh <[email protected]>
# http://www.linkdata.se/
#
# Script requirements:
#
# wget
@pboos
pboos / MainActivity.java
Last active January 29, 2020 17:00
Sample code for ViewPager + PagerTabStrip.
package ch.pboos.android.sample.viewpager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@pboos
pboos / AndroidManifest.xml
Last active December 14, 2015 07:49
Android: Install/uninstall scala on rooted phone. Beware! Only use this if you know what you are doing!
<uses-library android:name="ch.pboos.scala-library-2.10.0"/>
<uses-library android:name="ch.pboos.scala-actors-2.10.0"/>
<uses-library android:name="ch.pboos.scala-collection-2.10.0"/>
<uses-library android:name="ch.pboos.scala-immutable-2.10.0"/>
<uses-library android:name="ch.pboos.scala-mutable-2.10.0"/>