Skip to content

Instantly share code, notes, and snippets.

View kennydude's full-sized avatar

Joe Simpson kennydude

View GitHub Profile
@kennydude
kennydude / Java.java
Created July 14, 2012 14:31
Encrypt from Java and decrypt on Node.js
// Encrypt where jo is input, and query is output and ENCRPYTION_KEy is key
byte[] input = jo.toString().getBytes("utf-8");
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] thedigest = md.digest(ENCRYPTION_KEY.getBytes("UTF-8"));
SecretKeySpec skc = new SecretKeySpec(thedigest, "AES/ECB/PKCS5Padding");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skc);
byte[] cipherText = new byte[cipher.getOutputSize(input.length)];
@kennydude
kennydude / ExtendedEditText.java
Created April 17, 2013 21:35
Ever wanted a prefix and suffix on your EditText? Yes, well this ExtendedEditText class will do it for you!
package me.kennydude.spending.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.text.Editable;
import android.text.TextPaint;
import android.text.TextWatcher;
.card{
background: #FFF;
border-radius: 2px;
border: 1px solid #ddd;
border-bottom-width: 2px;
margin-bottom: 10px;
}
<html><head>
<meta charset="UTF-8">
<!--
Copyright (c) 2013 by Joe Simpson (http://codepen.io/kennydude/pen/CnDAz)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@kennydude
kennydude / class.java
Created March 4, 2013 12:37
Custom style *should work roughly*
public static class BigPictureStyle extends Style {
private Bitmap mPicture;
private Bitmap mBigLargeIcon;
private boolean mBigLargeIconSet = false;
public BigPictureStyle() {
}
public BigPictureStyle(Builder builder) {
setBuilder(builder);
@kennydude
kennydude / gist:4953168
Created February 14, 2013 14:30
Success!!!!
while(noSuccess){
try{
tryAgain();
} catch(InvalidStateException e){
break;
} catch(SleepDeprevationException e){
sleep( new Hours(8) );
} catch(DeathException e){
break;
}
package me.kennydude.transtimetable.ui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.StateSet;
public class TabBackgroundDrawable extends Drawable {
@kennydude
kennydude / FragmentAdapter.java
Created July 28, 2012 18:07
FragmentAdapter Example
import java.util.ArrayList;
import java.util.List;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.ViewGroup;
@kennydude
kennydude / tumblr-unac.html
Created September 29, 2012 20:24
tumblr-unac.html
<div class="uac" style="background: #333; opacity: 0.9; position: absolute; top:0;left:0;bottom:0;right:0;display:none">
</div>
<div style="position: fixed; top: 50px; right: 0; left: 0; z-index: 999999999;display:none" class="uac">
<div style="background:#fff; margin: 0 auto; text-align: center; width:500px">
<h1>YOU ARE</h1>
<img src="http://25.media.tumblr.com/tumblr_mb4mphniug1qlqeu2o1_500.gif" />
</div></div>
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
@kennydude
kennydude / Activity.java
Created August 29, 2012 13:43
ProgressBar in ActionBar
public boolean onCreateOptionsMenu(final Menu menu) {
// Inflate Layout here
// ProgressBar
if(isRefreshing){
ProgressBar p = new ProgressBar(this, null, android.R.attr.progressBarStyleSmall);
menu.findItem(R.id.refreshAction).setActionView(p).setEnabled(false);
}
// Do other crazy stuff here