Skip to content

Instantly share code, notes, and snippets.

View fiskurgit's full-sized avatar
🌑
...

öppenteknikstudio fiskurgit

🌑
...
View GitHub Profile
@fiskurgit
fiskurgit / gist:9366187
Created March 5, 2014 12:21
Archive.org JSoup Scraper - Work in progress, and not pretty.
package com.fiskur;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/**
*
@fiskurgit
fiskurgit / gist:1bb7139d21c4b3db82ec
Created May 13, 2014 09:52
Original Google volley encodeParameters method
/**
* Converts <code>params</code> into an application/x-www-form-urlencoded encoded string.
*/
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
StringBuilder encodedParams = new StringBuilder();
try {
for (Map.Entry<String, String> entry : params.entrySet()) {
encodedParams.append(URLEncoder.encode(entry.getKey(), paramsEncoding));
encodedParams.append('=');
encodedParams.append(URLEncoder.encode(entry.getValue(), paramsEncoding));
@fiskurgit
fiskurgit / gist:9c21a55cb015065222b8
Last active August 29, 2015 14:01
Fixed Google Volley encodeParameters method
/**
* Converts <code>params</code> into an application/x-www-form-urlencoded encoded string.
*/
private byte[] encodeParameters(Map<String, String> params, String paramsEncoding) {
StringBuilder encodedParams = new StringBuilder();
try {
for(Iterator<Map.Entry<String, String>> i = params.entrySet().iterator(); i.hasNext(); ){
Map.Entry<String, String> entry = i.next();
@fiskurgit
fiskurgit / gist:766f315a12d7ee39af5a
Last active August 29, 2015 14:01
Perlin wave processing.org sketch
float noiseScale = 0.018F;
float n = 0.0F;
float speed = 0.4F;
int frameCount = 0;
void setup(){
size(600, 300);
frameRate(30);
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-scroll-header-panel/core-scroll-header-panel.html">
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
@fiskurgit
fiskurgit / MainActivity.java
Last active August 29, 2015 14:03
How to change the global music volume on Android
package com.fiskur.wearvolume;
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
package com.fiskur.wearvolume;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.media.AudioManager;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;
@fiskurgit
fiskurgit / screenshot.sh
Last active August 29, 2015 14:03
Bash script to take a screenshot from an attached Android device, and resize (maintaining aspect ratio) to a width of 270 pixels (OSX only).
#!/bin/sh
timestamp=$(date +%s)
filepath=/sdcard/$timestamp.png
echo $filepath
adb shell screencap -p $filepath
adb pull $filepath
adb shell rm $filepath
sips --resampleWidth 270 $timestamp.png
package com.degree53.percentbars;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.Parcelable;